Someone on the list had requested the ability to set the username that appears at the login screen after I created my last patch. The new patch is included - it keeps the old behavior, displaying posmaster unless overridden. I modified the getting of the post/get variables, so this actually decreases the size of qmailadmin.c slightly. Usage is: http://host/cgi-bin/qmailadmin?username=someuser&domain=somedomain For security reasons, I'm not allowing you to set the password. It only takes a simple change to the source if you want that. Enjoy, Hampton
*** qmailadmin.c.old Wed Jan 10 12:46:26 2001 --- qmailadmin.c Wed Mar 21 15:43:20 2001 *************** *** 99,119 **** pi=getenv("PATH_INFO"); if ( pi ) pi = strdup(pi); if (pi && strncmp(pi, "/com/", 5) == 0) { struct passwd *pw; memset(TmpBuf2,0,MAX_BUFF); for(j=0,i=5;pi[i]!=0&&j<99;++i,++j) TmpBuf2[j] = pi[i]; - rm = getenv("REQUEST_METHOD"); - rm = strdup(rm); - - if ( strncmp(rm , "POST", 4) == 0 ) { - get_cgi(); - } else { - TmpCGI = (char *)getenv("QUERY_STRING"); - TmpCGI = strdup(TmpCGI); - } GetValue(TmpCGI,Username, "user=",MAX_BUFF); GetValue(TmpCGI,Domain, "dom=",MAX_BUFF); --- 99,120 ---- pi=getenv("PATH_INFO"); if ( pi ) pi = strdup(pi); + rm = getenv("REQUEST_METHOD"); + rm = strdup(rm); + + if ( strncmp(rm, "POST", 4) == 0 ) { + get_cgi(); + } else { + TmpCGI = (char *)getenv("QUERY_STRING"); + TmpCGI = strdup(TmpCGI); + } + if (pi && strncmp(pi, "/com/", 5) == 0) { struct passwd *pw; memset(TmpBuf2,0,MAX_BUFF); for(j=0,i=5;pi[i]!=0&&j<99;++i,++j) TmpBuf2[j] = pi[i]; GetValue(TmpCGI,Username, "user=",MAX_BUFF); GetValue(TmpCGI,Domain, "dom=",MAX_BUFF); *************** *** 146,160 **** memset(TmpBuf2,0,MAX_BUFF); for(j=0,i=6;pi[i]!=0&&j<99;++i,++j) TmpBuf2[j] = pi[i]; - rm = getenv("REQUEST_METHOD"); - rm = strdup(rm); - - if ( strncmp(rm , "POST", 4) == 0 ) { - get_cgi(); - } else { - TmpCGI = (char *)getenv("QUERY_STRING"); - TmpCGI = strdup(TmpCGI); - } GetValue(TmpCGI,Username, "user=",MAX_BUFF); GetValue(TmpCGI,Domain, "dom=",MAX_BUFF); --- 147,152 ---- *************** *** 176,192 **** } else { - char *rm; struct passwd *pw; FILE *fs; - rm = getenv("REQUEST_METHOD"); - if ( rm ) rm = strdup(rm); - if ( rm && strncmp(rm, "POST", 4) == 0 ) { - get_cgi(); - GetValue(TmpCGI,Username, "username=",MAX_BUFF); GetValue(TmpCGI,Domain, "domain=",MAX_BUFF); GetValue(TmpCGI,Password, "password=",MAX_BUFF); --- 168,178 ---- *************** *** 233,238 **** --- 219,229 ---- } } } + + if ( GetValue(TmpCGI,Username, "username=",MAX_BUFF) ) { + strcpy(Username, "postmaster"); /* default for old behavior */ + } + GetValue(TmpCGI,Domain, "domain=",MAX_BUFF); show_login(); }
*** show_login.html.old Wed Mar 21 15:48:28 2001 --- show_login.html Wed Mar 21 15:38:24 2001 *************** *** 43,50 **** <!--Content--> <form method=post name=logon action=##C> <table> ! <tr><td>##X112</td><td><input type=text size=14 name=username maxlength=128></td></tr> ! <tr><td>##X113</td><td><input type=text size=14 name=domain maxlength=128></td></tr> <tr><td>##X057</td><td><input type=password size=14 name=password maxlength=128></td></tr> <tr><td><input type=submit value="##X114" name="##X114"></td> </table> --- 43,50 ---- <!--Content--> <form method=post name=logon action=##C> <table> ! <tr><td>##X112</td><td><input type=text size=14 name=username value="##U" maxlength=128></td></tr> ! <tr><td>##X113</td><td><input type=text size=14 name=domain value="##D" maxlength=128></td></tr> <tr><td>##X057</td><td><input type=password size=14 name=password maxlength=128></td></tr> <tr><td><input type=submit value="##X114" name="##X114"></td> </table>