Changeset 988 for vendor/current/source4/smbd
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/smbd
- Files:
-
- 5 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/smbd/process_model.c
r740 r988 22 22 #include "smbd/process_model.h" 23 23 #include "param/param.h" 24 #include "lib/util/samba_modules.h" 24 25 25 26 /* the list of currently registered process models */ … … 112 113 initialised = true; 113 114 114 shared_init = load_samba_modules(NULL, lp_ctx,"process_model");115 shared_init = load_samba_modules(NULL, "process_model"); 115 116 116 117 run_init_functions(static_init); -
vendor/current/source4/smbd/process_single.c
r740 r988 27 27 #include "cluster/cluster.h" 28 28 29 NTSTATUS process_model_single_init(void); 30 29 31 /* 30 32 called when the process model is selected … … 48 50 NTSTATUS status; 49 51 struct socket_context *connected_socket; 52 pid_t pid = getpid(); 50 53 51 54 /* accept an incoming connection. */ … … 70 73 talloc_steal(private_data, connected_socket); 71 74 72 /* The cluster_id(0, fd) cannot collide with the incrementing 73 * task below, as the first component is 0, not 1 */ 75 /* 76 * We use the PID so we cannot collide in with cluster ids 77 * generated in other single mode tasks, and, and won't 78 * collide with PIDs from process model standard because a the 79 * combination of pid/fd should be unique system-wide 80 */ 74 81 new_conn(ev, lp_ctx, connected_socket, 75 cluster_id( 0, socket_get_fd(connected_socket)), private_data);82 cluster_id(pid, socket_get_fd(connected_socket)), private_data); 76 83 } 77 84 … … 85 92 void *private_data) 86 93 { 87 /* start our taskids at 1, zero is reserved for the top88 level samba task*/89 static uint32_t taskid = 1;94 pid_t pid = getpid(); 95 /* start our taskids at MAX_INT32, the first 2^31 tasks are is reserved for fd numbers */ 96 static uint32_t taskid = INT32_MAX; 90 97 91 /* We use 1 so we cannot collide in with cluster ids generated 92 * in the accept connection above, and unlikly to collide with 93 * PIDs from process modal standard (don't run samba as 94 * init) */ 95 new_task(ev, lp_ctx, cluster_id(1, taskid++), private_data); 98 /* 99 * We use the PID so we cannot collide in with cluster ids 100 * generated in other single mode tasks, and, and won't 101 * collide with PIDs from process model starndard because a the 102 * combination of pid/task_id should be unique system-wide 103 * 104 * Using the pid unaltered makes debugging of which process 105 * owns the messaging socket easier. 106 */ 107 new_task(ev, lp_ctx, cluster_id(pid, taskid++), private_data); 96 108 } 97 109 -
vendor/current/source4/smbd/process_standard.c
r740 r988 30 30 #include "ldb_wrap.h" 31 31 32 #ifdef HAVE_SETPROCTITLE 33 #ifdef HAVE_SETPROCTITLE_H 34 #include <setproctitle.h> 35 #endif 36 #else 37 #define setproctitle none_setproctitle 38 static int none_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2); 39 static int none_setproctitle(const char *fmt, ...) 40 { 41 return 0; 42 } 43 #endif 32 struct standard_child_state { 33 const char *name; 34 pid_t pid; 35 int to_parent_fd; 36 int from_child_fd; 37 struct tevent_fd *from_child_fde; 38 }; 39 40 NTSTATUS process_model_standard_init(void); 44 41 45 42 /* we hold a pipe open in the parent, and the any child 46 43 processes wait for EOF on that pipe. This ensures that 47 44 children die when the parent dies */ 48 static int child_pipe[2] ;45 static int child_pipe[2] = { -1, -1 }; 49 46 50 47 /* … … 53 50 static void standard_model_init(void) 54 51 { 55 pipe(child_pipe); 56 signal(SIGCHLD, SIG_IGN); 57 } 58 59 /* 60 handle EOF on the child pipe 52 int rc; 53 54 rc = pipe(child_pipe); 55 if (rc < 0) { 56 smb_panic("Failed to initialze pipe!"); 57 } 58 } 59 60 /* 61 handle EOF on the parent-to-all-children pipe in the child 61 62 */ 62 63 static void standard_pipe_handler(struct tevent_context *event_ctx, struct tevent_fd *fde, … … 65 66 DEBUG(10,("Child %d exiting\n", (int)getpid())); 66 67 exit(0); 68 } 69 70 /* 71 handle EOF on the child pipe in the parent, so we know when a 72 process terminates without using SIGCHLD or waiting on all possible pids. 73 74 We need to ensure we do not ignore SIGCHLD because we need it to 75 work to get a valid error code from samba_runcmd_*(). 76 */ 77 static void standard_child_pipe_handler(struct tevent_context *ev, 78 struct tevent_fd *fde, 79 uint16_t flags, 80 void *private_data) 81 { 82 struct standard_child_state *state 83 = talloc_get_type_abort(private_data, struct standard_child_state); 84 int status = 0; 85 pid_t pid; 86 87 /* the child has closed the pipe, assume its dead */ 88 errno = 0; 89 pid = waitpid(state->pid, &status, 0); 90 91 if (pid != state->pid) { 92 if (errno == ECHILD) { 93 /* 94 * this happens when the 95 * parent has set SIGCHLD to 96 * SIG_IGN. In that case we 97 * can only get error 98 * information for the child 99 * via its logging. We should 100 * stop using SIG_IGN on 101 * SIGCHLD in the standard 102 * process model. 103 */ 104 DEBUG(0, ("Error in waitpid() unexpectedly got ECHILD " 105 "for child %d (%s) - %s, someone has set SIGCHLD " 106 "to SIG_IGN!\n", 107 (int)state->pid, state->name, 108 strerror(errno))); 109 TALLOC_FREE(state); 110 return; 111 } 112 DEBUG(0, ("Error in waitpid() for child %d (%s) - %s \n", 113 (int)state->pid, state->name, strerror(errno))); 114 if (errno == 0) { 115 errno = ECHILD; 116 } 117 TALLOC_FREE(state); 118 return; 119 } 120 if (WIFEXITED(status)) { 121 status = WEXITSTATUS(status); 122 DEBUG(2, ("Child %d (%s) exited with status %d\n", 123 (int)state->pid, state->name, status)); 124 } else if (WIFSIGNALED(status)) { 125 status = WTERMSIG(status); 126 DEBUG(0, ("Child %d (%s) terminated with signal %d\n", 127 (int)state->pid, state->name, status)); 128 } 129 TALLOC_FREE(state); 130 return; 131 } 132 133 static struct standard_child_state *setup_standard_child_pipe(struct tevent_context *ev, 134 const char *name) 135 { 136 struct standard_child_state *state; 137 int parent_child_pipe[2]; 138 int ret; 139 140 /* 141 * Prepare a pipe to allow us to know when the child exits, 142 * because it will trigger a read event on this private 143 * pipe. 144 * 145 * We do all this before the accept and fork(), so we can 146 * clean up if it fails. 147 */ 148 state = talloc_zero(ev, struct standard_child_state); 149 if (state == NULL) { 150 return NULL; 151 } 152 153 if (name == NULL) { 154 name = ""; 155 } 156 157 state->name = talloc_strdup(state, name); 158 if (state->name == NULL) { 159 TALLOC_FREE(state); 160 return NULL; 161 } 162 163 ret = pipe(parent_child_pipe); 164 if (ret == -1) { 165 DEBUG(0, ("Failed to create parent-child pipe to handle " 166 "SIGCHLD to track new process for socket\n")); 167 TALLOC_FREE(state); 168 return NULL; 169 } 170 171 smb_set_close_on_exec(parent_child_pipe[0]); 172 smb_set_close_on_exec(parent_child_pipe[1]); 173 174 state->from_child_fd = parent_child_pipe[0]; 175 state->to_parent_fd = parent_child_pipe[1]; 176 177 /* 178 * The basic purpose of calling this handler is to ensure we 179 * call waitpid() and so avoid zombies (now that we no longer 180 * user SIGIGN on for SIGCHLD), but it also allows us to clean 181 * up other resources in the future. 182 */ 183 state->from_child_fde = tevent_add_fd(ev, state, 184 state->from_child_fd, 185 TEVENT_FD_READ, 186 standard_child_pipe_handler, 187 state); 188 if (state->from_child_fde == NULL) { 189 TALLOC_FREE(state); 190 return NULL; 191 } 192 tevent_fd_set_auto_close(state->from_child_fde); 193 194 return state; 67 195 } 68 196 … … 82 210 pid_t pid; 83 211 struct socket_address *c, *s; 212 struct standard_child_state *state; 213 214 state = setup_standard_child_pipe(ev, NULL); 215 if (state == NULL) { 216 return; 217 } 84 218 85 219 /* accept an incoming connection. */ … … 91 225 the system clears enough resources to handle this new socket */ 92 226 sleep(1); 227 close(state->to_parent_fd); 228 state->to_parent_fd = -1; 229 TALLOC_FREE(state); 93 230 return; 94 231 } … … 97 234 98 235 if (pid != 0) { 236 close(state->to_parent_fd); 237 state->to_parent_fd = -1; 238 239 if (pid > 0) { 240 state->pid = pid; 241 } else { 242 TALLOC_FREE(state); 243 } 244 99 245 /* parent or error code ... */ 100 246 talloc_free(sock2); … … 102 248 return; 103 249 } 250 251 /* this leaves state->to_parent_fd open */ 252 TALLOC_FREE(state); 104 253 105 254 pid = getpid(); … … 124 273 tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ, 125 274 standard_pipe_handler, NULL); 126 close(child_pipe[1]);127 128 /* Ensure that the forked children do not expose identical random streams */129 set_need_random_reseed();275 if (child_pipe[1] != -1) { 276 close(child_pipe[1]); 277 child_pipe[1] = -1; 278 } 130 279 131 280 /* setup the process title */ … … 139 288 talloc_free(s); 140 289 141 /* setup this new connection. Cluster ID is PID based for this process mod al */290 /* setup this new connection. Cluster ID is PID based for this process model */ 142 291 new_conn(ev, lp_ctx, sock2, cluster_id(pid, 0), private_data); 143 292 … … 145 294 so we now process events in the new event context until there are no 146 295 more to process */ 147 event_loop_wait(ev);296 tevent_loop_wait(ev); 148 297 149 298 talloc_free(ev); … … 161 310 { 162 311 pid_t pid; 312 struct standard_child_state *state; 313 314 state = setup_standard_child_pipe(ev, service_name); 315 if (state == NULL) { 316 return; 317 } 163 318 164 319 pid = fork(); 165 320 166 321 if (pid != 0) { 322 close(state->to_parent_fd); 323 state->to_parent_fd = -1; 324 325 if (pid > 0) { 326 state->pid = pid; 327 } else { 328 TALLOC_FREE(state); 329 } 330 167 331 /* parent or error code ... go back to the event loop */ 168 332 return; 169 333 } 334 335 /* this leaves state->to_parent_fd open */ 336 TALLOC_FREE(state); 170 337 171 338 pid = getpid(); … … 182 349 tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ, 183 350 standard_pipe_handler, NULL); 184 close(child_pipe[1]);185 186 /* Ensure that the forked children do not expose identical random streams */187 set_need_random_reseed();351 if (child_pipe[1] != -1) { 352 close(child_pipe[1]); 353 child_pipe[1] = -1; 354 } 188 355 189 356 setproctitle("task %s server_id[%d]", service_name, (int)pid); 190 357 191 /* setup this new task. Cluster ID is PID based for this process mod al */358 /* setup this new task. Cluster ID is PID based for this process model */ 192 359 new_task(ev, lp_ctx, cluster_id(pid, 0), private_data); 193 360 … … 195 362 so we now process events in the new event context until there are no 196 363 more to process */ 197 event_loop_wait(ev);364 tevent_loop_wait(ev); 198 365 199 366 talloc_free(ev); -
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 -
vendor/current/source4/smbd/service.c
r740 r988 45 45 srv->service_name = name; 46 46 srv->task_init = task_init; 47 DLIST_ADD_END(registered_servers, srv , struct registered_server *);47 DLIST_ADD_END(registered_servers, srv); 48 48 return NT_STATUS_OK; 49 49 } -
vendor/current/source4/smbd/service_named_pipe.c
r740 r988 201 201 } 202 202 203 if (!directory_create_or_exist(lpcfg_ncalrpc_dir(lp_ctx), geteuid(),0755)) {204 status = map_nt_error_from_unix (errno);203 if (!directory_create_or_exist(lpcfg_ncalrpc_dir(lp_ctx), 0755)) { 204 status = map_nt_error_from_unix_common(errno); 205 205 DEBUG(0,(__location__ ": Failed to create ncalrpc pipe directory '%s' - %s\n", 206 206 lpcfg_ncalrpc_dir(lp_ctx), nt_errstr(status))); … … 213 213 } 214 214 215 if (!directory_create_or_exist (dirname, geteuid(), 0700)) {216 status = map_nt_error_from_unix (errno);217 DEBUG(0,(__location__ ": Failed to create stream pipe directory %s- %s\n",215 if (!directory_create_or_exist_strict(dirname, geteuid(), 0700)) { 216 status = map_nt_error_from_unix_common(errno); 217 DEBUG(0,(__location__ ": Failed to create stream pipe directory '%s' - %s\n", 218 218 dirname, nt_errstr(status))); 219 219 goto fail; -
vendor/current/source4/smbd/service_stream.c
r740 r988 28 28 #include "param/param.h" 29 29 #include "../lib/tsocket/tsocket.h" 30 #include "lib/util/util_net.h" 30 31 31 32 /* the range of ports to try for dcerpc over tcp endpoints */ … … 60 61 if (!reason) reason = "unknown reason"; 61 62 62 DEBUG(3,("Terminating connection - '%s'\n", reason)); 63 if (srv_conn->processing) { 64 DEBUG(3,("Terminating connection deferred - '%s'\n", reason)); 65 } else { 66 DEBUG(3,("Terminating connection - '%s'\n", reason)); 67 } 63 68 64 69 srv_conn->terminate = reason; … … 77 82 talloc_free(srv_conn->event.fde); 78 83 srv_conn->event.fde = NULL; 84 imessaging_cleanup(srv_conn->msg_ctx); 79 85 model_ops->terminate(event_ctx, srv_conn->lp_ctx, reason); 80 86 talloc_free(srv_conn); … … 123 129 const struct model_ops *model_ops, 124 130 const struct stream_server_ops *stream_ops, 125 struct messaging_context *msg_ctx,131 struct imessaging_context *msg_ctx, 126 132 void *private_data, 127 133 struct stream_connection **_srv_conn) … … 174 180 srv_conn->lp_ctx = lp_ctx; 175 181 176 if (!socket_check_access(sock, "smbd", lpcfg_hosts allow(NULL, lpcfg_default_service(lp_ctx)), lpcfg_hostsdeny(NULL, lpcfg_default_service(lp_ctx)))) {182 if (!socket_check_access(sock, "smbd", lpcfg_hosts_allow(NULL, lpcfg_default_service(lp_ctx)), lpcfg_hosts_deny(NULL, lpcfg_default_service(lp_ctx)))) { 177 183 stream_terminate_connection(srv_conn, "denied by access rules"); 178 184 return; … … 187 193 188 194 /* setup to receive internal messages on this connection */ 189 srv_conn->msg_ctx = messaging_init(srv_conn,190 lpcfg_messaging_path(srv_conn, lp_ctx),191 srv_conn->server_id, ev);195 srv_conn->msg_ctx = imessaging_init(srv_conn, 196 lp_ctx, 197 srv_conn->server_id, ev, false); 192 198 if (!srv_conn->msg_ctx) { 193 stream_terminate_connection(srv_conn, " messaging_init() failed");199 stream_terminate_connection(srv_conn, "imessaging_init() failed"); 194 200 return; 195 201 } … … 210 216 TALLOC_CTX *tmp_ctx; 211 217 const char *title; 218 struct server_id_buf idbuf; 212 219 213 220 tmp_ctx = talloc_new(srv_conn); … … 217 224 tsocket_address_string(srv_conn->remote_address, tmp_ctx), 218 225 tsocket_address_string(srv_conn->local_address, tmp_ctx), 219 cluster_id_string(tmp_ctx, server_id));226 server_id_str_buf(server_id, &idbuf)); 220 227 if (title) { 221 228 stream_connection_set_title(srv_conn, title); … … 272 279 struct tevent_fd *fde; 273 280 int i; 281 struct sockaddr_storage ss; 274 282 275 283 stream_socket = talloc_zero(mem_ctx, struct stream_socket); 276 284 NT_STATUS_HAVE_NO_MEMORY(stream_socket); 277 285 278 status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0); 279 NT_STATUS_NOT_OK_RETURN(status); 286 if (strcmp(family, "ip") == 0) { 287 /* we will get the real family from the address itself */ 288 if (!interpret_string_addr(&ss, sock_addr, 0)) { 289 talloc_free(stream_socket); 290 return NT_STATUS_INVALID_ADDRESS; 291 } 292 293 socket_address = socket_address_from_sockaddr_storage(stream_socket, &ss, port?*port:0); 294 if (socket_address == NULL) { 295 TALLOC_FREE(stream_socket); 296 return NT_STATUS_NO_MEMORY; 297 } 298 299 status = socket_create(socket_address->family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0); 300 NT_STATUS_NOT_OK_RETURN(status); 301 } else { 302 status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0); 303 NT_STATUS_NOT_OK_RETURN(status); 304 305 /* this is for non-IP sockets, eg. unix domain sockets */ 306 socket_address = socket_address_from_strings(stream_socket, 307 stream_socket->sock->backend_name, 308 sock_addr, port?*port:0); 309 NT_STATUS_HAVE_NO_MEMORY(socket_address); 310 } 311 280 312 281 313 talloc_steal(stream_socket, stream_socket->sock); … … 298 330 * the string. We are indicating this by having port == NULL */ 299 331 if (!port) { 300 socket_address = socket_address_from_strings(stream_socket,301 stream_socket->sock->backend_name,302 sock_addr, 0);303 NT_STATUS_HAVE_NO_MEMORY(socket_address);304 332 status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0); 305 talloc_free(socket_address);306 307 333 } else if (*port == 0) { 308 334 for (i=SERVER_TCP_LOW_PORT;i<= SERVER_TCP_HIGH_PORT;i++) { 309 socket_address = socket_address_from_strings(stream_socket, 310 stream_socket->sock->backend_name, 311 sock_addr, i); 312 NT_STATUS_HAVE_NO_MEMORY(socket_address); 335 socket_address->port = i; 313 336 status = socket_listen(stream_socket->sock, socket_address, 314 337 SERVER_LISTEN_BACKLOG, 0); 315 talloc_free(socket_address);316 338 if (NT_STATUS_IS_OK(status)) { 317 339 *port = i; … … 320 342 } 321 343 } else { 322 socket_address = socket_address_from_strings(stream_socket,323 stream_socket->sock->backend_name,324 sock_addr, *port);325 NT_STATUS_HAVE_NO_MEMORY(socket_address);326 344 status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0); 327 talloc_free(socket_address);328 345 } 329 346 … … 363 380 } 364 381 382 365 383 /* 366 384 setup a connection title -
vendor/current/source4/smbd/service_stream.h
r740 r988 24 24 #define __SERVICE_STREAM_H__ 25 25 26 #include "librpc/gen_ndr/server_id 4.h"26 #include "librpc/gen_ndr/server_id.h" 27 27 28 28 /* modules can use the following to determine if the interface has changed … … 48 48 49 49 struct socket_context *socket; 50 struct messaging_context *msg_ctx;50 struct imessaging_context *msg_ctx; 51 51 struct loadparm_context *lp_ctx; 52 52 -
vendor/current/source4/smbd/service_task.c
r740 r988 35 35 DEBUG(0,("task_server_terminate: [%s]\n", reason)); 36 36 37 if (fatal ) {37 if (fatal && task->msg_ctx != NULL) { 38 38 struct dcerpc_binding_handle *irpc_handle; 39 39 struct samba_terminate r; … … 42 42 "samba", &ndr_table_irpc); 43 43 if (irpc_handle != NULL) { 44 /* Note: this makes use of nested event loops... */ 45 dcerpc_binding_handle_set_sync_ev(irpc_handle, event_ctx); 44 46 r.in.reason = reason; 45 47 dcerpc_samba_terminate_r(irpc_handle, task, &r); 46 48 } 47 49 } 50 51 imessaging_cleanup(task->msg_ctx); 48 52 49 53 model_ops->terminate(event_ctx, task->lp_ctx, reason); … … 79 83 task->lp_ctx = lp_ctx; 80 84 81 task->msg_ctx = messaging_init(task,82 lpcfg_messaging_path(task, task->lp_ctx),83 task->server_id,84 task->event_ctx);85 task->msg_ctx = imessaging_init(task, 86 task->lp_ctx, 87 task->server_id, 88 task->event_ctx, false); 85 89 if (!task->msg_ctx) { 86 task_server_terminate(task, " messaging_init() failed", true);90 task_server_terminate(task, "imessaging_init() failed", true); 87 91 return; 88 92 } -
vendor/current/source4/smbd/service_task.h
r740 r988 23 23 #define __SERVICE_TASK_H__ 24 24 25 #include "librpc/gen_ndr/server_id 4.h"25 #include "librpc/gen_ndr/server_id.h" 26 26 27 27 struct task_server { 28 28 struct tevent_context *event_ctx; 29 29 const struct model_ops *model_ops; 30 struct messaging_context *msg_ctx;30 struct imessaging_context *msg_ctx; 31 31 struct loadparm_context *lp_ctx; 32 32 struct server_id server_id; -
vendor/current/source4/smbd/wscript_build
r740 r988 4 4 source='service.c service_stream.c service_named_pipe.c service_task.c', 5 5 autoproto='service_proto.h', 6 deps='tevent MESSAGING samba_socket RPC_NDR_IRPC NDR_NAMED_PIPE_AUTH NAMED_PIPE_AUTH_TSTREAM gssapi credentials LIBTSOCKET LIBSAMBA_TSOCKET process_model', 7 private_library=True 6 deps='tevent MESSAGING samba_socket RPC_NDR_IRPC NDR_NAMED_PIPE_AUTH npa_tstream gssapi samba-credentials LIBTSOCKET LIBSAMBA_TSOCKET process_model', 7 private_library=True, 8 enabled=bld.AD_DC_BUILD_IS_ENABLED() 8 9 ) 9 10 10 11 11 bld.SAMBA_SUBSYSTEM('PIDFILE', 12 source='pidfile.c', 13 deps='talloc', 14 autoproto='pidfile.h' 15 ) 16 12 bld.SAMBA_LIBRARY('process_model', 13 source='process_model.c', 14 autoproto='process_model_proto.h', 15 deps='samba-util samba-hostconfig samba-modules', 16 private_library=True, 17 enabled=bld.AD_DC_BUILD_IS_ENABLED() 18 ) 17 19 18 20 bld.SAMBA_BINARY('samba', 19 21 source='server.c', 20 manpages='samba.8',21 22 subsystem_name='service', 22 deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA PIDFILE23 deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA 23 24 popt gensec registry ntptr ntvfs share cluster COMMON_SCHANNEL SECRETS''', 24 25 pyembed=True, 25 install_path='${SBINDIR}' 26 install_path='${SBINDIR}', 27 enabled=bld.AD_DC_BUILD_IS_ENABLED() 26 28 ) 27 28 29 30 29 31 30 bld.SAMBA_MODULE('process_model_single', … … 46 45 ) 47 46 48 49 bld.SAMBA_MODULE('process_model_thread',50 source='process_thread.c',51 subsystem='process_model',52 init_function='process_model_thread_init',53 enabled=False,54 deps='pthread samba-sockets cluster process_model',55 internal_module=False56 )57 58 59 bld.SAMBA_MODULE('process_model_prefork',60 source='process_prefork.c',61 subsystem='process_model',62 init_function='process_model_prefork_init',63 deps='events ldbsamba cluster samba-sockets process_model',64 internal_module=False65 )66 67 bld.SAMBA_MODULE('process_model_onefork',68 source='process_onefork.c',69 subsystem='process_model',70 init_function='process_model_onefork_init',71 deps='events ldbsamba process_model cluster samba-sockets',72 internal_module=False73 )74 75 76 bld.SAMBA_LIBRARY('process_model',77 source='process_model.c',78 autoproto='process_model_proto.h',79 deps='samba-util samba-hostconfig',80 private_library=True81 )82
Note:
See TracChangeset
for help on using the changeset viewer.