Changeset 774 for branches/samba-3.5.x/source3/web/cgi.c
- Timestamp:
- Jul 2, 2013, 8:03:46 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.5.x/source3/web/cgi.c
r617 r774 46 46 static char *C_user; 47 47 static char *C_pass; 48 static char *C_nonce; 48 49 static bool inetd_server; 49 50 static bool got_request; … … 329 330 330 331 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()); 344 333 } 345 334 setuid(pwd->pw_uid); … … 453 442 return(C_pass); 454 443 } 444 445 /*************************************************************************** 446 return a ptr to the nonce 447 ***************************************************************************/ 448 char *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 455 468 456 469 /***************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.