mod_admserv/mod_admserv.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
New commits:
commit 0f074403a6a59449bf7271a45840c284bee5a8f1
Author: Noriko Hosoi <nhosoi(a)jiji.usersys.redhat.com>
Date: Sat Feb 12 18:42:33 2011 -0800
Bug 245278 - Changing to a password with a single quote does not work
https://bugzilla.redhat.com/show_bug.cgi?id=245278
Description: When the Admin User password is changed on the Admin
Console, the console escapes the password then sends it to the
Admin Server. This patch adds the apache API ap_unescape_url to
mod_admserv to unescape the password before handling it. Since
ap_unescape_url does the unescape in place, it duplicates the
given password and escapes on the duplicated memory.
diff --git a/mod_admserv/mod_admserv.c b/mod_admserv/mod_admserv.c
index 6f96669..ede5c33 100644
--- a/mod_admserv/mod_admserv.c
+++ b/mod_admserv/mod_admserv.c
@@ -1330,13 +1330,14 @@ bailout:
/*
* Modify SIE password
+ * query points to new password
*/
static int
change_sie_password(const char *name, char *query, void* arg, request_rec *r)
{
FILE *f;
char *uid=NULL , *col=NULL, *origpw_hash=NULL;
- char *newpw=query;
+ char *newpw = NULL;
char filename[BIG_LINE];
char inbuf[BIG_LINE];
char outbuf[64]; /* needs at least 36 bytes */
@@ -1345,7 +1346,7 @@ change_sie_password(const char *name, char *query, void* arg,
request_rec *r)
apr_snprintf(filename, sizeof(filename), "%s/admpw", configdir);
- if (newpw==NULL) {
+ if (query==NULL) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r,
"Wrong usage, password param missing");
return 0;
@@ -1373,6 +1374,14 @@ change_sie_password(const char *name, char *query, void* arg,
request_rec *r)
uid = inbuf; *col=0; origpw_hash=col+1;
+ /* newpw is escaped; it needs to be unescaped. */
+ newpw = strdup(query);
+ if (NULL == newpw) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+ "failed to allocate memory for password");
+ goto recover;
+ }
+ ap_unescape_url(newpw);
apr_sha1_base64(newpw, strlen(newpw), outbuf);
if (!update_admpwd(configdir, uid, outbuf)) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
@@ -1381,7 +1390,7 @@ change_sie_password(const char *name, char *query, void* arg,
request_rec *r)
}
admpwd_done = 1;
- if (!task_update_registry_server_bindpw(uid, strdup(newpw), bindpw, r)) {
+ if (!task_update_registry_server_bindpw(uid, newpw, bindpw, r)) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
"failed to update server bindpw");
goto recover;
@@ -1390,6 +1399,9 @@ change_sie_password(const char *name, char *query, void* arg,
request_rec *r)
return 1;
recover:
+ if (newpw) {
+ free(newpw);
+ }
if (admpwd_done) {
update_admpwd(configdir, uid, origpw_hash);
}