diff options
Diffstat (limited to 'source4/smbd')
-rw-r--r-- | source4/smbd/process_model.c | 2 | ||||
-rw-r--r-- | source4/smbd/server.c | 38 | ||||
-rw-r--r-- | source4/smbd/service_named_pipe.c | 11 | ||||
-rw-r--r-- | source4/smbd/service_stream.c | 55 | ||||
-rw-r--r-- | source4/smbd/service_stream.h | 4 | ||||
-rw-r--r-- | source4/smbd/service_task.c | 6 | ||||
-rw-r--r-- | source4/smbd/service_task.h | 4 |
7 files changed, 62 insertions, 58 deletions
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c index af12a7b8cb..3c4c03ebf2 100644 --- a/source4/smbd/process_model.c +++ b/source4/smbd/process_model.c @@ -111,7 +111,7 @@ _PUBLIC_ NTSTATUS process_model_init(struct loadparm_context *lp_ctx) } initialised = true; - shared_init = load_samba_modules(NULL, lp_ctx, "process_model"); + shared_init = load_samba_modules(NULL, "process_model"); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source4/smbd/server.c b/source4/smbd/server.c index 0f2f1bb1bb..1be3b2885f 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -178,13 +178,8 @@ _NORETURN_ static void max_runtime_handler(struct tevent_context *ev, struct timeval t, void *private_data) { const char *binary_name = (const char *)private_data; - struct timeval tv; - struct timezone tz; - if (gettimeofday(&tv, &tz) == 0) { - DEBUG(0,("%s: maximum runtime exceeded - terminating, current ts: %d\n", binary_name, (int)tv.tv_sec)); - } else { - DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name)); - } + DEBUG(0,("%s: maximum runtime exceeded - terminating, current ts: %llu\n", + binary_name, (unsigned long long) time(NULL))); exit(0); } @@ -221,11 +216,11 @@ static NTSTATUS samba_terminate(struct irpc_message *msg, static NTSTATUS setup_parent_messaging(struct tevent_context *event_ctx, struct loadparm_context *lp_ctx) { - struct messaging_context *msg; + struct imessaging_context *msg; NTSTATUS status; - msg = messaging_init(talloc_autofree_context(), - lpcfg_messaging_path(event_ctx, lp_ctx), + msg = imessaging_init(talloc_autofree_context(), + lpcfg_imessaging_path(event_ctx, lp_ctx), cluster_id(0, SAMBA_PARENT_TASKID), event_ctx); NT_STATUS_HAVE_NO_MEMORY(msg); @@ -388,10 +383,9 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ pidfile_create(lpcfg_piddir(cmdline_lp_ctx), binary_name); - /* Do *not* remove this, until you have removed - * passdb/secrets.c, and proved that Samba still builds... */ - /* Setup the SECRETS subsystem */ - if (secrets_init(talloc_autofree_context(), cmdline_lp_ctx) == NULL) { + /* Set up a database to hold a random seed, in case we don't + * have /dev/urandom */ + if (!randseed_init(talloc_autofree_context(), cmdline_lp_ctx)) { return 1; } @@ -402,9 +396,9 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ } } - gensec_init(cmdline_lp_ctx); /* FIXME: */ + gensec_init(); /* FIXME: */ - ntptr_init(cmdline_lp_ctx); /* FIXME: maybe run this in the initialization function + ntptr_init(); /* FIXME: maybe run this in the initialization function of the spoolss RPC server instead? */ ntvfs_init(cmdline_lp_ctx); /* FIXME: maybe run this in the initialization functions @@ -412,7 +406,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ process_model_init(cmdline_lp_ctx); - shared_init = load_samba_modules(NULL, cmdline_lp_ctx, "service"); + shared_init = load_samba_modules(NULL, "service"); run_init_functions(static_init); run_init_functions(shared_init); @@ -445,14 +439,8 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ discard_const(binary_name)); if (max_runtime) { - struct timeval tv; - struct timezone tz; - - if (gettimeofday(&tv, &tz) == 0) { - DEBUG(0,("Called with maxruntime %d - current ts %d\n", max_runtime, (int)tv.tv_sec)); - } else { - DEBUG(0,("Called with maxruntime %d\n", max_runtime)); - } + DEBUG(0,("Called with maxruntime %d - current ts %llu\n", + max_runtime, (unsigned long long) time(NULL))); tevent_add_timer(event_ctx, event_ctx, timeval_current_ofs(max_runtime, 0), max_runtime_handler, diff --git a/source4/smbd/service_named_pipe.c b/source4/smbd/service_named_pipe.c index 086a037b69..b000083eec 100644 --- a/source4/smbd/service_named_pipe.c +++ b/source4/smbd/service_named_pipe.c @@ -200,14 +200,21 @@ NTSTATUS tstream_setup_named_pipe(TALLOC_CTX *mem_ctx, goto fail; } + if (!directory_create_or_exist(lpcfg_ncalrpc_dir(lp_ctx), geteuid(), 0755)) { + status = map_nt_error_from_unix_common(errno); + DEBUG(0,(__location__ ": Failed to create ncalrpc pipe directory '%s' - %s\n", + lpcfg_ncalrpc_dir(lp_ctx), nt_errstr(status))); + goto fail; + } + dirname = talloc_asprintf(pipe_sock, "%s/np", lpcfg_ncalrpc_dir(lp_ctx)); if (dirname == NULL) { goto fail; } if (!directory_create_or_exist(dirname, geteuid(), 0700)) { - status = map_nt_error_from_unix(errno); - DEBUG(0,(__location__ ": Failed to create stream pipe directory %s - %s\n", + status = map_nt_error_from_unix_common(errno); + DEBUG(0,(__location__ ": Failed to create stream pipe directory '%s' - %s\n", dirname, nt_errstr(status))); goto fail; } diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c index 916393253b..6e65122063 100644 --- a/source4/smbd/service_stream.c +++ b/source4/smbd/service_stream.c @@ -27,6 +27,7 @@ #include "cluster/cluster.h" #include "param/param.h" #include "../lib/tsocket/tsocket.h" +#include "lib/util/util_net.h" /* the range of ports to try for dcerpc over tcp endpoints */ #define SERVER_TCP_LOW_PORT 1024 @@ -122,7 +123,7 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev, struct loadparm_context *lp_ctx, const struct model_ops *model_ops, const struct stream_server_ops *stream_ops, - struct messaging_context *msg_ctx, + struct imessaging_context *msg_ctx, void *private_data, struct stream_connection **_srv_conn) { @@ -186,11 +187,11 @@ static void stream_new_connection(struct tevent_context *ev, } /* setup to receive internal messages on this connection */ - srv_conn->msg_ctx = messaging_init(srv_conn, - lpcfg_messaging_path(srv_conn, lp_ctx), + srv_conn->msg_ctx = imessaging_init(srv_conn, + lpcfg_imessaging_path(srv_conn, lp_ctx), srv_conn->server_id, ev); if (!srv_conn->msg_ctx) { - stream_terminate_connection(srv_conn, "messaging_init() failed"); + stream_terminate_connection(srv_conn, "imessaging_init() failed"); return; } @@ -216,7 +217,7 @@ static void stream_new_connection(struct tevent_context *ev, stream_socket->ops->name, tsocket_address_string(srv_conn->remote_address, tmp_ctx), tsocket_address_string(srv_conn->local_address, tmp_ctx), - cluster_id_string(tmp_ctx, server_id)); + server_id_str(tmp_ctx, &server_id)); if (title) { stream_connection_set_title(srv_conn, title); } @@ -271,12 +272,34 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx, struct socket_address *socket_address; struct tevent_fd *fde; int i; + struct sockaddr_storage ss; stream_socket = talloc_zero(mem_ctx, struct stream_socket); NT_STATUS_HAVE_NO_MEMORY(stream_socket); - status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0); - NT_STATUS_NOT_OK_RETURN(status); + if (strcmp(family, "ip") == 0) { + /* we will get the real family from the address itself */ + if (!interpret_string_addr(&ss, sock_addr, 0)) { + talloc_free(stream_socket); + return NT_STATUS_INVALID_ADDRESS; + } + + socket_address = socket_address_from_sockaddr_storage(stream_socket, &ss, port?*port:0); + NT_STATUS_HAVE_NO_MEMORY_AND_FREE(socket_address, stream_socket); + + status = socket_create(socket_address->family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0); + NT_STATUS_NOT_OK_RETURN(status); + } else { + status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0); + NT_STATUS_NOT_OK_RETURN(status); + + /* this is for non-IP sockets, eg. unix domain sockets */ + socket_address = socket_address_from_strings(stream_socket, + stream_socket->sock->backend_name, + sock_addr, port?*port:0); + NT_STATUS_HAVE_NO_MEMORY(socket_address); + } + talloc_steal(stream_socket, stream_socket->sock); @@ -297,34 +320,19 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx, /* Some sockets don't have a port, or are just described from * the string. We are indicating this by having port == NULL */ if (!port) { - socket_address = socket_address_from_strings(stream_socket, - stream_socket->sock->backend_name, - sock_addr, 0); - NT_STATUS_HAVE_NO_MEMORY(socket_address); status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0); - talloc_free(socket_address); - } else if (*port == 0) { for (i=SERVER_TCP_LOW_PORT;i<= SERVER_TCP_HIGH_PORT;i++) { - socket_address = socket_address_from_strings(stream_socket, - stream_socket->sock->backend_name, - sock_addr, i); - NT_STATUS_HAVE_NO_MEMORY(socket_address); + socket_address->port = i; status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0); - talloc_free(socket_address); if (NT_STATUS_IS_OK(status)) { *port = i; break; } } } else { - socket_address = socket_address_from_strings(stream_socket, - stream_socket->sock->backend_name, - sock_addr, *port); - NT_STATUS_HAVE_NO_MEMORY(socket_address); status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0); - talloc_free(socket_address); } if (!NT_STATUS_IS_OK(status)) { @@ -362,6 +370,7 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } + /* setup a connection title */ diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h index 02ade716d2..e098a690f1 100644 --- a/source4/smbd/service_stream.h +++ b/source4/smbd/service_stream.h @@ -23,7 +23,7 @@ #ifndef __SERVICE_STREAM_H__ #define __SERVICE_STREAM_H__ -#include "librpc/gen_ndr/server_id4.h" +#include "librpc/gen_ndr/server_id.h" /* modules can use the following to determine if the interface has changed * please increment the version number after each interface change @@ -47,7 +47,7 @@ struct stream_connection { } event; struct socket_context *socket; - struct messaging_context *msg_ctx; + struct imessaging_context *msg_ctx; struct loadparm_context *lp_ctx; struct tstream_context *tstream; diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c index 1eb8403e3b..32c44cf660 100644 --- a/source4/smbd/service_task.c +++ b/source4/smbd/service_task.c @@ -78,12 +78,12 @@ static void task_server_callback(struct tevent_context *event_ctx, task->server_id = server_id; task->lp_ctx = lp_ctx; - task->msg_ctx = messaging_init(task, - lpcfg_messaging_path(task, task->lp_ctx), + task->msg_ctx = imessaging_init(task, + lpcfg_imessaging_path(task, task->lp_ctx), task->server_id, task->event_ctx); if (!task->msg_ctx) { - task_server_terminate(task, "messaging_init() failed", true); + task_server_terminate(task, "imessaging_init() failed", true); return; } diff --git a/source4/smbd/service_task.h b/source4/smbd/service_task.h index b8954073e5..ded4590daf 100644 --- a/source4/smbd/service_task.h +++ b/source4/smbd/service_task.h @@ -22,12 +22,12 @@ #ifndef __SERVICE_TASK_H__ #define __SERVICE_TASK_H__ -#include "librpc/gen_ndr/server_id4.h" +#include "librpc/gen_ndr/server_id.h" struct task_server { struct tevent_context *event_ctx; const struct model_ops *model_ops; - struct messaging_context *msg_ctx; + struct imessaging_context *msg_ctx; struct loadparm_context *lp_ctx; struct server_id server_id; void *private_data; |