summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/squark-auth-snmp.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/squark-auth-snmp.c b/src/squark-auth-snmp.c
index e6947c4..90a908b 100644
--- a/src/squark-auth-snmp.c
+++ b/src/squark-auth-snmp.c
@@ -571,20 +571,25 @@ static void auth_completed(struct auth_context *auth)
void *token;
struct authdb_entry entry;
blob_t b, uf;
+ int ok = 1;
token = authdb_get(&adb, &auth->addr, &entry, 1);
authdb_clear_entry(&entry);
- b = BLOB_BUF(tmp);
- blob_push(&b, BLOB_STRLEN(auth->token));
- blob_push(&b, BLOB_STR(" OK user="));
- uf_a = b.ptr;
- blob_push_formatted_username(&b, username_format, auth);
- uf_b = b.ptr;
- blob_push(&b, BLOB_PTR_LEN("\n", 1));
- uf = BLOB_PTR_PTR(uf_a, uf_b);
+ if (auth_ok(auth)) {
+ b = BLOB_BUF(tmp);
+ blob_push(&b, BLOB_STRLEN(auth->token));
+ blob_push(&b, BLOB_STR(" OK user="));
+ uf_a = b.ptr;
+ blob_push_formatted_username(&b, username_format, auth);
+ uf_b = b.ptr;
+ blob_push(&b, BLOB_PTR_LEN("\n", 1));
+ uf = BLOB_PTR_PTR(uf_a, uf_b);
+ } else {
+ ok = 0;
+ }
- if (auth_ok(auth) && uf.len <= sizeof(entry.p.login_name)) {
+ if (ok && uf.len <= sizeof(entry.p.login_name)) {
if (token != NULL &&
!authdb_check_login(token, &entry, uf, current_time, &adbc)) {
authdb_clear_entry(&entry);