summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-06-14 16:15:08 +0300
committerTimo Teräs <timo.teras@iki.fi>2011-06-14 16:15:08 +0300
commit7877caa44efaf1d483e6e3d76c1c6b3b5937e64d (patch)
treeb7503d54f52793a9d9c8c931f5fab2089c9db016
parent90b8f5899a5881106bdd0873b6741bc747190218 (diff)
downloadsquark-7877caa44efaf1d483e6e3d76c1c6b3b5937e64d.tar.bz2
squark-7877caa44efaf1d483e6e3d76c1c6b3b5937e64d.tar.xz
Revert "filter: support filter-only and track-only modes"
-rw-r--r--src/squark-filter.c70
1 files changed, 9 insertions, 61 deletions
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: