Changeset 774 for branches/samba-3.5.x/source3/web
- Timestamp:
- Jul 2, 2013, 8:03:46 PM (12 years ago)
- 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 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 /*************************************************************************** -
branches/samba-3.5.x/source3/web/swat.c
r732 r774 149 149 uint8_t token[16]; 150 150 int i; 151 char *nonce = cgi_nonce(); 151 152 152 153 token_str[0] = '\0'; … … 162 163 MD5Update(&md5_ctx, (uint8_t *)pass, strlen(pass)); 163 164 } 165 MD5Update(&md5_ctx, (uint8_t *)nonce, strlen(nonce)); 164 166 165 167 MD5Final(token, &md5_ctx); … … 261 263 printf("Expires: 0\r\n"); 262 264 } 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"); 264 267 265 268 if (!include_html("include/header.html")) { -
branches/samba-3.5.x/source3/web/swat_proto.h
r617 r774 33 33 char *cgi_user_name(void); 34 34 char *cgi_user_pass(void); 35 char *cgi_nonce(void); 35 36 void cgi_setup(const char *rootdir, int auth_required); 36 37 const char *cgi_baseurl(void);
Note:
See TracChangeset
for help on using the changeset viewer.