s3 swat: Add XSRF protection to wizard page
authorKai Blin <kai@samba.org>
Fri, 8 Jul 2011 13:03:44 +0000 (15:03 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 26 Jul 2011 20:22:25 +0000 (22:22 +0200)
Signed-off-by: Kai Blin <kai@samba.org>
source3/web/swat.c

index cdbbcb479b438c2840879ae4657e3f48fd7a403e..ac182dd70767f90ee05437ec96beaeb66eb3c40a 100644 (file)
@@ -765,6 +765,11 @@ static void wizard_page(void)
        int have_home = -1;
        int HomeExpo = 0;
        int SerType = 0;
+       const char form_name[] = "wizard";
+
+       if (!verify_xsrf_token(form_name)) {
+               goto output_page;
+       }
 
        if (cgi_variable("Rewrite")) {
                (void) rewritecfg_file();
@@ -856,9 +861,11 @@ static void wizard_page(void)
 
        role = lp_server_role();
 
+output_page:
        /* Here we go ... */
        printf("<H2>%s</H2>\n", _("Samba Configuration Wizard"));
        printf("<form method=post action=wizard>\n");
+       print_xsrf_token(cgi_user_name(), cgi_user_pass(), form_name);
 
        if (have_write_access) {
                printf("%s\n", _("The \"Rewrite smb.conf file\" button will clear the smb.conf file of all default values and of comments."));