Ignore:
Timestamp:
Jul 2, 2013, 8:03:46 PM (12 years ago)
Author:
Herwig Bauernfeind
Message:

Samba Server 3.5: Update branch to 3.5.21

Location:
branches/samba-3.5.x/source3/web
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/source3/web/cgi.c

    r617 r774  
    4646static char *C_user;
    4747static char *C_pass;
     48static char *C_nonce;
    4849static bool inetd_server;
    4950static bool got_request;
     
    329330
    330331        if (!setuid(0)) {
    331                 C_pass = secrets_fetch_generic("root", "SWAT");
    332                 if (C_pass == NULL) {
    333                         char *tmp_pass = NULL;
    334                         tmp_pass = generate_random_str(talloc_tos(), 16);
    335                         if (tmp_pass == NULL) {
    336                                 printf("%sFailed to create random nonce for "
    337                                        "SWAT session\n<br>%s\n", head, tail);
    338                                 exit(0);
    339                         }
    340                         secrets_store_generic("root", "SWAT", tmp_pass);
    341                         C_pass = SMB_STRDUP(tmp_pass);
    342                         TALLOC_FREE(tmp_pass);
    343                 }
     332                C_pass = SMB_STRDUP(cgi_nonce());
    344333        }
    345334        setuid(pwd->pw_uid);
     
    453442        return(C_pass);
    454443}
     444
     445/***************************************************************************
     446return a ptr to the nonce
     447  ***************************************************************************/
     448char *cgi_nonce(void)
     449{
     450        const char *head = "Content-Type: text/html\r\n\r\n<HTML><BODY><H1>SWAT installation Error</H1>\n";
     451        const char *tail = "</BODY></HTML>\r\n";
     452        C_nonce = secrets_fetch_generic("root", "SWAT");
     453        if (C_nonce == NULL) {
     454                char *tmp_pass = NULL;
     455                tmp_pass = generate_random_str(talloc_tos(), 16);
     456                if (tmp_pass == NULL) {
     457                        printf("%sFailed to create random nonce for "
     458                               "SWAT session\n<br>%s\n", head, tail);
     459                        exit(0);
     460                }
     461                secrets_store_generic("root", "SWAT", tmp_pass);
     462                C_nonce = SMB_STRDUP(tmp_pass);
     463                TALLOC_FREE(tmp_pass);
     464        }
     465        return(C_nonce);
     466}
     467
    455468
    456469/***************************************************************************
  • branches/samba-3.5.x/source3/web/swat.c

    r732 r774  
    149149        uint8_t token[16];
    150150        int i;
     151        char *nonce = cgi_nonce();
    151152
    152153        token_str[0] = '\0';
     
    162163                MD5Update(&md5_ctx, (uint8_t *)pass, strlen(pass));
    163164        }
     165        MD5Update(&md5_ctx, (uint8_t *)nonce, strlen(nonce));
    164166
    165167        MD5Final(token, &md5_ctx);
     
    261263                printf("Expires: 0\r\n");
    262264        }
    263         printf("Content-type: text/html\r\n\r\n");
     265        printf("Content-type: text/html\r\n");
     266        printf("X-Frame-Options: DENY\r\n\r\n");
    264267
    265268        if (!include_html("include/header.html")) {
  • branches/samba-3.5.x/source3/web/swat_proto.h

    r617 r774  
    3333char *cgi_user_name(void);
    3434char *cgi_user_pass(void);
     35char *cgi_nonce(void);
    3536void cgi_setup(const char *rootdir, int auth_required);
    3637const char *cgi_baseurl(void);
Note: See TracChangeset for help on using the changeset viewer.