diff options
author | Antoni Sawicki <tenox@google.com> | 2019-05-07 02:28:07 -0700 |
---|---|---|
committer | Antoni Sawicki <tenox@google.com> | 2019-05-07 02:28:07 -0700 |
commit | 743efdd88a2426157d8f3ec9ec3f4ade6443d1a8 (patch) | |
tree | d9b85e9d1893798a7daaa06ba3f6c9e29bba52c8 /wfm.c | |
parent | a0b8da9be6615423bdb9ee6f26dbbaadd45ca0ae (diff) | |
parent | 09f7627ac34a92c4299b3bdd2cebd853f0d3b34e (diff) | |
download | wfm-743efdd88a2426157d8f3ec9ec3f4ade6443d1a8.tar.gz |
auth method and others
Diffstat (limited to 'wfm.c')
-rw-r--r-- | wfm.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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)); } } @@ -168,6 +170,7 @@ void access_check(char *access_string) { rt.access_as_user=1; snprintf(rt.loggedinuser, sizeof(rt.loggedinuser), "%s", getenv("REMOTE_USER") ); + rt.auth_method=AUTH_HT; } } } @@ -479,6 +482,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); } @@ -565,9 +578,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(); |