summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2011-07-08 15:04:48 +0200
committerKarolin Seeger <kseeger@samba.org>2011-07-27 19:40:10 +0200
commitd7056ec2d31ede5f03c1dc0da09a6c26a0f07b77 (patch)
treedcdfbcc873f46837b060bc0955d75b03b22683b7
parent43bb2d4e9f162f2aaa4ae56dba27170fe1b8e9ae (diff)
downloadsamba-d7056ec2d31ede5f03c1dc0da09a6c26a0f07b77.tar.gz
s3 swat: Add XSRF protection to shares page
Signed-off-by: Kai Blin <kai@samba.org> (cherry picked from commit ef457a20422cfa8231e25b539d2cd87f299686b9)
-rw-r--r--source/web/swat.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/source/web/swat.c b/source/web/swat.c
index 5d11685db18..4544c318e35 100644
--- a/source/web/swat.c
+++ b/source/web/swat.c
@@ -982,11 +982,17 @@ static void shares_page(void)
int mode = 0;
unsigned int parm_filter = FLAG_BASIC;
size_t converted_size;
+ const char form_name[] = "shares";
+
+ printf("<H2>%s</H2>\n", _("Share Parameters"));
+
+ if (!verify_xsrf_token(form_name)) {
+ goto output_page;
+ }
if (share)
snum = lp_servicenumber(share);
- printf("<H2>%s</H2>\n", _("Share Parameters"));
if (cgi_variable("Commit") && snum >= 0) {
commit_parameters(snum);
@@ -1012,10 +1018,6 @@ static void shares_page(void)
}
}
- printf("<FORM name=\"swatform\" method=post>\n");
-
- printf("<table>\n");
-
if ( cgi_variable("ViewMode") )
mode = atoi(cgi_variable_nonull("ViewMode"));
if ( cgi_variable("BasicMode"))
@@ -1023,6 +1025,12 @@ static void shares_page(void)
if ( cgi_variable("AdvMode"))
mode = 1;
+output_page:
+ printf("<FORM name=\"swatform\" method=post>\n");
+ print_xsrf_token(cgi_user_name(), cgi_user_pass(), form_name);
+
+ printf("<table>\n");
+
ViewModeBoxes( mode );
switch ( mode ) {
case 0: