From 02e7cfc6b4603be8ff3b69abbfad50193aaee845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Wed, 28 Jul 2010 13:04:38 +0300 Subject: 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. --- squark-auth.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'squark-auth.c') 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': -- cgit v1.2.3