Changeset 740 for vendor/current/source4/smbd/server.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/smbd/server.c
r414 r740 32 32 #include "ntptr/ntptr.h" 33 33 #include "auth/gensec/gensec.h" 34 #include "libcli/auth/schannel.h" 34 35 #include "smbd/process_model.h" 35 36 #include "param/secrets.h" … … 41 42 #include "librpc/gen_ndr/ndr_irpc.h" 42 43 #include "cluster/cluster.h" 44 #include "dynconfig/dynconfig.h" 43 45 44 46 /* … … 116 118 #endif 117 119 DEBUG(0,("Exiting pid %d on SIGTERM\n", (int)getpid())); 118 exit( 0);120 exit(127); 119 121 } 120 122 … … 141 143 142 144 /* POSIX demands that signals are inherited. If the invoking process has 143 * these signals masked, we will have problems, as we won't rec ieve them. */145 * these signals masked, we will have problems, as we won't receive them. */ 144 146 BlockSignals(false, SIGHUP); 145 147 BlockSignals(false, SIGTERM); … … 177 179 { 178 180 const char *binary_name = (const char *)private_data; 179 DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name)); 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 } 180 188 exit(0); 181 189 } 182 190 183 191 /* 184 pre-open the sam ldb to ensure the schema has been loaded. This185 saves a lot of time in child processes192 pre-open the key databases. This saves a lot of time in child 193 processes 186 194 */ 187 static void prime_samdb_schema(struct tevent_context *event_ctx) 188 { 189 TALLOC_CTX *samdb_context; 190 samdb_context = talloc_new(event_ctx); 191 samdb_connect(samdb_context, event_ctx, cmdline_lp_ctx, system_session(samdb_context, cmdline_lp_ctx)); 192 talloc_free(samdb_context); 195 static void prime_ldb_databases(struct tevent_context *event_ctx) 196 { 197 TALLOC_CTX *db_context; 198 db_context = talloc_new(event_ctx); 199 200 samdb_connect(db_context, event_ctx, cmdline_lp_ctx, system_session(cmdline_lp_ctx), 0); 201 privilege_connect(db_context, cmdline_lp_ctx); 202 203 /* we deliberately leave these open, which allows them to be 204 * re-used in ldb_wrap_connect() */ 193 205 } 194 206 … … 214 226 215 227 msg = messaging_init(talloc_autofree_context(), 216 lp_messaging_path(event_ctx, lp_ctx), 217 cluster_id(0, SAMBA_PARENT_TASKID), 218 lp_iconv_convenience(lp_ctx), 219 event_ctx); 228 lpcfg_messaging_path(event_ctx, lp_ctx), 229 cluster_id(0, SAMBA_PARENT_TASKID), event_ctx); 220 230 NT_STATUS_HAVE_NO_MEMORY(msg); 221 231 … … 229 239 230 240 241 /* 242 show build info 243 */ 244 static void show_build(void) 245 { 246 #define CONFIG_OPTION(n) { #n, dyn_ ## n } 247 struct { 248 const char *name; 249 const char *value; 250 } config_options[] = { 251 CONFIG_OPTION(BINDIR), 252 CONFIG_OPTION(SBINDIR), 253 CONFIG_OPTION(CONFIGFILE), 254 CONFIG_OPTION(NCALRPCDIR), 255 CONFIG_OPTION(LOGFILEBASE), 256 CONFIG_OPTION(LMHOSTSFILE), 257 CONFIG_OPTION(DATADIR), 258 CONFIG_OPTION(MODULESDIR), 259 CONFIG_OPTION(LOCKDIR), 260 CONFIG_OPTION(PIDDIR), 261 CONFIG_OPTION(PRIVATE_DIR), 262 CONFIG_OPTION(SWATDIR), 263 CONFIG_OPTION(CODEPAGEDIR), 264 CONFIG_OPTION(SETUPDIR), 265 CONFIG_OPTION(WINBINDD_SOCKET_DIR), 266 CONFIG_OPTION(WINBINDD_PRIVILEGED_SOCKET_DIR), 267 CONFIG_OPTION(NTP_SIGND_SOCKET_DIR), 268 { NULL, NULL} 269 }; 270 int i; 271 272 printf("Samba version: %s\n", SAMBA_VERSION_STRING); 273 printf("Build environment:\n"); 274 #ifdef BUILD_SYSTEM 275 printf(" Build host: %s\n", BUILD_SYSTEM); 276 #endif 277 278 printf("Paths:\n"); 279 for (i=0; config_options[i].name; i++) { 280 printf(" %s: %s\n", config_options[i].name, config_options[i].value); 281 } 282 283 exit(0); 284 } 231 285 232 286 /* … … 239 293 int opt; 240 294 poptContext pc; 241 extern NTSTATUS server_service_wrepl_init(void); 242 extern NTSTATUS server_service_kdc_init(void); 243 extern NTSTATUS server_service_ldap_init(void); 244 extern NTSTATUS server_service_web_init(void); 245 extern NTSTATUS server_service_ldap_init(void); 246 extern NTSTATUS server_service_winbind_init(void); 247 extern NTSTATUS server_service_nbtd_init(void); 248 extern NTSTATUS server_service_auth_init(void); 249 extern NTSTATUS server_service_cldapd_init(void); 250 extern NTSTATUS server_service_smb_init(void); 251 extern NTSTATUS server_service_drepl_init(void); 252 extern NTSTATUS server_service_kcc_init(void); 253 extern NTSTATUS server_service_rpc_init(void); 254 extern NTSTATUS server_service_ntp_signd_init(void); 255 extern NTSTATUS server_service_samba3_smb_init(void); 295 #define _MODULE_PROTO(init) extern NTSTATUS init(void); 296 STATIC_service_MODULES_PROTO; 256 297 init_module_fn static_init[] = { STATIC_service_MODULES }; 257 298 init_module_fn *shared_init; … … 264 305 OPT_DAEMON = 1000, 265 306 OPT_INTERACTIVE, 266 OPT_PROCESS_MODEL 307 OPT_PROCESS_MODEL, 308 OPT_SHOW_BUILD 267 309 }; 268 310 struct poptOption long_options[] = { … … 276 318 {"maximum-runtime",0, POPT_ARG_INT, &max_runtime, 0, 277 319 "set maximum runtime of the server process, till autotermination", "seconds"}, 320 {"show-build", 'b', POPT_ARG_NONE, NULL, OPT_SHOW_BUILD, "show build info", NULL }, 278 321 POPT_COMMON_SAMBA 279 322 POPT_COMMON_VERSION … … 293 336 model = poptGetOptArg(pc); 294 337 break; 338 case OPT_SHOW_BUILD: 339 show_build(); 340 break; 295 341 default: 296 342 fprintf(stderr, "\nInvalid option %s: %s\n\n", 297 343 poptBadOption(pc, 0), poptStrerror(opt)); 298 344 poptPrintUsage(pc, stderr, 0); 299 exit(1);345 return 1; 300 346 } 301 347 } … … 305 351 "Option -i|--interactive is not allowed together with -D|--daemon\n\n"); 306 352 poptPrintUsage(pc, stderr, 0); 307 exit(1);353 return 1; 308 354 } else if (!opt_interactive) { 309 355 /* default is --daemon */ … … 321 367 322 368 DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING)); 323 DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-20 09\n"));369 DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2011\n")); 324 370 325 371 if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) { … … 327 373 DEBUGADD(0,("sizeof(uint16_t) = %u, sizeof(uint32_t) %u, sizeof(uint64_t) = %u\n", 328 374 (unsigned int)sizeof(uint16_t), (unsigned int)sizeof(uint32_t), (unsigned int)sizeof(uint64_t))); 329 exit(1);375 return 1; 330 376 } 331 377 332 378 if (opt_daemon) { 333 379 DEBUG(3,("Becoming a daemon.\n")); 334 become_daemon(true, false );380 become_daemon(true, false, false); 335 381 } 336 382 337 383 cleanup_tmp_files(cmdline_lp_ctx); 338 384 339 if (!directory_exist(lp _lockdir(cmdline_lp_ctx))) {340 mkdir(lp _lockdir(cmdline_lp_ctx), 0755);341 } 342 343 pidfile_create(lp _piddir(cmdline_lp_ctx), binary_name);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); 344 390 345 391 /* Do *not* remove this, until you have removed … … 347 393 /* Setup the SECRETS subsystem */ 348 394 if (secrets_init(talloc_autofree_context(), cmdline_lp_ctx) == NULL) { 349 exit(1); 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 } 350 403 } 351 404 … … 393 446 394 447 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 } 395 456 tevent_add_timer(event_ctx, event_ctx, 396 457 timeval_current_ofs(max_runtime, 0), … … 399 460 } 400 461 401 prime_ samdb_schema(event_ctx);462 prime_ldb_databases(event_ctx); 402 463 403 464 status = setup_parent_messaging(event_ctx, cmdline_lp_ctx); … … 410 471 411 472 status = server_service_startup(event_ctx, cmdline_lp_ctx, model, 412 lp _server_services(cmdline_lp_ctx));473 lpcfg_server_services(cmdline_lp_ctx)); 413 474 if (!NT_STATUS_IS_OK(status)) { 414 475 DEBUG(0,("Starting Services failed - %s\n", nt_errstr(status)));
Note:
See TracChangeset
for help on using the changeset viewer.