summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-07-28 13:04:38 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-07-28 13:06:29 +0300
commit02e7cfc6b4603be8ff3b69abbfad50193aaee845 (patch)
tree8f280262c505ae5ae7d5d89bed303d0b144ad743
parent0946cb09b5cee9e14846df17fc44ccbaf31a3d1e (diff)
downloadsquark-02e7cfc6b4603be8ff3b69abbfad50193aaee845.tar.bz2
squark-02e7cfc6b4603be8ff3b69abbfad50193aaee845.tar.xz
auth: read net-snmp configuration files
This allows setting SNMPv3 configuration via the standard config files. If SNMP community is given from command line, we fallback to SNMPv2c mode.
-rw-r--r--squark-auth.85
-rw-r--r--squark-auth.c13
2 files changed, 12 insertions, 6 deletions
diff --git a/squark-auth.8 b/squark-auth.8
index 7d83c9d..ca4be00 100644
--- a/squark-auth.8
+++ b/squark-auth.8
@@ -29,8 +29,9 @@ the port and connected client.
The following options are recognized:
.IP "\fB\-c \fIsnmp\-communicty"
-Specifies the SNMP community to be used. Currently the same community
-is used for all switches.
+Allows specifying SNMP community. If specified SNMPv2c mode is assumed.
+To use SNMPv3 you need to configure the required version and authentication
+keys using standard net-snmp configuration files.
.IP "\fB\-r \fIlayer3\-root\-ip"
The management IP-address of the default gateway router for the clients.
diff --git a/squark-auth.c b/squark-auth.c
index 73f9e0f..88f4d61 100644
--- a/squark-auth.c
+++ b/squark-auth.c
@@ -90,7 +90,7 @@ struct switch_info;
static int num_queries = 0, running = TRUE;
-static const char *snmp_community = "public";
+static const char *snmp_community = NULL;
static const char *username_format = "%w";
static struct switch_info *all_switches[SWITCH_HASH_SIZE];
static struct switch_info *l3_root_dev, *l2_root_dev;
@@ -524,9 +524,11 @@ struct switch_info *get_switch(sockaddr_any *addr)
addr_copy(&si->addr, addr);
snmp_sess_init(&config);
- config.version = SNMP_VERSION_2c;
- config.community = (unsigned char *) snmp_community;
- config.community_len = strlen(snmp_community);
+ if (snmp_community != NULL) {
+ config.version = SNMP_VERSION_2c;
+ config.community = (unsigned char *) snmp_community;
+ config.community_len = strlen(snmp_community);
+ }
config.peername = (char *) addr_print(addr);
si->session = snmp_open(&config);
@@ -1176,6 +1178,9 @@ int main(int argc, char **argv)
fd_set fdset;
int opt, fds, block;
+ setenv("MIBS", "", 1);
+ init_snmp("squark-auth");
+
while ((opt = getopt(argc, argv, "c:r:i:R:v:f:T:")) != -1) {
switch (opt) {
case 'c':