diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-07-28 13:04:38 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2010-07-28 13:06:29 +0300 |
commit | 02e7cfc6b4603be8ff3b69abbfad50193aaee845 (patch) | |
tree | 8f280262c505ae5ae7d5d89bed303d0b144ad743 /squark-auth.c | |
parent | 0946cb09b5cee9e14846df17fc44ccbaf31a3d1e (diff) | |
download | squark-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.
Diffstat (limited to 'squark-auth.c')
-rw-r--r-- | squark-auth.c | 13 |
1 files changed, 9 insertions, 4 deletions
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': |