Changeset 740 for vendor/current/source3/smbd/server.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/server.c
r618 r740 23 23 24 24 #include "includes.h" 25 #include "system/filesys.h" 26 #include "popt_common.h" 27 #include "smbd/smbd.h" 25 28 #include "smbd/globals.h" 26 27 static_decl_rpc; 29 #include "registry/reg_init_full.h" 30 #include "libcli/auth/schannel.h" 31 #include "secrets.h" 32 #include "memcache.h" 33 #include "ctdbd_conn.h" 34 #include "printing/printer_list.h" 35 #include "rpc_server/rpc_ep_setup.h" 36 #include "printing/pcap.h" 37 #include "printing.h" 38 #include "serverid.h" 39 #include "passdb.h" 40 #include "auth.h" 41 #include "messages.h" 42 #include "smbprofile.h" 43 44 extern void start_epmd(struct tevent_context *ev_ctx, 45 struct messaging_context *msg_ctx); 46 47 extern void start_spoolssd(struct event_context *ev_ctx, 48 struct messaging_context *msg_ctx); 28 49 29 50 #ifdef WITH_DFS … … 31 52 #endif /* WITH_DFS */ 32 53 33 int smbd_server_fd(void)34 {35 return server_fd;36 }37 38 54 static void smbd_set_server_fd(int fd) 39 55 { 40 server_fd = fd; 41 } 42 43 int get_client_fd(void) 44 { 45 return server_fd; 56 struct smbd_server_connection *sconn = smbd_server_conn; 57 char addr[INET6_ADDRSTRLEN]; 58 const char *name; 59 60 sconn->sock = fd; 61 62 /* 63 * Initialize sconn->client_id: If we can't find the client's 64 * name, default to its address. 65 */ 66 67 client_addr(fd, sconn->client_id.addr, sizeof(sconn->client_id.addr)); 68 69 name = client_name(sconn->sock); 70 if (strcmp(name, "UNKNOWN") != 0) { 71 name = talloc_strdup(sconn, name); 72 } else { 73 name = NULL; 74 } 75 sconn->client_id.name = 76 (name != NULL) ? name : sconn->client_id.addr; 77 78 sub_set_socket_ids(sconn->client_id.addr, sconn->client_id.name, 79 client_socket_addr(sconn->sock, addr, 80 sizeof(addr))); 46 81 } 47 82 48 83 struct event_context *smbd_event_context(void) 49 84 { 50 if (!smbd_event_ctx) { 51 smbd_event_ctx = event_context_init(talloc_autofree_context()); 52 } 53 if (!smbd_event_ctx) { 54 smb_panic("Could not init smbd event context"); 55 } 56 return smbd_event_ctx; 57 } 58 59 struct messaging_context *smbd_messaging_context(void) 60 { 61 if (smbd_msg_ctx == NULL) { 62 smbd_msg_ctx = messaging_init(talloc_autofree_context(), 63 server_id_self(), 64 smbd_event_context()); 65 } 66 if (smbd_msg_ctx == NULL) { 67 DEBUG(0, ("Could not init smbd messaging context.\n")); 68 } 69 return smbd_msg_ctx; 70 } 71 72 struct memcache *smbd_memcache(void) 73 { 74 if (!smbd_memcache_ctx) { 75 smbd_memcache_ctx = memcache_init(talloc_autofree_context(), 76 lp_max_stat_cache_size()*1024); 77 } 78 if (!smbd_memcache_ctx) { 79 smb_panic("Could not init smbd memcache"); 80 } 81 82 return smbd_memcache_ctx; 85 return server_event_context(); 83 86 } 84 87 … … 93 96 DATA_BLOB *data) 94 97 { 98 struct tevent_context *ev_ctx = 99 talloc_get_type_abort(private_data, struct tevent_context); 100 95 101 DEBUG(10,("smb_conf_updated: Got message saying smb.conf was " 96 102 "updated. Reloading.\n")); 97 103 change_to_root_user(); 98 reload_services(False); 99 } 100 104 reload_services(msg, smbd_server_conn->sock, False); 105 if (am_parent) { 106 pcap_cache_reload(ev_ctx, msg, 107 &reload_pcap_change_notify); 108 } 109 } 110 111 /******************************************************************* 112 What to do when printcap is updated. 113 ********************************************************************/ 114 115 static void smb_pcap_updated(struct messaging_context *msg, 116 void *private_data, 117 uint32_t msg_type, 118 struct server_id server_id, 119 DATA_BLOB *data) 120 { 121 struct tevent_context *ev_ctx = 122 talloc_get_type_abort(private_data, struct tevent_context); 123 124 DEBUG(10,("Got message saying pcap was updated. Reloading.\n")); 125 change_to_root_user(); 126 reload_printers(ev_ctx, msg); 127 } 101 128 102 129 /******************************************************************* … … 158 185 159 186 if (data->length != sizeof(sig)) { 160 161 187 DEBUG(0, ("Process %s sent bogus signal injection request\n", 162 188 procid_str_static(&src))); … … 240 266 DEBUG(1,("Cleaning up brl and lock database after unclean shutdown\n")); 241 267 message_send_all(smbd_messaging_context(), MSG_SMB_UNLOCK, NULL, 0, NULL); 242 messaging_send_buf(smbd_messaging_context(), procid_self(), 268 messaging_send_buf(smbd_messaging_context(), procid_self(), 243 269 MSG_SMB_BRL_VALIDATE, NULL, 0); 244 270 /* mark the cleanup as having been done */ … … 250 276 struct child_pid *child; 251 277 static struct timed_event *cleanup_te; 278 struct server_id child_id; 252 279 253 280 if (unclean_shutdown) { … … 256 283 pending locks 257 284 */ 258 DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", 285 DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", 259 286 (unsigned int)pid)); 260 287 if (!cleanup_te) { … … 263 290 cleanup_te = event_add_timed(smbd_event_context(), NULL, 264 291 timeval_current_ofs(cleanup_time, 0), 265 cleanup_timeout_fn, 292 cleanup_timeout_fn, 266 293 &cleanup_te); 267 294 DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n")); 268 295 } 296 } 297 298 child_id = procid_self(); /* Just initialize pid and potentially vnn */ 299 child_id.pid = pid; 300 301 if (!serverid_deregister(child_id)) { 302 DEBUG(1, ("Could not remove pid %d from serverid.tdb\n", 303 (int)pid)); 269 304 } 270 305 … … 375 410 struct sockaddr_storage addr; 376 411 socklen_t in_addrlen = sizeof(addr); 412 int fd; 377 413 pid_t pid = 0; 378 379 smbd_set_server_fd(accept(s->fd,(struct sockaddr *)&addr,&in_addrlen)); 380 381 if (smbd_server_fd() == -1 && errno == EINTR) 414 uint64_t unique_id; 415 416 fd = accept(s->fd, (struct sockaddr *)(void *)&addr,&in_addrlen); 417 smbd_set_server_fd(fd); 418 419 if (fd == -1 && errno == EINTR) 382 420 return; 383 421 384 if ( smbd_server_fd()== -1) {422 if (fd == -1) { 385 423 DEBUG(0,("open_sockets_smbd: accept: %s\n", 386 424 strerror(errno))); … … 389 427 390 428 if (s->parent->interactive) { 391 smbd_process( );429 smbd_process(smbd_server_conn); 392 430 exit_server_cleanly("end of interactive mode"); 393 431 return; … … 395 433 396 434 if (!allowable_number_of_smbd_processes()) { 397 close( smbd_server_fd());435 close(fd); 398 436 smbd_set_server_fd(-1); 399 437 return; 400 438 } 439 440 /* 441 * Generate a unique id in the parent process so that we use 442 * the global random state in the parent. 443 */ 444 generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id)); 401 445 402 446 pid = sys_fork(); 403 447 if (pid == 0) { 404 448 NTSTATUS status = NT_STATUS_OK; 449 405 450 /* Child code ... */ 406 451 am_parent = 0; 452 453 set_my_unique_id(unique_id); 407 454 408 455 /* Stop zombies, the parent explicitly handles … … 422 469 423 470 status = reinit_after_fork(smbd_messaging_context(), 424 smbd_event_context(), true); 471 smbd_event_context(), procid_self(), 472 true); 425 473 if (!NT_STATUS_IS_OK(status)) { 426 474 if (NT_STATUS_EQUAL(status, … … 430 478 goto exit; 431 479 } 480 if (lp_clustering() && 481 NT_STATUS_EQUAL(status, 482 NT_STATUS_INTERNAL_DB_ERROR)) { 483 DEBUG(1,("child process cannot initialize " 484 "because connection to CTDB " 485 "has failed\n")); 486 goto exit; 487 } 488 432 489 DEBUG(0,("reinit_after_fork() failed\n")); 433 490 smb_panic("reinit_after_fork() failed"); … … 435 492 436 493 smbd_setup_sig_term_handler(); 437 smbd_setup_sig_hup_handler(); 438 439 smbd_process(); 494 smbd_setup_sig_hup_handler(server_event_context(), 495 server_messaging_context()); 496 497 if (!serverid_register(procid_self(), 498 FLAG_MSG_GENERAL|FLAG_MSG_SMBD 499 |FLAG_MSG_DBWRAP 500 |FLAG_MSG_PRINT_GENERAL)) { 501 exit_server_cleanly("Could not register myself in " 502 "serverid.tdb"); 503 } 504 505 smbd_process(smbd_server_conn); 440 506 exit: 441 507 exit_server_cleanly("end of child"); 442 508 return; 443 } else if (pid < 0) { 509 } 510 511 if (pid < 0) { 444 512 DEBUG(0,("smbd_accept_connection: sys_fork() failed: %s\n", 445 513 strerror(errno))); … … 447 515 448 516 /* The parent doesn't need this socket */ 449 close( smbd_server_fd());517 close(fd); 450 518 451 519 /* Sun May 6 18:56:14 2001 ackley@cs.unm.edu: … … 543 611 } 544 612 545 static bool parent_housekeeping_fn(const struct timeval *now, void *private_data) 546 { 547 DEBUG(5, ("houskeeping\n")); 548 /* check if we need to reload services */ 549 check_reload(time(NULL)); 613 static bool smbd_parent_housekeeping(const struct timeval *now, void *private_data) 614 { 615 time_t printcap_cache_time = (time_t)lp_printcap_cache_time(); 616 time_t t = time_mono(NULL); 617 618 DEBUG(5, ("parent housekeeping\n")); 619 620 /* if periodic printcap rescan is enabled, see if it's time to reload */ 621 if ((printcap_cache_time != 0) 622 && (t >= (last_printer_reload_time + printcap_cache_time))) { 623 DEBUG( 3,( "Printcap cache time expired.\n")); 624 pcap_cache_reload(server_event_context(), 625 smbd_messaging_context(), 626 &reload_pcap_change_notify); 627 last_printer_reload_time = t; 628 } 629 550 630 return true; 551 631 } … … 556 636 557 637 static bool open_sockets_smbd(struct smbd_parent_context *parent, 638 struct messaging_context *msg_ctx, 558 639 const char *smb_ports) 559 640 { … … 682 763 operations until it has gone thru a full startup, which 683 764 includes checking to see that smbd is listening. */ 684 claim_connection(NULL,"", 685 FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_DBWRAP); 765 766 if (!serverid_register(procid_self(), 767 FLAG_MSG_GENERAL|FLAG_MSG_SMBD 768 |FLAG_MSG_DBWRAP)) { 769 DEBUG(0, ("open_sockets_smbd: Failed to register " 770 "myself in serverid.tdb\n")); 771 return false; 772 } 686 773 687 774 if (!(event_add_idle(smbd_event_context(), NULL, 688 775 timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0), 689 "parent_housekeeping", parent_housekeeping_fn,690 parent))) {691 DEBUG(0, ("Could not add housekeeping event\n"));692 exit(1);776 "parent_housekeeping", smbd_parent_housekeeping, 777 NULL))) { 778 DEBUG(0, ("Could not add parent_housekeeping event\n")); 779 return false; 693 780 } 694 781 695 782 /* Listen to messages */ 696 783 697 messaging_register(smbd_messaging_context(), NULL, 698 MSG_SMB_SAM_SYNC, msg_sam_sync); 699 messaging_register(smbd_messaging_context(), NULL, 700 MSG_SHUTDOWN, msg_exit_server); 701 messaging_register(smbd_messaging_context(), NULL, 702 MSG_SMB_FILE_RENAME, msg_file_was_renamed); 703 messaging_register(smbd_messaging_context(), NULL, 704 MSG_SMB_CONF_UPDATED, smb_conf_updated); 705 messaging_register(smbd_messaging_context(), NULL, 706 MSG_SMB_STAT_CACHE_DELETE, smb_stat_cache_delete); 707 messaging_register(smbd_messaging_context(), NULL, 708 MSG_DEBUG, smbd_msg_debug); 709 brl_register_msgs(smbd_messaging_context()); 784 messaging_register(msg_ctx, NULL, MSG_SMB_SAM_SYNC, msg_sam_sync); 785 messaging_register(msg_ctx, NULL, MSG_SHUTDOWN, msg_exit_server); 786 messaging_register(msg_ctx, NULL, MSG_SMB_FILE_RENAME, 787 msg_file_was_renamed); 788 messaging_register(msg_ctx, server_event_context(), MSG_SMB_CONF_UPDATED, 789 smb_conf_updated); 790 messaging_register(msg_ctx, NULL, MSG_SMB_STAT_CACHE_DELETE, 791 smb_stat_cache_delete); 792 messaging_register(msg_ctx, NULL, MSG_DEBUG, smbd_msg_debug); 793 messaging_register(msg_ctx, server_event_context(), MSG_PRINTER_PCAP, 794 smb_pcap_updated); 795 brl_register_msgs(msg_ctx); 796 797 msg_idmap_register_msgs(msg_ctx); 710 798 711 799 #ifdef CLUSTER_SUPPORT … … 716 804 717 805 #ifdef DEVELOPER 718 messaging_register( smbd_messaging_context(), NULL,719 MSG_SMB_INJECT_FAULT,msg_inject_fault);806 messaging_register(msg_ctx, NULL, MSG_SMB_INJECT_FAULT, 807 msg_inject_fault); 720 808 #endif 721 809 722 if ( dns_port != 0) {810 if (lp_multicast_dns_register() && (dns_port != 0)) { 723 811 #ifdef WITH_DNSSD_SUPPORT 724 812 smbd_setup_mdns_registration(smbd_event_context(), … … 759 847 } 760 848 761 /***************************************************************************762 purge stale printers and reload from pre-populated pcap cache763 ***************************************************************************/764 void reload_printers(void)765 {766 int snum;767 int n_services = lp_numservices();768 int pnum = lp_servicenumber(PRINTERS_NAME);769 const char *pname;770 771 DEBUG(10, ("reloading printer services from pcap cache\n"));772 for (snum = 0; snum < n_services; snum++) {773 /* avoid removing PRINTERS_NAME or non-autoloaded printers */774 if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&775 lp_autoloaded(snum)))776 continue;777 778 pname = lp_printername(snum);779 if (!pcap_printername_ok(pname)) {780 DEBUG(3, ("removing stale printer %s\n", pname));781 782 if (is_printer_published(NULL, snum, NULL))783 nt_printer_publish(NULL, snum, DSPRINT_UNPUBLISH);784 del_a_printer(pname);785 lp_killservice(snum);786 }787 }788 789 load_printers();790 }791 792 /****************************************************************************793 Reload the services file.794 **************************************************************************/795 796 bool reload_services(bool test)797 {798 bool ret;799 800 if (lp_loaded()) {801 char *fname = lp_configfile();802 if (file_exist(fname) &&803 !strcsequal(fname, get_dyn_CONFIGFILE())) {804 set_dyn_CONFIGFILE(fname);805 test = False;806 }807 }808 809 reopen_logs();810 811 if (test && !lp_file_list_changed())812 return(True);813 814 lp_killunused(conn_snum_used);815 816 ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);817 818 pcap_cache_reload(&reload_printers);819 820 /* perhaps the config filename is now set */821 if (!test)822 reload_services(True);823 824 reopen_logs();825 826 load_interfaces();827 828 if (smbd_server_fd() != -1) {829 set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");830 set_socket_options(smbd_server_fd(), lp_socket_options());831 }832 833 mangle_reset_cache();834 reset_stat_cache();835 836 /* this forces service parameters to be flushed */837 set_current_service(NULL,0,True);838 839 return(ret);840 }841 842 /****************************************************************************843 Exit the server.844 ****************************************************************************/845 846 /* Reasons for shutting down a server process. */847 enum server_exit_reason { SERVER_EXIT_NORMAL, SERVER_EXIT_ABNORMAL };848 849 static void exit_server_common(enum server_exit_reason how,850 const char *const reason) _NORETURN_;851 852 static void exit_server_common(enum server_exit_reason how,853 const char *const reason)854 {855 bool had_open_conn = false;856 struct smbd_server_connection *sconn = smbd_server_conn;857 858 if (!exit_firsttime)859 exit(0);860 exit_firsttime = false;861 862 change_to_root_user();863 864 if (sconn && sconn->smb1.negprot.auth_context) {865 struct auth_context *a = sconn->smb1.negprot.auth_context;866 a->free(&sconn->smb1.negprot.auth_context);867 }868 869 if (sconn) {870 had_open_conn = conn_close_all(sconn);871 invalidate_all_vuids(sconn);872 }873 874 /* 3 second timeout. */875 print_notify_send_messages(smbd_messaging_context(), 3);876 877 /* delete our entry in the connections database. */878 yield_connection(NULL,"");879 880 #ifdef WITH_DFS881 if (dcelogin_atmost_once) {882 dfs_unlogin();883 }884 #endif885 886 #ifdef USE_DMAPI887 /* Destroy Samba DMAPI session only if we are master smbd process */888 if (am_parent) {889 if (!dmapi_destroy_session()) {890 DEBUG(0,("Unable to close Samba DMAPI session\n"));891 }892 }893 #endif894 895 locking_end();896 printing_end();897 898 /*899 * we need to force the order of freeing the following,900 * because smbd_msg_ctx is not a talloc child of smbd_server_conn.901 */902 sconn = NULL;903 TALLOC_FREE(smbd_server_conn);904 TALLOC_FREE(smbd_msg_ctx);905 TALLOC_FREE(smbd_event_ctx);906 907 if (how != SERVER_EXIT_NORMAL) {908 int oldlevel = DEBUGLEVEL;909 910 DEBUGLEVEL = 10;911 912 DEBUGSEP(0);913 DEBUG(0,("Abnormal server exit: %s\n",914 reason ? reason : "no explanation provided"));915 DEBUGSEP(0);916 917 log_stack_trace();918 919 DEBUGLEVEL = oldlevel;920 dump_core();921 922 } else {923 DEBUG(3,("Server exit (%s)\n",924 (reason ? reason : "normal exit")));925 if (am_parent) {926 pidfile_unlink();927 }928 gencache_stabilize();929 }930 931 /* if we had any open SMB connections when we exited then we932 need to tell the parent smbd so that it can trigger a retry933 of any locks we may have been holding or open files we were934 blocking */935 if (had_open_conn) {936 exit(1);937 } else {938 exit(0);939 }940 }941 942 void exit_server(const char *const explanation)943 {944 exit_server_common(SERVER_EXIT_ABNORMAL, explanation);945 }946 947 void exit_server_cleanly(const char *const explanation)948 {949 exit_server_common(SERVER_EXIT_NORMAL, explanation);950 }951 952 void exit_server_fault(void)953 {954 exit_server("critical server fault");955 }956 849 957 850 /**************************************************************************** … … 968 861 if (!init_names()) 969 862 return False; 970 971 file_init();972 863 973 864 if (!secrets_init()) … … 1022 913 }; 1023 914 struct smbd_parent_context *parent = NULL; 1024 TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ 915 TALLOC_CTX *frame; 916 NTSTATUS status; 917 uint64_t unique_id; 918 919 /* 920 * Do this before any other talloc operation 921 */ 922 talloc_enable_null_tracking(); 923 frame = talloc_stackframe(); 924 925 load_case_tables(); 926 927 /* Initialize the event context, it will panic on error */ 928 smbd_event_context(); 1025 929 1026 930 smbd_init_globals(); … … 1067 971 } 1068 972 1069 setup_logging(argv[0],log_stdout); 973 if (log_stdout) { 974 setup_logging(argv[0], DEBUG_STDOUT); 975 } else { 976 setup_logging(argv[0], DEBUG_FILE); 977 } 1070 978 1071 979 if (print_build_options) { … … 1073 981 exit(0); 1074 982 } 1075 1076 load_case_tables();1077 983 1078 984 #ifdef HAVE_SETLUID … … 1081 987 #endif 1082 988 1083 sec_init();1084 1085 989 set_remote_machine_name("smbd", False); 1086 990 … … 1098 1002 generate_random_buffer(NULL, 0); 1099 1003 1004 /* get initial effective uid and gid */ 1005 sec_init(); 1006 1100 1007 /* make absolutely sure we run as root - to handle cases where people 1101 1008 are crazy enough to have it setuid */ 1102 1103 1009 gain_root_privilege(); 1104 1010 gain_root_group_privilege(); … … 1135 1041 umask(0); 1136 1042 1137 init_sec_ctx();1138 1139 1043 reopen_logs(); 1140 1044 … … 1158 1062 } 1159 1063 1064 /* Init the security context and global current_user */ 1065 init_sec_ctx(); 1066 1160 1067 if (smbd_messaging_context() == NULL) 1161 1068 exit(1); 1162 1069 1163 if (!reload_services(False)) 1164 return(-1); 1070 /* 1071 * Reloading of the printers will not work here as we don't have a 1072 * server info and rpc services set up. It will be called later. 1073 */ 1074 if (!reload_services(smbd_messaging_context(), -1, False)) { 1075 exit(1); 1076 } 1077 1078 /* ...NOTE... Log files are working from this point! */ 1079 1080 DEBUG(3,("loaded services\n")); 1165 1081 1166 1082 init_structs(); … … 1181 1097 #endif 1182 1098 1183 DEBUG(3,( "loaded services\n"));1184 1185 1099 if (!is_daemon && !is_a_socket(0)) { 1186 1100 if (!interactive) … … 1197 1111 if (is_daemon && !interactive) { 1198 1112 DEBUG( 3, ( "Becoming a daemon.\n" ) ); 1199 become_daemon(Fork, no_process_group); 1200 } 1113 become_daemon(Fork, no_process_group, log_stdout); 1114 } 1115 1116 generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id)); 1117 set_my_unique_id(unique_id); 1201 1118 1202 1119 #if HAVE_SETPGID … … 1215 1132 pidfile_create("smbd"); 1216 1133 1217 if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(), 1218 smbd_event_context(), false))) { 1134 status = reinit_after_fork(smbd_messaging_context(), 1135 smbd_event_context(), 1136 procid_self(), false); 1137 if (!NT_STATUS_IS_OK(status)) { 1219 1138 DEBUG(0,("reinit_after_fork() failed\n")); 1220 1139 exit(1); 1221 1140 } 1222 1141 1142 smbd_server_conn->msg_ctx = smbd_messaging_context(); 1143 1223 1144 smbd_setup_sig_term_handler(); 1224 smbd_setup_sig_hup_handler(); 1145 smbd_setup_sig_hup_handler(smbd_event_context(), 1146 smbd_server_conn->msg_ctx); 1225 1147 1226 1148 /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */ … … 1243 1165 } 1244 1166 1167 if (lp_server_role() == ROLE_DOMAIN_BDC || lp_server_role() == ROLE_DOMAIN_PDC) { 1168 if (!open_schannel_session_store(NULL, lp_private_dir())) { 1169 DEBUG(0,("ERROR: Samba cannot open schannel store for secured NETLOGON operations.\n")); 1170 exit(1); 1171 } 1172 } 1173 1245 1174 if(!get_global_sam_sid()) { 1246 1175 DEBUG(0,("ERROR: Samba cannot create a SAM SID.\n")); … … 1248 1177 } 1249 1178 1250 if (!session_init()) 1251 exit(1); 1179 if (!sessionid_init()) { 1180 exit(1); 1181 } 1252 1182 1253 1183 if (!connections_init(True)) … … 1257 1187 exit(1); 1258 1188 1259 namecache_enable(); 1189 if (!messaging_tdb_parent_init(smbd_event_context())) { 1190 exit(1); 1191 } 1192 1193 if (!notify_internal_parent_init(smbd_event_context())) { 1194 exit(1); 1195 } 1196 1197 if (!serverid_parent_init(smbd_event_context())) { 1198 exit(1); 1199 } 1200 1201 if (!printer_list_parent_init()) { 1202 exit(1); 1203 } 1260 1204 1261 1205 if (!W_ERROR_IS_OK(registry_init_full())) 1262 1206 exit(1); 1263 1207 1264 #if 01265 if (!init_svcctl_db())1266 exit(1);1267 #endif1268 1269 1208 if (!print_backend_init(smbd_messaging_context())) 1270 1209 exit(1); 1271 1272 if (!init_guest_info()) {1273 DEBUG(0,("ERROR: failed to setup guest info.\n"));1274 return -1;1275 }1276 1210 1277 1211 /* Open the share_info.tdb here, so we don't have to open … … 1284 1218 } 1285 1219 1220 status = init_system_info(); 1221 if (!NT_STATUS_IS_OK(status)) { 1222 DEBUG(1, ("ERROR: failed to setup system user info: %s.\n", 1223 nt_errstr(status))); 1224 return -1; 1225 } 1226 1227 if (!init_guest_info()) { 1228 DEBUG(0,("ERROR: failed to setup guest info.\n")); 1229 return -1; 1230 } 1231 1232 if (!file_init(smbd_server_conn)) { 1233 DEBUG(0, ("ERROR: file_init failed\n")); 1234 return -1; 1235 } 1236 1237 if (is_daemon && !interactive) { 1238 const char *rpcsrv_type; 1239 1240 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM, 1241 "rpc_server", "epmapper", 1242 "none"); 1243 if (StrCaseCmp(rpcsrv_type, "daemon") == 0) { 1244 start_epmd(smbd_event_context(), 1245 smbd_server_conn->msg_ctx); 1246 } 1247 } 1248 1249 if (!dcesrv_ep_setup(smbd_event_context(), smbd_server_conn->msg_ctx)) { 1250 exit(1); 1251 } 1252 1253 /* Publish nt printers, this requires a working winreg pipe */ 1254 pcap_cache_reload(server_event_context(), smbd_messaging_context(), 1255 &reload_printers); 1256 1286 1257 /* only start the background queue daemon if we are 1287 1258 running as a daemon -- bad things will happen if … … 1291 1262 if (is_daemon && !interactive 1292 1263 && lp_parm_bool(-1, "smbd", "backgroundqueue", true)) { 1293 start_background_queue(); 1264 start_background_queue(smbd_event_context(), 1265 smbd_messaging_context()); 1266 } 1267 1268 if (is_daemon && !_lp_disable_spoolss()) { 1269 const char *rpcsrv_type; 1270 1271 /* start spoolss daemon */ 1272 /* start as a separate daemon only if enabled */ 1273 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM, 1274 "rpc_server", "spoolss", 1275 "embedded"); 1276 if (StrCaseCmp(rpcsrv_type, "daemon") == 0) { 1277 start_spoolssd(smbd_event_context(), 1278 smbd_messaging_context()); 1279 } 1294 1280 } 1295 1281 … … 1313 1299 smbd_setup_sig_chld_handler(); 1314 1300 1315 smbd_process( );1301 smbd_process(smbd_server_conn); 1316 1302 1317 1303 exit_server_cleanly(NULL); … … 1325 1311 parent->interactive = interactive; 1326 1312 1327 if (!open_sockets_smbd(parent, ports))1313 if (!open_sockets_smbd(parent, smbd_messaging_context(), ports)) 1328 1314 exit_server("open_sockets_smbd() failed"); 1329 1315
Note:
See TracChangeset
for help on using the changeset viewer.