diff options
author | Kai Blin <kai@samba.org> | 2011-07-08 15:05:38 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2011-07-26 22:22:25 +0200 |
commit | 072c199180d7d0580665f15e4182f32bf9a565c0 (patch) | |
tree | b1b1f8b26ce453e6e326f8766766d00b103d6c11 /source3 | |
parent | c02df79f610d69d5311b7659f94d9161e88836ee (diff) | |
download | samba-072c199180d7d0580665f15e4182f32bf9a565c0.tar.gz samba-072c199180d7d0580665f15e4182f32bf9a565c0.tar.bz2 samba-072c199180d7d0580665f15e4182f32bf9a565c0.zip |
s3 swat: Add XSRF protection to password page
Signed-off-by: Kai Blin <kai@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/web/swat.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source3/web/swat.c b/source3/web/swat.c index 2ad2870adc..8f64a5426f 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -1238,12 +1238,15 @@ static void chg_passwd(void) static void passwd_page(void) { const char *new_name = cgi_user_name(); + const char passwd_form[] = "passwd"; + const char rpasswd_form[] = "rpasswd"; if (!new_name) new_name = ""; printf("<H2>%s</H2>\n", _("Server Password Management")); printf("<FORM name=\"swatform\" method=post>\n"); + print_xsrf_token(cgi_user_name(), cgi_user_pass(), passwd_form); printf("<table>\n"); @@ -1283,14 +1286,16 @@ static void passwd_page(void) * 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(CHG_S_PASSWD_FLAG)) || (cgi_variable(ADD_USER_FLAG)) || (cgi_variable(DELETE_USER_FLAG)) || - (cgi_variable(DISABLE_USER_FLAG)) || (cgi_variable(ENABLE_USER_FLAG))) { + if (verify_xsrf_token(passwd_form) && + ((cgi_variable(CHG_S_PASSWD_FLAG)) || (cgi_variable(ADD_USER_FLAG)) || (cgi_variable(DELETE_USER_FLAG)) || + (cgi_variable(DISABLE_USER_FLAG)) || (cgi_variable(ENABLE_USER_FLAG)))) { chg_passwd(); } printf("<H2>%s</H2>\n", _("Client/Server Password Management")); printf("<FORM name=\"swatform\" method=post>\n"); + print_xsrf_token(cgi_user_name(), cgi_user_pass(), rpasswd_form); printf("<table>\n"); @@ -1323,7 +1328,7 @@ static void passwd_page(void) * 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)) { + if (verify_xsrf_token(passwd_form) && cgi_variable(CHG_R_PASSWD_FLAG)) { chg_passwd(); } |