diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-03-09 17:48:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:56:49 -0500 |
commit | 651ca6553edadb2b97339fd3c112fdb6ef6c08bc (patch) | |
tree | 240f124aa3dcf08304c7f4bed6c2e0bd22ed83ed /source4/smbd/process_standard.c | |
parent | 60823d1878563c398373ff2c761dd91a588af3b5 (diff) | |
download | samba-651ca6553edadb2b97339fd3c112fdb6ef6c08bc.tar.gz samba-651ca6553edadb2b97339fd3c112fdb6ef6c08bc.tar.bz2 samba-651ca6553edadb2b97339fd3c112fdb6ef6c08bc.zip |
r14079: I just found the setproctitle library from alt linux:-)
- add set_title hook to the process models
- use setproctitle library in process_model standard if available
- the the title for the task servers and on connections
metze
(This used to be commit 526f20bbecc9bbd607595637c15fc4001d3f0c70)
Diffstat (limited to 'source4/smbd/process_standard.c')
-rw-r--r-- | source4/smbd/process_standard.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index dadbe5bf80..798d0883c8 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -26,6 +26,7 @@ #include "lib/events/events.h" #include "lib/tdb/include/tdb.h" #include "smb_server/smb_server.h" +#include "lib/socket/socket.h" /* For specifiying event context to GSSAPI below */ #include "system/kerberos.h" @@ -33,6 +34,13 @@ #include "passdb/secrets.h" +#ifdef HAVE_SETPROCTITLE +#include <setproctitle.h> +#define SETPROCTITLE(x) setproctitle x +#else +#define SETPROCTITLE(x) +#endif + /* called when the process model is selected */ @@ -54,6 +62,7 @@ static void standard_accept_connection(struct event_context *ev, struct socket_context *sock2; pid_t pid; struct event_context *ev2; + struct socket_address *c, *s; /* accept an incoming connection. */ status = socket_accept(sock, &sock2); @@ -75,6 +84,8 @@ static void standard_accept_connection(struct event_context *ev, return; } + pid = getpid(); + /* This is now the child code. We need a completely new event_context to work with */ ev2 = event_context_init(NULL); @@ -104,8 +115,18 @@ static void standard_accept_connection(struct event_context *ev, /* Ensure that the forked children do not expose identical random streams */ set_need_random_reseed(); + /* setup the process title */ + c = socket_get_peer_addr(sock2, ev2); + s = socket_get_my_addr(sock2, ev2); + if (s && c) { + SETPROCTITLE(("conn c[%s:%u] s[%s:%u] server_id[%d]", + c->addr, c->port, s->addr, s->port, pid)); + } + talloc_free(c); + talloc_free(s); + /* setup this new connection */ - new_conn(ev2, sock2, getpid(), private); + new_conn(ev2, sock2, pid, private); /* we can't return to the top level here, as that event context is gone, so we now process events in the new event context until there are no @@ -133,6 +154,8 @@ static void standard_new_task(struct event_context *ev, return; } + pid = getpid(); + /* This is now the child code. We need a completely new event_context to work with */ ev2 = event_context_init(NULL); @@ -153,8 +176,10 @@ static void standard_new_task(struct event_context *ev, /* Ensure that the forked children do not expose identical random streams */ set_need_random_reseed(); + SETPROCTITLE(("task server_id[%d]", pid)); + /* setup this new connection */ - new_task(ev2, getpid(), private); + new_task(ev2, pid, private); /* we can't return to the top level here, as that event context is gone, so we now process events in the new event context until there are no @@ -184,6 +209,15 @@ static void standard_terminate(struct event_context *ev, const char *reason) exit(0); } +/* called to set a title of a task or connection */ +static void standard_set_title(struct event_context *ev, const char *title) +{ + if (title) { + SETPROCTITLE(("%s", title)); + } else { + SETPROCTITLE((NULL)); + } +} static const struct model_ops standard_ops = { .name = "standard", @@ -191,6 +225,7 @@ static const struct model_ops standard_ops = { .accept_connection = standard_accept_connection, .new_task = standard_new_task, .terminate = standard_terminate, + .set_title = standard_set_title, }; /* |