From 7877caa44efaf1d483e6e3d76c1c6b3b5937e64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Tue, 14 Jun 2011 16:15:08 +0300 Subject: Revert "filter: support filter-only and track-only modes" This reverts commit a1277ab45a9d2bab9ca28baf05f978bf8066d928. --- src/squark-filter.c | 70 +++++++---------------------------------------------- 1 file changed, 9 insertions(+), 61 deletions(-) (limited to 'src/squark-filter.c') diff --git a/src/squark-filter.c b/src/squark-filter.c index db8fb38..22c8800 100644 --- a/src/squark-filter.c +++ b/src/squark-filter.c @@ -26,17 +26,11 @@ #define FILTER_OVERRIDE_TIMEOUT (15*60) -#define MODE_NOAUTH 0 -#define MODE_TRACK 1 -#define MODE_CAPTIVE 2 - static struct sqdb db; static struct authdb adb; static struct authdb_config adbc; static int running = 1; -static int mode = MODE_CAPTIVE; - static const blob_t dash = BLOB_STR_INIT("-"); static const blob_t space = BLOB_STR_INIT(" "); static const blob_t slash = BLOB_STR_INIT("/"); @@ -407,22 +401,12 @@ static void read_input(struct sqdb *db) else category = 0; - if (mode == MODE_NOAUTH) { + token = authdb_get(&adb, &addr, &entry, 1); + if (authdb_check_login(token, &entry, username, now, &adbc)) { auth_ok = 1; + username = BLOB_STRLEN(entry.p.login_name); } else { - token = authdb_get(&adb, &addr, &entry, 1); - if (authdb_check_login(token, &entry, username, now, &adbc)) { - auth_ok = 1; - username = BLOB_STRLEN(entry.p.login_name); - } else if (mode == MODE_TRACK) { - auth_ok = 1; - authdb_clear_entry(&entry); - memcpy(entry.p.login_name, username.ptr, username.len); - authdb_commit_login(token, &entry, now, &adbc); - } else { - /* mode == MODE_CAPTIVE, and not authenticated */ - auth_ok = 0; - } + auth_ok = 0; } if (!auth_ok) { @@ -445,61 +429,25 @@ static void read_input(struct sqdb *db) } while (b.len); } -static int usage(const char *progname) -{ - fprintf(stderr, - "Usage: %s [-m {captive|track|nauth}]\n" - "\n" - "Program arguments:\n" - " -m Select authentication mode:\n" - " captive captive portal authentication enforced\n" - " track squid authentication is tracked if available\n" - " noauth authentication infromation is ignored (filter only)\n", - progname); - return 1; -} - int main(int argc, char **argv) { - int rc = 1, opt; - - while ((opt = getopt(argc, argv, "hm:")) != -1) { - switch (opt) { - case 'm': - if (!strcmp(optarg, "captive")) - mode = MODE_CAPTIVE; - else if (!strcmp(optarg, "track")) - mode = MODE_TRACK; - else if (!strcmp(optarg, "noauth")) - mode = MODE_NOAUTH; - else - return usage(argv[0]); - break; - case 'h': - default: - return usage(argv[0]); - } - } + int rc = 1; if (sqdb_open(&db, squark_dbname) < 0) { fprintf(stderr, "%s: failed to open squarkdb\n", squark_dbname); goto err_sqdb; } - - if (mode != MODE_NOAUTH) { - if (authdb_open(&adb, &adbc, &db) < 0) { - fprintf(stderr, "Failed to initialize authdb\n"); - goto err_adb; - } + if (authdb_open(&adb, &adbc, &db) < 0) { + fprintf(stderr, "Failed to initialize authdb\n"); + goto err_adb; } while (running) read_input(&db); rc = 0; - if (mode != MODE_NOAUTH) - authdb_close(&adb); + authdb_close(&adb); err_adb: sqdb_close(&db); err_sqdb: -- cgit v1.2.3