From 6559aa10d55dd7a71e3b7c7cdee1ff3c7a58ac37 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 11 Nov 1998 21:37:44 +0000 Subject: added password change functionality to swat (This used to be commit 06d4026cf1521766b52766193774f1fd8dd70c81) --- source3/web/cgi.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'source3/web/cgi.c') diff --git a/source3/web/cgi.c b/source3/web/cgi.c index 38be0de3c6..a11abe074e 100644 --- a/source3/web/cgi.c +++ b/source3/web/cgi.c @@ -44,6 +44,7 @@ static int request_post; static char *query_string; static char *baseurl; static char *pathinfo; +static char *C_user; static void unescape(char *buf) { @@ -311,16 +312,32 @@ static int cgi_handle_authorization(char *line) user = line; pass = p+1; - /* currently only allow connections as root */ - if (strcmp(user,"root")) { - cgi_setup_error("401 Bad Authorization", "", - "incorrect username/password"); - } - + /* Save the users name */ + C_user = strdup(user); return pass_check(user, pass, strlen(pass), NULL, NULL); } +/*************************************************************************** +is this root? + ***************************************************************************/ +BOOL is_root() +{ + if ((C_user) && (strcmp(C_user,"root") == 0)) { + return( True); + } else { + return( False); + } +} + +/*************************************************************************** +return a ptr to the users name + ***************************************************************************/ +char * get_user_name() +{ + return(C_user); +} + /*************************************************************************** handle a file download @@ -390,6 +407,16 @@ void cgi_setup(char *rootdir, int auth_required) } if (getenv("CONTENT_LENGTH") || getenv("REQUEST_METHOD")) { + + char *x; + + /* Save the users name if available */ + if (x = getenv("REMOTE_USER")) { + C_user = strdup(x); + } else { + C_user = ""; + } + /* assume we are running under a real web server */ return; } -- cgit