Ignore:
Timestamp:
May 13, 2014, 11:39:04 AM (11 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update trunk to 3.6.23

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/web/cgi.c

    r745 r862  
    4949static char *C_user;
    5050static char *C_pass;
     51static char *C_nonce;
    5152static bool inetd_server;
    5253static bool got_request;
     
    331332
    332333        if (!setuid(0)) {
    333                 C_pass = secrets_fetch_generic("root", "SWAT");
    334                 if (C_pass == NULL) {
    335                         char *tmp_pass = NULL;
    336                         tmp_pass = generate_random_password(talloc_tos(),
    337                                                             16, 16);
    338                         if (tmp_pass == NULL) {
    339                                 printf("%sFailed to create random nonce for "
    340                                        "SWAT session\n<br>%s\n", head, tail);
    341                                 exit(0);
    342                         }
    343                         secrets_store_generic("root", "SWAT", tmp_pass);
    344                         C_pass = SMB_STRDUP(tmp_pass);
    345                         TALLOC_FREE(tmp_pass);
    346                 }
     334                C_pass = SMB_STRDUP(cgi_nonce());
    347335        }
    348336        setuid(pwd->pw_uid);
     
    459447{
    460448        return(C_pass);
     449}
     450
     451/***************************************************************************
     452return a ptr to the nonce
     453  ***************************************************************************/
     454char *cgi_nonce(void)
     455{
     456        const char *head = "Content-Type: text/html\r\n\r\n<HTML><BODY><H1>SWAT installation Error</H1>\n";
     457        const char *tail = "</BODY></HTML>\r\n";
     458        C_nonce = secrets_fetch_generic("root", "SWAT");
     459        if (C_nonce == NULL) {
     460                char *tmp_pass = NULL;
     461                tmp_pass = generate_random_password(talloc_tos(),
     462                                                    16, 16);
     463                if (tmp_pass == NULL) {
     464                        printf("%sFailed to create random nonce for "
     465                               "SWAT session\n<br>%s\n", head, tail);
     466                        exit(0);
     467                }
     468                secrets_store_generic("root", "SWAT", tmp_pass);
     469                C_nonce = SMB_STRDUP(tmp_pass);
     470                TALLOC_FREE(tmp_pass);
     471        }
     472        return(C_nonce);
    461473}
    462474
Note: See TracChangeset for help on using the changeset viewer.