summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2011-07-08 15:05:38 +0200
committerKarolin Seeger <kseeger@samba.org>2011-07-24 20:45:48 +0200
commit4850456845d2da5e3451716a5ad4ca0ef034e01f (patch)
treed9f24668970f45de15b26bbd207a594b5040d9dd
parentef457a20422cfa8231e25b539d2cd87f299686b9 (diff)
downloadsamba-4850456845d2da5e3451716a5ad4ca0ef034e01f.tar.gz
samba-4850456845d2da5e3451716a5ad4ca0ef034e01f.tar.xz
samba-4850456845d2da5e3451716a5ad4ca0ef034e01f.zip
s3 swat: Add XSRF protection to password page
Signed-off-by: Kai Blin <kai@samba.org>
-rw-r--r--source/web/swat.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/web/swat.c b/source/web/swat.c
index 4544c318e35..524248481b9 100644
--- a/source/web/swat.c
+++ b/source/web/swat.c
@@ -1225,12 +1225,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");
@@ -1270,14 +1273,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");
@@ -1310,7 +1315,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();
}