diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-09-03 13:41:04 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2010-09-03 13:41:04 +0300 |
commit | 050e200061d2b5002251c85a83c55bb7e1864a39 (patch) | |
tree | b17b56e60d176bd349e4f419cc25bbfffd1fcc1b /squark-auth-ip.c | |
parent | 5bc7fd8f1e41365677eb6787cb7d2a6dea62ee0c (diff) | |
download | squark-050e200061d2b5002251c85a83c55bb7e1864a39.tar.bz2 squark-050e200061d2b5002251c85a83c55bb7e1864a39.tar.xz |
auth-ip: implement logout
Implement logout function and some minor fixes.
Diffstat (limited to 'squark-auth-ip.c')
-rw-r--r-- | squark-auth-ip.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/squark-auth-ip.c b/squark-auth-ip.c index dff4f8d..6993e85 100644 --- a/squark-auth-ip.c +++ b/squark-auth-ip.c @@ -17,9 +17,10 @@ #include "blob.h" #include "authdb.h" -#define DO_LOGIN -1 -#define DO_OVERRIDE -2 -#define DO_PRINT -3 +#define DO_LOGIN -1 +#define DO_OVERRIDE -2 +#define DO_PRINT -3 +#define DO_LOGOUT -4 static int running = 1; static struct authdb adb; @@ -106,7 +107,7 @@ int main(int argc, char **argv) sockaddr_any ipaddr = { .any.sa_family = AF_UNSPEC }; blob_t ip = BLOB_NULL, username = BLOB_NULL; - while ((opt = getopt(argc, argv, "i:u:olp")) != -1) { + while ((opt = getopt(argc, argv, "i:u:olpL")) != -1) { switch (opt) { case 'i': ip = BLOB_STRLEN(optarg); @@ -128,6 +129,9 @@ int main(int argc, char **argv) case 'p': running = DO_PRINT; break; + case 'L': + running = DO_LOGOUT; + break; } } @@ -168,13 +172,28 @@ int main(int argc, char **argv) fprintf(stdout, "IP-address: %s\n" "Username: %s\n" + "MAC-address: %02x:%02x:%02x:%02x:%02x:%02x\n" + "Soft block mask: %016llx\n" + "Hard block mask: %016llx\n" "Login time: %s" "Override time: %s", ip.ptr, - username.ptr, + entry.p.login_name, + entry.p.mac_address[0], + entry.p.mac_address[1], + entry.p.mac_address[2], + entry.p.mac_address[3], + entry.p.mac_address[4], + entry.p.mac_address[5], + entry.p.block_categories, + entry.p.hard_block_categories, entry.u.login_time ? ctime_r(&entry.u.login_time, buf1) : "<none>\n", entry.u.override_time ? ctime_r(&entry.u.override_time, buf2) : "<none>\n"); break; + case DO_LOGOUT: + if (authdb_check_login(token, &entry, username, now)) + authdb_commit_logout(token); + break; } } else { while (running) |