Changeset 988 for vendor/current/source4/smbd/server.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/smbd/server.c
r740 r988 35 35 #include "smbd/process_model.h" 36 36 #include "param/secrets.h" 37 #include " smbd/pidfile.h"37 #include "lib/util/pidfile.h" 38 38 #include "param/param.h" 39 39 #include "dsdb/samdb/samdb.h" … … 43 43 #include "cluster/cluster.h" 44 44 #include "dynconfig/dynconfig.h" 45 #include "lib/util/samba_modules.h" 46 #include "nsswitch/winbind_client.h" 47 #include "libds/common/roles.h" 45 48 46 49 /* … … 179 182 { 180 183 const char *binary_name = (const char *)private_data; 181 struct timeval tv; 182 struct timezone tz; 183 if (gettimeofday(&tv, &tz) == 0) { 184 DEBUG(0,("%s: maximum runtime exceeded - terminating, current ts: %d\n", binary_name, (int)tv.tv_sec)); 185 } else { 186 DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name)); 187 } 184 DEBUG(0,("%s: maximum runtime exceeded - terminating at %llu, current ts: %llu\n", 185 binary_name, (unsigned long long)t.tv_sec, (unsigned long long) time(NULL))); 188 186 exit(0); 189 187 } … … 222 220 struct loadparm_context *lp_ctx) 223 221 { 224 struct messaging_context *msg;222 struct imessaging_context *msg; 225 223 NTSTATUS status; 226 224 227 msg = messaging_init(talloc_autofree_context(),228 lpcfg_messaging_path(event_ctx, lp_ctx),229 cluster_id(0, SAMBA_PARENT_TASKID), event_ctx);225 msg = imessaging_init(talloc_autofree_context(), 226 lp_ctx, 227 cluster_id(0, SAMBA_PARENT_TASKID), event_ctx, false); 230 228 NT_STATUS_HAVE_NO_MEMORY(msg); 231 229 232 irpc_add_name(msg, "samba"); 230 status = irpc_add_name(msg, "samba"); 231 if (!NT_STATUS_IS_OK(status)) { 232 return status; 233 } 233 234 234 235 status = IRPC_REGISTER(msg, irpc, SAMBA_TERMINATE, … … 258 259 CONFIG_OPTION(MODULESDIR), 259 260 CONFIG_OPTION(LOCKDIR), 261 CONFIG_OPTION(STATEDIR), 262 CONFIG_OPTION(CACHEDIR), 260 263 CONFIG_OPTION(PIDDIR), 261 264 CONFIG_OPTION(PRIVATE_DIR), 262 CONFIG_OPTION(SWATDIR),263 265 CONFIG_OPTION(CODEPAGEDIR), 264 266 CONFIG_OPTION(SETUPDIR), … … 302 304 const char *model = "standard"; 303 305 int max_runtime = 0; 306 struct stat st; 304 307 enum { 305 308 OPT_DAEMON = 1000, … … 359 362 poptFreeContext(pc); 360 363 364 talloc_enable_null_tracking(); 365 361 366 setup_logging(binary_name, opt_interactive?DEBUG_STDOUT:DEBUG_FILE); 362 367 setup_signals(); … … 367 372 368 373 DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING)); 369 DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-201 1\n"));374 DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2016\n")); 370 375 371 376 if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) { … … 383 388 cleanup_tmp_files(cmdline_lp_ctx); 384 389 385 if (!directory_exist(lpcfg_lockdir(cmdline_lp_ctx))) { 386 mkdir(lpcfg_lockdir(cmdline_lp_ctx), 0755); 387 } 388 389 pidfile_create(lpcfg_piddir(cmdline_lp_ctx), binary_name); 390 391 /* Do *not* remove this, until you have removed 392 * passdb/secrets.c, and proved that Samba still builds... */ 393 /* Setup the SECRETS subsystem */ 394 if (secrets_init(talloc_autofree_context(), cmdline_lp_ctx) == NULL) { 395 return 1; 396 } 397 398 if (lpcfg_server_role(cmdline_lp_ctx) == ROLE_DOMAIN_CONTROLLER) { 399 if (!open_schannel_session_store(talloc_autofree_context(), lpcfg_private_dir(cmdline_lp_ctx))) { 400 DEBUG(0,("ERROR: Samba cannot open schannel store for secured NETLOGON operations.\n")); 401 exit(1); 402 } 403 } 404 405 gensec_init(cmdline_lp_ctx); /* FIXME: */ 406 407 ntptr_init(cmdline_lp_ctx); /* FIXME: maybe run this in the initialization function 390 if (!directory_exist(lpcfg_lock_directory(cmdline_lp_ctx))) { 391 mkdir(lpcfg_lock_directory(cmdline_lp_ctx), 0755); 392 } 393 394 pidfile_create(lpcfg_pid_directory(cmdline_lp_ctx), binary_name); 395 396 if (lpcfg_server_role(cmdline_lp_ctx) == ROLE_ACTIVE_DIRECTORY_DC) { 397 if (!open_schannel_session_store(talloc_autofree_context(), cmdline_lp_ctx)) { 398 exit_daemon("Samba cannot open schannel store for secured NETLOGON operations.", EACCES); 399 } 400 } 401 402 /* make sure we won't go through nss_winbind */ 403 if (!winbind_off()) { 404 exit_daemon("Samba failed to disable recusive winbindd calls.", EACCES); 405 } 406 407 gensec_init(); /* FIXME: */ 408 409 ntptr_init(); /* FIXME: maybe run this in the initialization function 408 410 of the spoolss RPC server instead? */ 409 411 … … 413 415 process_model_init(cmdline_lp_ctx); 414 416 415 shared_init = load_samba_modules(NULL, cmdline_lp_ctx,"service");417 shared_init = load_samba_modules(NULL, "service"); 416 418 417 419 run_init_functions(static_init); … … 425 427 426 428 if (event_ctx == NULL) { 427 DEBUG(0,("Initializing event context failed\n")); 428 return 1; 429 exit_daemon("Initializing event context failed", EACCES); 429 430 } 430 431 … … 441 442 signal(SIGTTIN, SIG_IGN); 442 443 #endif 443 tevent_add_fd(event_ctx, event_ctx, 0, stdin_event_flags, 444 server_stdin_handler, 445 discard_const(binary_name)); 444 445 if (fstat(0, &st) != 0) { 446 exit_daemon("Samba failed to set standard input handler", ENOTTY); 447 } 448 449 if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { 450 tevent_add_fd(event_ctx, 451 event_ctx, 452 0, 453 stdin_event_flags, 454 server_stdin_handler, 455 discard_const(binary_name)); 456 } 446 457 447 458 if (max_runtime) { 448 struct timeval tv; 449 struct timezone tz; 450 451 if (gettimeofday(&tv, &tz) == 0) { 452 DEBUG(0,("Called with maxruntime %d - current ts %d\n", max_runtime, (int)tv.tv_sec)); 453 } else { 454 DEBUG(0,("Called with maxruntime %d\n", max_runtime)); 455 } 459 DEBUG(0,("Called with maxruntime %d - current ts %llu\n", 460 max_runtime, (unsigned long long) time(NULL))); 456 461 tevent_add_timer(event_ctx, event_ctx, 457 462 timeval_current_ofs(max_runtime, 0), … … 460 465 } 461 466 467 if (lpcfg_server_role(cmdline_lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC 468 && !lpcfg_parm_bool(cmdline_lp_ctx, NULL, "server role check", "inhibit", false) 469 && !str_list_check_ci(lpcfg_server_services(cmdline_lp_ctx), "smb") 470 && !str_list_check_ci(lpcfg_dcerpc_endpoint_servers(cmdline_lp_ctx), "remote") 471 && !str_list_check_ci(lpcfg_dcerpc_endpoint_servers(cmdline_lp_ctx), "mapiproxy")) { 472 DEBUG(0, ("At this time the 'samba' binary should only be used for either:\n")); 473 DEBUGADD(0, ("'server role = active directory domain controller' or to access the ntvfs file server with 'server services = +smb' or the rpc proxy with 'dcerpc endpoint servers = remote'\n")); 474 DEBUGADD(0, ("You should start smbd/nmbd/winbindd instead for domain member and standalone file server tasks\n")); 475 exit_daemon("Samba detected misconfigured 'server role' and exited. Check logs for details", EINVAL); 476 }; 477 462 478 prime_ldb_databases(event_ctx); 463 479 464 480 status = setup_parent_messaging(event_ctx, cmdline_lp_ctx); 465 481 if (!NT_STATUS_IS_OK(status)) { 466 DEBUG(0,("Failed to setup parent messaging - %s\n", nt_errstr(status))); 467 return 1; 482 exit_daemon("Samba failed to setup parent messaging", NT_STATUS_V(status)); 468 483 } 469 484 … … 473 488 lpcfg_server_services(cmdline_lp_ctx)); 474 489 if (!NT_STATUS_IS_OK(status)) { 475 DEBUG(0,("Starting Services failed - %s\n", nt_errstr(status))); 476 return 1; 490 exit_daemon("Samba failed to start services", NT_STATUS_V(status)); 491 } 492 493 if (opt_daemon) { 494 daemon_ready("samba"); 477 495 } 478 496
Note:
See TracChangeset
for help on using the changeset viewer.