diff options
Diffstat (limited to 'source4/smbd')
-rw-r--r-- | source4/smbd/pidfile.c | 8 | ||||
-rw-r--r-- | source4/smbd/process_model.c | 3 | ||||
-rw-r--r-- | source4/smbd/process_model.h | 2 | ||||
-rw-r--r-- | source4/smbd/process_single.c | 2 | ||||
-rw-r--r-- | source4/smbd/process_standard.c | 2 | ||||
-rw-r--r-- | source4/smbd/server.c | 37 | ||||
-rw-r--r-- | source4/smbd/service_stream.c | 20 | ||||
-rw-r--r-- | source4/smbd/service_stream.h | 2 | ||||
-rw-r--r-- | source4/smbd/service_task.c | 5 | ||||
-rw-r--r-- | source4/smbd/service_task.h | 2 |
10 files changed, 54 insertions, 29 deletions
diff --git a/source4/smbd/pidfile.c b/source4/smbd/pidfile.c index fdb502d41d..4847ddd7b5 100644 --- a/source4/smbd/pidfile.c +++ b/source4/smbd/pidfile.c @@ -21,6 +21,8 @@ #include "includes.h" #include "system/filesys.h" +#include "param/param.h" +#include "smbd/pidfile.h" /** * @file @@ -38,7 +40,7 @@ pid_t pidfile_pid(const char *name) pid_t ret; char *pidFile; - asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name); + asprintf(&pidFile, "%s/%s.pid", lp_piddir(global_loadparm), name); fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644); @@ -85,7 +87,7 @@ void pidfile_create(const char *name) char *pidFile; pid_t pid; - asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name); + asprintf(&pidFile, "%s/%s.pid", lp_piddir(global_loadparm), name); pid = pidfile_pid(name); if (pid != 0) { @@ -101,7 +103,7 @@ void pidfile_create(const char *name) exit(1); } - if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==False) { + if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==false) { DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n", name, pidFile, strerror(errno))); exit(1); diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c index f83c7b784b..bb4d3a53bb 100644 --- a/source4/smbd/process_model.c +++ b/source4/smbd/process_model.c @@ -21,6 +21,7 @@ #include "includes.h" #include "smbd/process_model.h" #include "build.h" +#include "param/param.h" /* setup the events for the chosen process model @@ -82,7 +83,7 @@ _PUBLIC_ NTSTATUS register_process_model(const void *_ops) NTSTATUS process_model_init(void) { init_module_fn static_init[] = STATIC_process_model_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, "process_model"); + init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "process_model"); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source4/smbd/process_model.h b/source4/smbd/process_model.h index 513e903781..19212606c1 100644 --- a/source4/smbd/process_model.h +++ b/source4/smbd/process_model.h @@ -67,6 +67,8 @@ struct process_model_critical_sizes { int sizeof_model_ops; }; +extern const struct model_ops single_ops; + #include "smbd/process_model_proto.h" #endif /* __PROCESS_MODEL_H__ */ diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c index 65f5a7e375..5ba2c8df88 100644 --- a/source4/smbd/process_single.c +++ b/source4/smbd/process_single.c @@ -87,7 +87,7 @@ static void single_set_title(struct event_context *ev, const char *title) { } -static const struct model_ops single_ops = { +const struct model_ops single_ops = { .name = "single", .model_init = single_model_init, .new_task = single_new_task, diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index b9a245d140..07fdccdb36 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -191,7 +191,7 @@ static void standard_new_task(struct event_context *ev, /* called when a task goes down */ -static void standard_terminate(struct event_context *ev, const char *reason) +_NORETURN_ static void standard_terminate(struct event_context *ev, const char *reason) { DEBUG(2,("standard_terminate: reason[%s]\n",reason)); diff --git a/source4/smbd/server.c b/source4/smbd/server.c index 1a90592fcd..8f5c3b66ec 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -39,6 +39,7 @@ #include "param/secrets.h" #include "smbd/pidfile.h" #include "cluster/ctdb/ctdb_cluster.h" +#include "param/param.h" /* recursively delete a directory tree @@ -92,7 +93,7 @@ static void cleanup_tmp_files(void) char *path; TALLOC_CTX *mem_ctx = talloc_new(NULL); - path = smbd_tmp_path(mem_ctx, NULL); + path = smbd_tmp_path(mem_ctx, global_loadparm, NULL); recursive_delete(path); talloc_free(mem_ctx); @@ -122,25 +123,25 @@ static void sig_term(int sig) static void setup_signals(void) { /* we are never interested in SIGPIPE */ - BlockSignals(True,SIGPIPE); + BlockSignals(true,SIGPIPE); #if defined(SIGFPE) /* we are never interested in SIGFPE */ - BlockSignals(True,SIGFPE); + BlockSignals(true,SIGFPE); #endif /* We are no longer interested in USR1 */ - BlockSignals(True, SIGUSR1); + BlockSignals(true, SIGUSR1); #if defined(SIGUSR2) /* We are no longer interested in USR2 */ - BlockSignals(True,SIGUSR2); + BlockSignals(true,SIGUSR2); #endif /* POSIX demands that signals are inherited. If the invoking process has * these signals masked, we will have problems, as we won't recieve them. */ - BlockSignals(False, SIGHUP); - BlockSignals(False, SIGTERM); + BlockSignals(false, SIGHUP); + BlockSignals(false, SIGTERM); CatchSignal(SIGHUP, sig_hup); CatchSignal(SIGTERM, sig_term); @@ -152,7 +153,7 @@ static void setup_signals(void) static void server_stdin_handler(struct event_context *event_ctx, struct fd_event *fde, uint16_t flags, void *private) { - const char *binary_name = private; + const char *binary_name = (const char *)private; uint8_t c; if (read(0, &c, 1) == 0) { DEBUG(0,("%s: EOF on stdin - terminating\n", binary_name)); @@ -168,10 +169,11 @@ static void server_stdin_handler(struct event_context *event_ctx, struct fd_even /* die if the user selected maximum runtime is exceeded */ -static void max_runtime_handler(struct event_context *ev, struct timed_event *te, - struct timeval t, void *private) +_NORETURN_ static void max_runtime_handler(struct event_context *ev, + struct timed_event *te, + struct timeval t, void *private) { - const char *binary_name = private; + const char *binary_name = (const char *)private; DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name)); exit(0); } @@ -267,8 +269,8 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ cleanup_tmp_files(); - if (!directory_exist(lp_lockdir())) { - mkdir(lp_lockdir(), 0755); + if (!directory_exist(lp_lockdir(global_loadparm))) { + mkdir(lp_lockdir(global_loadparm), 0755); } pidfile_create(binary_name); @@ -294,7 +296,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ process_model_init(); - shared_init = load_samba_modules(NULL, "service"); + shared_init = load_samba_modules(NULL, global_loadparm, "service"); run_init_functions(static_init); run_init_functions(shared_init); @@ -305,6 +307,11 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ should hang off that */ event_ctx = event_context_init(talloc_autofree_context()); + if (event_ctx == NULL) { + DEBUG(0,("Initializing event context failed\n")); + return 1; + } + /* initialise clustering if needed */ cluster_ctdb_init(event_ctx, model); @@ -327,7 +334,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ } DEBUG(0,("%s: using '%s' process model\n", binary_name, model)); - status = server_service_startup(event_ctx, model, lp_server_services()); + status = server_service_startup(event_ctx, model, lp_server_services(global_loadparm)); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Starting Services failed - %s\n", nt_errstr(status))); return 1; diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c index 08c323fc0a..ad72f907bb 100644 --- a/source4/smbd/service_stream.c +++ b/source4/smbd/service_stream.c @@ -28,6 +28,7 @@ #include "smbd/service_stream.h" #include "lib/messaging/irpc.h" #include "cluster/cluster.h" +#include "param/param.h" /* the range of ports to try for dcerpc over tcp endpoints */ #define SERVER_TCP_LOW_PORT 1024 @@ -83,13 +84,13 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char */ static void stream_io_handler(struct stream_connection *conn, uint16_t flags) { - conn->processing = True; + conn->processing = true; if (flags & EVENT_FD_WRITE) { conn->ops->send_handler(conn, flags); } else if (flags & EVENT_FD_READ) { conn->ops->recv_handler(conn, flags); } - conn->processing = False; + conn->processing = false; if (conn->terminate) { stream_terminate_connection(conn, conn->terminate); @@ -174,13 +175,15 @@ static void stream_new_connection(struct event_context *ev, srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock), 0, stream_io_handler_fde, srv_conn); - if (!socket_check_access(sock, "smbd", lp_hostsallow(-1), lp_hostsdeny(-1))) { + if (!socket_check_access(sock, "smbd", lp_hostsallow(NULL), lp_hostsdeny(NULL))) { stream_terminate_connection(srv_conn, "denied by access rules"); return; } /* setup to receive internal messages on this connection */ - srv_conn->msg_ctx = messaging_init(srv_conn, srv_conn->server_id, ev); + srv_conn->msg_ctx = messaging_init(srv_conn, + lp_messaging_path(srv_conn, global_loadparm), + srv_conn->server_id, ev); if (!srv_conn->msg_ctx) { stream_terminate_connection(srv_conn, "messaging_init() failed"); return; @@ -224,11 +227,13 @@ static void stream_accept_handler(struct event_context *ev, struct fd_event *fde stream_new_connection, stream_socket); } - - /* setup a listen stream socket if you pass *port == 0, then a port > 1024 is used + + FIXME: This function is TCP/IP specific - uses an int rather than + a string for the port. Should leave allocating a port nr + to the socket implementation - JRV20070903 */ NTSTATUS stream_setup_socket(struct event_context *event_context, const struct model_ops *model_ops, @@ -255,7 +260,8 @@ NTSTATUS stream_setup_socket(struct event_context *event_context, status = socket_set_option(stream_socket->sock, "SO_KEEPALIVE", NULL); NT_STATUS_NOT_OK_RETURN(status); - status = socket_set_option(stream_socket->sock, lp_socket_options(), NULL); + status = socket_set_option(stream_socket->sock, lp_socket_options(global_loadparm), + NULL); NT_STATUS_NOT_OK_RETURN(status); /* TODO: set socket ACL's here when they're implemented */ diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h index 49869d8eed..6eb26a4282 100644 --- a/source4/smbd/service_stream.h +++ b/source4/smbd/service_stream.h @@ -23,6 +23,8 @@ #ifndef __SERVICE_STREAM_H__ #define __SERVICE_STREAM_H__ +#include "librpc/gen_ndr/misc.h" + /* modules can use the following to determine if the interface has changed * please increment the version number after each interface change * with a comment and maybe update struct stream_connection_critical_sizes. diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c index cab5c7e112..c77cae4185 100644 --- a/source4/smbd/service_task.c +++ b/source4/smbd/service_task.c @@ -25,6 +25,7 @@ #include "smbd/service.h" #include "smbd/service_task.h" #include "lib/messaging/irpc.h" +#include "param/param.h" /* terminate a task service @@ -64,7 +65,9 @@ static void task_server_callback(struct event_context *event_ctx, task->model_ops = state->model_ops; task->server_id = server_id; - task->msg_ctx = messaging_init(task, task->server_id, task->event_ctx); + task->msg_ctx = messaging_init(task, + lp_messaging_path(task, global_loadparm), + task->server_id, task->event_ctx); if (!task->msg_ctx) { task_server_terminate(task, "messaging_init() failed"); return; diff --git a/source4/smbd/service_task.h b/source4/smbd/service_task.h index 54e6d0fa6c..e5bf9ea414 100644 --- a/source4/smbd/service_task.h +++ b/source4/smbd/service_task.h @@ -22,6 +22,8 @@ #ifndef __SERVICE_TASK_H__ #define __SERVICE_TASK_H__ +#include "librpc/gen_ndr/misc.h" + struct task_server { struct event_context *event_ctx; const struct model_ops *model_ops; |