summaryrefslogtreecommitdiffstats
path: root/src/squark-auth-snmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/squark-auth-snmp.c')
-rw-r--r--src/squark-auth-snmp.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/squark-auth-snmp.c b/src/squark-auth-snmp.c
index aa45c73..40ef6b5 100644
--- a/src/squark-auth-snmp.c
+++ b/src/squark-auth-snmp.c
@@ -26,6 +26,7 @@
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
+#include "config.h"
#include "blob.h"
#include "addr.h"
#include "authdb.h"
@@ -1063,13 +1064,16 @@ int main(int argc, char **argv)
struct timeval timeout;
sockaddr_any addr;
fd_set fdset;
- int opt, fds, block, i;
+ int opt, fds, block, i, rc = 1;
setenv("MIBS", "", 1);
init_snmp("squark-auth");
- while ((opt = getopt(argc, argv, "c:r:i:R:v:f:T:K")) != -1) {
+ while ((opt = getopt(argc, argv, "Vc:r:i:R:v:f:T:K")) != -1) {
switch (opt) {
+ case 'V':
+ fprintf(stderr, "squark-auth-snmp %s\n", squark_version);
+ return 0;
case 'c':
snmp_community = optarg;
break;
@@ -1104,8 +1108,15 @@ int main(int argc, char **argv)
return 1;
}
- sqdb_open(&db, "/var/lib/squark/squark.db");
- authdb_open(&adb, &adbc, &db);
+ if (sqdb_open(&db, squark_dbname) < 0) {
+ fprintf(stderr, "%s: failed to open squarkdb\n",
+ squark_dbname);
+ goto err_sqdb;
+ }
+ if (authdb_open(&adb, &adbc, &db) < 0) {
+ fprintf(stderr, "Failed to initialize authdb\n");
+ goto err_adb;
+ }
if (l2_root == NULL)
l2_root = l3_root;
@@ -1145,8 +1156,12 @@ int main(int argc, char **argv)
} else
snmp_timeout();
}
+ rc = 0;
+
authdb_close(&adb);
+err_adb:
sqdb_close(&db);
+err_sqdb:
- return 0;
+ return rc;
}