aboutsummaryrefslogtreecommitdiff
path: root/wfm.c
diff options
context:
space:
mode:
authorAntoni Sawicki <tenox@google.com>2018-12-02 23:56:00 -0800
committerAntoni Sawicki <tenox@google.com>2018-12-02 23:56:00 -0800
commit8ccfbbb36d34a4abb9ac2bcd1b718cc56f0f71e7 (patch)
treece9e18ad84a956c0d119d72624ab5558442d4ee2 /wfm.c
parent5742b81f67db190340f695a5f1a17da96b7c13c2 (diff)
downloadwfm-8ccfbbb36d34a4abb9ac2bcd1b718cc56f0f71e7.tar.gz
hack to logoff htauth session
Diffstat (limited to 'wfm.c')
-rw-r--r--wfm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/wfm.c b/wfm.c
index 8064797..a2da6d9 100644
--- a/wfm.c
+++ b/wfm.c
@@ -140,8 +140,9 @@ void access_check(char *access_string) {
rt.access_level=PERM_RO;
else if(strcmp(type, "rw")==0)
rt.access_level=PERM_RW;
- }
-
+
+ rt.auth_method=AUTH_IP;
+ }
}
else if(sscanf(access_string, "access-md5pw=%2[^':']:%30[^':']:%63s", type, user, pass)==3) {
cfg.users_defined=1;
@@ -154,6 +155,7 @@ void access_check(char *access_string) {
rt.access_level=PERM_RW;
rt.access_as_user=1;
+ rt.auth_method=AUTH_MD5;
strncpy(rt.loggedinuser, user, sizeof(rt.loggedinuser));
}
}
@@ -167,6 +169,7 @@ void access_check(char *access_string) {
rt.access_level=PERM_RW;
rt.access_as_user=1;
+ rt.auth_method=AUTH_HT;
strncpy(rt.loggedinuser, getenv("REMOTE_USER"), sizeof(rt.loggedinuser));
}
}
@@ -478,6 +481,16 @@ void redirect(char *location, ...) {
va_end(ap);
cgiHeaderLocation(buff);
+ exit(0);
+}
+
+//
+// Log off user from HTAUTH session
+//
+void logoff() {
+ cgiHeaderStatus(401, "Unauthorized");
+ fprintf(cgiOut, "You have been logged out.");
+ exit(0);
}
@@ -564,9 +577,11 @@ int cgiMain(void) {
char ea[8]={0};
// early action - simple actions before cfg is read or access check performed (no authentication!)
+ // note that ea functions must exit()
cgiFormStringNoNewlines("ea", ea, sizeof(ea));
if(strcmp(ea, "icon")==0) icon();
// if(strcmp(ea, "upstat")==0) upload_status();
+ if(strcmp(ea, "logoff")==0) logoff();
// normal initialization
tstart();