From 7e71258563a8d34eb1fa1a67e27d7339510bffc9 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Thu, 12 Nov 1998 18:44:16 +0000 Subject: changes from John Sygulla for changing remote passwords (This used to be commit e3fc90d0b5b21d49615c951a475d85f15fa01271) --- source3/web/swat.c | 96 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 79 insertions(+), 17 deletions(-) (limited to 'source3/web/swat.c') diff --git a/source3/web/swat.c b/source3/web/swat.c index a1e56e9389..c2e5ea560e 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -38,10 +38,12 @@ static BOOL demo_mode = False; #define OLD_PSWD "old_passwd" #define NEW_PSWD "new_passwd" #define NEW2_PSWD "new2_passwd" -#define CHG_PASSWD_FLAG "chg_passwd_flag" +#define CHG_S_PASSWD_FLAG "chg_s_passwd_flag" +#define CHG_R_PASSWD_FLAG "chg_r_passwd_flag" #define ADD_USER_FLAG "add_user_flag" #define DISABLE_USER_FLAG "disable_user_flag" #define ENABLE_USER_FLAG "enable_user_flag" +#define RHOST "remote_host" /* we need these because we link to locking*.o */ void become_root(BOOL save_dir) {} @@ -605,6 +607,7 @@ static BOOL change_password(const char *remote_machine, char *user_name, ****************************************************************************/ static void chg_passwd(void) { + char *host; BOOL rslt; /* Make sure users name has been specified */ @@ -619,12 +622,22 @@ static void chg_passwd(void) */ if (!cgi_variable(DISABLE_USER_FLAG) && !cgi_variable(ENABLE_USER_FLAG)) { - /* If current user is not root, make sure old password has been specified */ - if ((am_root() == False) && (strlen( cgi_variable(OLD_PSWD)) <= 0)) { + /* + * If current user is not root, make sure old password has been specified + * If REMOTE change, even root must provide old password + */ + if (((am_root() == False) && (strlen( cgi_variable(OLD_PSWD)) <= 0)) || + ((cgi_variable(CHG_R_PASSWD_FLAG)) && (strlen( cgi_variable(OLD_PSWD)) <= 0))) { printf("

Must specify \"Old Password\" \n"); return; } + /* If changing a users password on a remote hosts we have to know what host */ + if ((cgi_variable(CHG_R_PASSWD_FLAG)) && (strlen( cgi_variable(RHOST)) <= 0)) { + printf("

Must specify \"Remote Machine\" \n"); + return; + } + /* Make sure new passwords have been specified */ if ((strlen( cgi_variable(NEW_PSWD)) <= 0) || (strlen( cgi_variable(NEW2_PSWD)) <= 0)) { @@ -639,7 +652,14 @@ static void chg_passwd(void) } } - rslt = change_password(am_root() ? NULL : "127.0.0.1", + if (cgi_variable(CHG_R_PASSWD_FLAG)) { + host = cgi_variable(RHOST); + } else if (am_root()) { + host = NULL; + } else { + host = "127.0.0.1"; + } + rslt = change_password(host, cgi_variable(USER), cgi_variable(OLD_PSWD), cgi_variable(NEW_PSWD), cgi_variable(ADD_USER_FLAG)? True : False, @@ -663,12 +683,6 @@ static void passwd_page(void) { char *new_name = get_user_name(); - printf("

Password Manager

\n"); - - printf("
\n"); - - printf("\n"); - /* * After the first time through here be nice. If the user * changed the User box text to another users name, remember it. @@ -679,6 +693,15 @@ static void passwd_page(void) if (!new_name) new_name = ""; + printf("

Server Password Management

\n"); + + printf("\n"); + + printf("
\n"); + + /* + * Create all the dialog boxes for data collection + */ printf("

User Name : \n", USER, new_name); if (am_root() == False) { @@ -687,21 +710,60 @@ static void passwd_page(void) printf("

New Password: \n",NEW_PSWD); printf("

Re-type New Password: \n",NEW2_PSWD); - printf("

"); - printf("

\n"); + printf("\n"); /* - * If we don't have user information then there's nothing to do. It's probably - * the first time through this code. + * Do some work if change, add, disable or enable was requested. It could be + * this is the first time through this code, so there isn't anything to do. */ - if (cgi_variable(USER)) { + if ((cgi_variable(CHG_S_PASSWD_FLAG)) || (cgi_variable(ADD_USER_FLAG)) || + (cgi_variable(DISABLE_USER_FLAG)) || (cgi_variable(ENABLE_USER_FLAG))) { + chg_passwd(); + } + + printf("
"); - printf("", CHG_PASSWD_FLAG); + /* + * Create all the control buttons for requesting action + */ + printf("

"); + printf("", CHG_S_PASSWD_FLAG); if (am_root() == True) { printf("", ADD_USER_FLAG); printf("", DISABLE_USER_FLAG); printf("", ENABLE_USER_FLAG); } - printf("
"); + + printf("
\n"); + + printf("

Client/Server Password Management

\n"); + + printf("
\n"); + + printf("\n"); + + /* + * Create all the dialog boxes for data collection + */ + printf("

User Name : \n", + USER, new_name); + printf("

Old Password: \n",OLD_PSWD); + printf("

New Password: \n",NEW_PSWD); + printf("

Re-type New Password: \n",NEW2_PSWD); + printf("

Remote Machine: \n",RHOST); + + /* + * Create all the control buttons for requesting action + */ + printf("

\n"); + + /* + * Do some work if a request has been made to change the password somewhere other + * than the server. It could be this is the first time through this code, so there + * isn't anything to do. + */ + if (cgi_variable(CHG_R_PASSWD_FLAG)) { chg_passwd(); } -- cgit
"); + printf("", CHG_R_PASSWD_FLAG); + printf("