Changeset 740 for vendor/current/source3/web
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/source3/web
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/web/cgi.c
r615 r740 2 2 some simple CGI helper routines 3 3 Copyright (C) Andrew Tridgell 1997-1998 4 4 5 5 This program is free software; you can redistribute it and/or modify 6 6 it under the terms of the GNU General Public License as published by 7 7 the Free Software Foundation; either version 3 of the License, or 8 8 (at your option) any later version. 9 9 10 10 This program is distributed in the hope that it will be useful, 11 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 GNU General Public License for more details. 14 14 15 15 You should have received a copy of the GNU General Public License 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 19 19 20 20 #include "includes.h" 21 #include "system/passwd.h" 22 #include "system/filesys.h" 21 23 #include "web/swat_proto.h" 24 #include "intl/lang_tdb.h" 25 #include "auth.h" 22 26 #include "secrets.h" 23 #include "../lib/util/util.h"24 27 25 28 #define MAX_VARIABLES 10000 … … 57 60 while ((*cl)) { 58 61 int c; 59 62 60 63 if (i == len) { 61 64 char *ret2; … … 66 69 ret = ret2; 67 70 } 68 71 69 72 c = fgetc(f); 70 73 (*cl)--; … … 74 77 break; 75 78 } 76 79 77 80 if (c == '\r') continue; 78 81 … … 82 85 83 86 } 84 87 85 88 if (ret) { 86 89 ret[i] = 0; … … 136 139 p = strchr_m(line,'='); 137 140 if (!p) continue; 138 141 139 142 *p = 0; 140 143 141 144 variables[num_variables].name = SMB_STRDUP(line); 142 145 variables[num_variables].value = SMB_STRDUP(p+1); 143 146 144 147 SAFE_FREE(line); 145 148 146 149 if (!variables[num_variables].name || 147 150 !variables[num_variables].value) … … 158 161 variables[num_variables].value); 159 162 #endif 160 163 161 164 num_variables++; 162 165 if (num_variables == MAX_VARIABLES) break; … … 173 176 p = strchr_m(tok,'='); 174 177 if (!p) continue; 175 178 176 179 *p = 0; 177 180 178 181 variables[num_variables].name = SMB_STRDUP(tok); 179 182 variables[num_variables].value = SMB_STRDUP(p+1); … … 318 321 } 319 322 320 pwd = Get_Pwnam_alloc(talloc_ autofree_context(), user);323 pwd = Get_Pwnam_alloc(talloc_tos(), user); 321 324 if (!pwd) { 322 325 printf("%sCannot find user %s<br>%s\n", head, user, tail); … … 330 333 if (C_pass == NULL) { 331 334 char *tmp_pass = NULL; 332 tmp_pass = generate_random_str(talloc_tos(), 16); 335 tmp_pass = generate_random_password(talloc_tos(), 336 16, 16); 333 337 if (tmp_pass == NULL) { 334 338 printf("%sFailed to create random nonce for " … … 359 363 fstring user, user_pass; 360 364 struct passwd *pass = NULL; 365 const char *rhost; 366 char addr[INET6_ADDRSTRLEN]; 361 367 362 368 if (!strnequal(line,"Basic ", 6)) { … … 386 392 * Try and get the user from the UNIX password file. 387 393 */ 388 389 pass = Get_Pwnam_alloc(talloc_autofree_context(), user); 390 394 395 pass = Get_Pwnam_alloc(talloc_tos(), user); 396 397 rhost = client_name(1); 398 if (strequal(rhost,"UNKNOWN")) 399 rhost = client_addr(1, addr, sizeof(addr)); 400 391 401 /* 392 402 * Validate the password they have given. 393 403 */ 394 395 if NT_STATUS_IS_OK(pass_check(pass, user, user_pass, 396 strlen(user_pass), NULL, False)) { 397 404 405 if NT_STATUS_IS_OK(pass_check(pass, user, rhost, user_pass, false)) { 398 406 if (pass) { 399 407 /* 400 408 * Password was ok. 401 409 */ 402 410 403 411 if ( initgroups(pass->pw_name, pass->pw_gid) != 0 ) 404 412 goto err; 405 413 406 414 become_user_permanently(pass->pw_uid, pass->pw_gid); 407 415 408 416 /* Save the users name */ 409 417 C_user = SMB_STRDUP(user); … … 413 421 } 414 422 } 415 423 416 424 err: 417 425 cgi_setup_error("401 Bad Authorization", … … 536 544 537 545 546 /* return true if the char* contains ip addrs only. Used to avoid 547 name lookup calls */ 548 549 static bool only_ipaddrs_in_list(const char **list) 550 { 551 bool only_ip = true; 552 553 if (!list) { 554 return true; 555 } 556 557 for (; *list ; list++) { 558 /* factor out the special strings */ 559 if (strequal(*list, "ALL") || strequal(*list, "FAIL") || 560 strequal(*list, "EXCEPT")) { 561 continue; 562 } 563 564 if (!is_ipaddress(*list)) { 565 /* 566 * If we failed, make sure that it was not because 567 * the token was a network/netmask pair. Only 568 * network/netmask pairs have a '/' in them. 569 */ 570 if ((strchr_m(*list, '/')) == NULL) { 571 only_ip = false; 572 DEBUG(3,("only_ipaddrs_in_list: list has " 573 "non-ip address (%s)\n", 574 *list)); 575 break; 576 } 577 } 578 } 579 580 return only_ip; 581 } 582 583 /* return true if access should be allowed to a service for a socket */ 584 static bool check_access(int sock, const char **allow_list, 585 const char **deny_list) 586 { 587 bool ret = false; 588 bool only_ip = false; 589 char addr[INET6_ADDRSTRLEN]; 590 591 if ((!deny_list || *deny_list==0) && (!allow_list || *allow_list==0)) { 592 return true; 593 } 594 595 /* Bypass name resolution calls if the lists 596 * only contain IP addrs */ 597 if (only_ipaddrs_in_list(allow_list) && 598 only_ipaddrs_in_list(deny_list)) { 599 only_ip = true; 600 DEBUG (3, ("check_access: no hostnames " 601 "in host allow/deny list.\n")); 602 ret = allow_access(deny_list, 603 allow_list, 604 "", 605 get_peer_addr(sock,addr,sizeof(addr))); 606 } else { 607 DEBUG (3, ("check_access: hostnames in " 608 "host allow/deny list.\n")); 609 ret = allow_access(deny_list, 610 allow_list, 611 get_peer_name(sock,true), 612 get_peer_addr(sock,addr,sizeof(addr))); 613 } 614 615 if (ret) { 616 DEBUG(2,("Allowed connection from %s (%s)\n", 617 only_ip ? "" : get_peer_name(sock,true), 618 get_peer_addr(sock,addr,sizeof(addr)))); 619 } else { 620 DEBUG(0,("Denied connection from %s (%s)\n", 621 only_ip ? "" : get_peer_name(sock,true), 622 get_peer_addr(sock,addr,sizeof(addr)))); 623 } 624 625 return(ret); 626 } 538 627 539 628 /** -
vendor/current/source3/web/diagnose.c
r414 r740 3 3 diagnosis tools for web admin 4 4 Copyright (C) Andrew Tridgell 1998 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 3 of the License, or 9 9 (at your option) any later version. 10 10 11 11 This program is distributed in the hope that it will be useful, 12 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 GNU General Public License for more details. 15 15 16 16 You should have received a copy of the GNU General Public License 17 17 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 20 20 #include "includes.h" 21 21 #include "web/swat_proto.h" 22 #include "lib/winbind_util.h" 23 #include "libsmb/libsmb.h" 22 24 23 25 #ifdef WITH_WINBIND … … 36 38 { 37 39 struct in_addr loopback_ip; 38 int fd, count, flags;40 int count; 39 41 struct sockaddr_storage *ss_list; 40 42 struct sockaddr_storage ss; 43 NTSTATUS status; 41 44 42 45 loopback_ip.s_addr = htonl(INADDR_LOOPBACK); 43 46 in_addr_to_sockaddr_storage(&ss, loopback_ip); 44 47 45 if ((fd = open_socket_in(SOCK_DGRAM, 0, 3, 46 &ss, True)) != -1) { 47 if ((ss_list = name_query(fd, "__SAMBA__", 0, 48 True, True, &ss, 49 &count, &flags, NULL)) != NULL) { 50 SAFE_FREE(ss_list); 51 close(fd); 52 return True; 53 } 54 close (fd); 48 status = name_query("__SAMBA__", 0, 49 True, True, &ss, 50 talloc_tos(), &ss_list, &count, 51 NULL); 52 if (NT_STATUS_IS_OK(status)) { 53 TALLOC_FREE(ss_list); 54 return True; 55 55 } 56 56 -
vendor/current/source3/web/neg_lang.c
r414 r740 21 21 #include "includes.h" 22 22 #include "web/swat_proto.h" 23 #include "intl/lang_tdb.h" 23 24 24 25 /* … … 52 53 }; 53 54 54 static int qsort_cmp_list(const void *x, const void *y) { 55 struct pri_list *a = (struct pri_list *)x; 56 struct pri_list *b = (struct pri_list *)y; 55 static int qsort_cmp_list(struct pri_list *a, struct pri_list *b) 56 { 57 57 if (a->pri > b->pri) return -1; 58 58 if (a->pri < b->pri) return 1; … … 102 102 TALLOC_FREE(lang_list); 103 103 104 qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list);104 TYPESAFE_QSORT(pl, lang_num, qsort_cmp_list); 105 105 106 106 /* it's not an error to not initialise - we just fall back to -
vendor/current/source3/web/startstop.c
r414 r740 37 37 38 38 if (asprintf(&binfile, "%s/smbd", get_dyn_SBINDIR()) > 0) { 39 become_daemon(true, false );39 become_daemon(true, false, false); 40 40 execl(binfile, binfile, "-D", NULL); 41 41 } … … 57 57 58 58 if (asprintf(&binfile, "%s/nmbd", get_dyn_SBINDIR()) > 0) { 59 become_daemon(true, false );59 become_daemon(true, false, false); 60 60 execl(binfile, binfile, "-D", NULL); 61 61 } … … 77 77 78 78 if (asprintf(&binfile, "%s/winbindd", get_dyn_SBINDIR()) > 0) { 79 become_daemon(true, false );79 become_daemon(true, false, false); 80 80 execl(binfile, binfile, NULL); 81 81 } -
vendor/current/source3/web/statuspage.c
r615 r740 20 20 #include "includes.h" 21 21 #include "web/swat_proto.h" 22 #include "libcli/security/security.h" 23 #include "locking/proto.h" 22 24 23 25 #define _(x) lang_msg_rotate(talloc_tos(),x) … … 124 126 { 125 127 char *utf8_fname; 128 char *utf8_sharepath; 126 129 int deny_mode; 127 130 size_t converted_size; … … 173 176 174 177 push_utf8_talloc(talloc_tos(), &utf8_fname, fname, &converted_size); 175 printf("<td>%s</td><td>%s</td></tr>\n", 176 utf8_fname,tstring(talloc_tos(),e->time.tv_sec)); 178 push_utf8_talloc(talloc_tos(), &utf8_sharepath, sharepath, 179 &converted_size); 180 printf("<td>%s</td><td>%s</td><td>%s</td></tr>\n", 181 utf8_sharepath,utf8_fname,tstring(talloc_tos(),e->time.tv_sec)); 177 182 TALLOC_FREE(utf8_fname); 178 183 } … … 180 185 181 186 /* kill off any connections chosen by the user */ 182 static int traverse_fn1(struct db_record *rec, 183 const struct connections_key *key, 187 static int traverse_fn1(const struct connections_key *key, 184 188 const struct connections_data *crec, 185 189 void *private_data) … … 197 201 198 202 /* traversal fn for showing machine connections */ 199 static int traverse_fn2(struct db_record *rec, 200 const struct connections_key *key, 203 static int traverse_fn2(const struct connections_key *key, 201 204 const struct connections_data *crec, 202 205 void *private_data) … … 222 225 223 226 /* traversal fn for showing share connections */ 224 static int traverse_fn3(struct db_record *rec, 225 const struct connections_key *key, 227 static int traverse_fn3(const struct connections_key *key, 226 228 const struct connections_data *crec, 227 229 void *private_data) … … 328 330 } 329 331 330 connections_forall (traverse_fn1, NULL);332 connections_forall_read(traverse_fn1, NULL); 331 333 332 334 initPid2Machine (); … … 420 422 printf("</tr>\n"); 421 423 422 connections_forall (traverse_fn2, NULL);424 connections_forall_read(traverse_fn2, NULL); 423 425 424 426 printf("</table><p>\n"); … … 429 431 _("Share"), _("User"), _("Group"), _("PID"), _("Client"), _("Date")); 430 432 431 connections_forall (traverse_fn3, NULL);433 connections_forall_read(traverse_fn3, NULL); 432 434 433 435 printf("</table><p>\n"); … … 435 437 printf("<h3>%s</h3>\n", _("Open Files")); 436 438 printf("<table border=1>\n"); 437 printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th>< /tr>\n",438 _("PID"), _("UID"), _("Sharing"), _("R/W"), _("Oplock"), _(" File"), _("Date"));439 printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n", 440 _("PID"), _("UID"), _("Sharing"), _("R/W"), _("Oplock"), _("Share"), _("File"), _("Date")); 439 441 440 442 locking_init_readonly(); -
vendor/current/source3/web/swat.c
r615 r740 5 5 Copyright (C) Andrew Tridgell 1997-2002 6 6 Copyright (C) John H Terpstra 2002 7 7 8 8 This program is free software; you can redistribute it and/or modify 9 9 it under the terms of the GNU General Public License as published by 10 10 the Free Software Foundation; either version 3 of the License, or 11 11 (at your option) any later version. 12 12 13 13 This program is distributed in the hope that it will be useful, 14 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 16 GNU General Public License for more details. 17 17 18 18 You should have received a copy of the GNU General Public License 19 19 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 29 29 30 30 #include "includes.h" 31 #include "system/filesys.h" 32 #include "popt_common.h" 31 33 #include "web/swat_proto.h" 34 #include "printing/pcap.h" 35 #include "printing/load.h" 36 #include "passdb.h" 37 #include "intl/lang_tdb.h" 32 38 #include "../lib/crypto/md5.h" 33 39 … … 122 128 123 129 while (*str) { 124 if (*str != ' ') *p++ = toupper_ ascii(*str);130 if (*str != ' ') *p++ = toupper_m(*str); 125 131 ++str; 126 132 } … … 169 175 170 176 snprintf(tmp, sizeof(tmp), "%02x", token[i]); 171 str ncat(token_str, tmp, sizeof(tmp));177 strlcat(token_str, tmp, sizeof(tmp)); 172 178 } 173 179 } … … 193 199 const char *token = cgi_variable_nonull(XSRF_TOKEN); 194 200 const char *time_str = cgi_variable_nonull(XSRF_TIME); 201 char *p = NULL; 202 long long xsrf_time_ll = 0; 195 203 time_t xsrf_time = 0; 196 204 time_t now = time(NULL); 197 205 198 if (sizeof(time_t) == sizeof(int)) { 199 xsrf_time = atoi(time_str); 200 } else if (sizeof(time_t) == sizeof(long)) { 201 xsrf_time = atol(time_str); 202 } else if (sizeof(time_t) == sizeof(long long)) { 203 xsrf_time = atoll(time_str); 204 } 206 errno = 0; 207 xsrf_time_ll = strtoll(time_str, &p, 10); 208 if (errno != 0) { 209 return false; 210 } 211 if (p == NULL) { 212 return false; 213 } 214 if (PTR_DIFF(p, time_str) > strlen(time_str)) { 215 return false; 216 } 217 if (xsrf_time_ll > _TYPE_MAXIMUM(time_t)) { 218 return false; 219 } 220 if (xsrf_time_ll < _TYPE_MINIMUM(time_t)) { 221 return false; 222 } 223 xsrf_time = xsrf_time_ll; 205 224 206 225 if (abs(now - xsrf_time) > XSRF_TIMEOUT) { … … 492 511 493 512 if ((parm_filter & FLAG_WIZARD) && !(parm->flags & FLAG_WIZARD)) continue; 494 513 495 514 if ((parm_filter & FLAG_ADVANCED) && !(parm->flags & FLAG_ADVANCED)) continue; 496 515 497 516 if (heading && heading != last_heading) { 498 517 printf("<tr><td></td></tr><tr><td><b><u>%s</u></b></td></tr>\n", _(heading)); … … 521 540 fprintf(f, "# from %s (%s)\n", cgi_remote_host(), cgi_remote_addr()); 522 541 fprintf(f, "# Date: %s\n\n", current_timestring(ctx, False)); 523 542 524 543 lp_dump(f, show_defaults, iNumNonAutoPrintServices); 525 544 … … 565 584 } 566 585 iNumNonAutoPrintServices = lp_numservices(); 567 pcap_cache_reload(&load_printers); 586 if (pcap_cache_loaded()) { 587 load_printers(server_event_context(), 588 server_messaging_context()); 589 } 568 590 569 591 return 1; … … 631 653 { 632 654 char *p; 633 655 634 656 if ((p = cgi_user_name()) && strcmp(p, "root")) { 635 657 printf(_("Logged in as <b>%s</b>"), p); … … 745 767 printf("<input type=reset name=\"Reset Values\" value=\"Reset\">\n"); 746 768 printf("<p>\n"); 747 769 748 770 printf("<table>\n"); 749 771 show_parameters(GLOBAL_SECTION_SNUM, 1, parm_filter, 0); … … 797 819 /* Plain text passwords are too badly broken - use encrypted passwords only */ 798 820 lp_do_parameter( GLOBAL_SECTION_SNUM, "encrypt passwords", "Yes"); 799 821 800 822 switch ( SerType ){ 801 823 case 0: … … 909 931 for(i = 0; wins_servers[i]; i++) printf("%s ", wins_servers[i]); 910 932 } 911 933 912 934 printf("\"></td></tr>\n"); 913 935 if (winstype == 3) { … … 919 941 printf("<td><input type=radio name=\"HomeExpo\" value=\"0\" %s> No</td>", (have_home == -1 ) ? "checked" : ""); 920 942 printf("<td></td></tr>\n"); 921 943 922 944 /* Enable this when we are ready .... 923 945 * printf("<tr><td><b>%s: </b></td>\n", _("Is Print Server")); … … 926 948 * printf("<td></td></tr>\n"); 927 949 */ 928 950 929 951 printf("</table></center>"); 930 952 printf("<hr>"); … … 1125 1147 return False; 1126 1148 } 1127 1149 1128 1150 if (remote_machine != NULL) { 1129 1151 ret = remote_password_change(remote_machine, user_name, … … 1139 1161 return False; 1140 1162 } 1141 1163 1142 1164 ret = local_password_change(user_name, local_flags, new_passwd, 1143 1165 &err_str, &msg_str); … … 1222 1244 local_flags |= (cgi_variable(ENABLE_USER_FLAG) ? LOCAL_ENABLE_USER : 0); 1223 1245 local_flags |= (cgi_variable(DISABLE_USER_FLAG) ? LOCAL_DISABLE_USER : 0); 1224 1225 1246 1226 1247 rslt = change_password(host, … … 1237 1258 } 1238 1259 } 1239 1260 1240 1261 return; 1241 1262 } … … 1527 1548 BlockSignals(True,SIGPIPE); 1528 1549 1529 dbf = x_fopen("/dev/null", O_WRONLY, 0); 1530 if (!dbf) dbf = x_stderr; 1550 debug_set_logfile("/dev/null"); 1531 1551 1532 1552 /* we don't want stderr screwing us up */ 1533 1553 close(2); 1534 1554 open("/dev/null", O_WRONLY); 1535 1555 setup_logging("swat", DEBUG_FILE); 1556 1557 load_case_tables(); 1558 1536 1559 pc = poptGetContext("swat", argc, (const char **) argv, long_options, 0); 1537 1560 … … 1542 1565 poptFreeContext(pc); 1543 1566 1544 load_case_tables(); 1545 1546 setup_logging(argv[0],False); 1567 /* This should set a more apporiate log file */ 1547 1568 load_config(True); 1569 reopen_logs(); 1548 1570 load_interfaces(); 1549 1571 iNumNonAutoPrintServices = lp_numservices(); 1550 pcap_cache_reload(&load_printers); 1572 if (pcap_cache_loaded()) { 1573 load_printers(server_event_context(), 1574 server_messaging_context()); 1575 } 1551 1576 1552 1577 cgi_setup(get_dyn_SWATDIR(), !demo_mode);
Note:
See TracChangeset
for help on using the changeset viewer.