summaryrefslogtreecommitdiffstats
path: root/source3/nmbd/nmbd.c
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2014-03-26 11:34:56 +0200
committerJeremy Allison <jra@samba.org>2014-04-23 02:29:08 +0200
commit6771c23aa06d824028c26eafedab7d4fb1711d4f (patch)
tree62bc10b63c1b7b8597e0982a42057557ad79bb85 /source3/nmbd/nmbd.c
parent02a3b598a5294f74886531156646e55067ac0251 (diff)
downloadsamba-6771c23aa06d824028c26eafedab7d4fb1711d4f.tar.gz
samba-6771c23aa06d824028c26eafedab7d4fb1711d4f.tar.xz
samba-6771c23aa06d824028c26eafedab7d4fb1711d4f.zip
nmbd: use exit_daemon() to report status to systemd
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10517 Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/nmbd/nmbd.c')
-rw-r--r--source3/nmbd/nmbd.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index c75f3b1063..500ba85bee 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -975,16 +975,12 @@ static bool open_sockets(bool isdaemon, int port)
ok = directory_create_or_exist(lp_lock_directory(), geteuid(), 0755);
if (!ok) {
- DEBUG(0, ("Failed to create directory %s for lock files - %s\n",
- lp_lock_directory(), strerror(errno)));
- exit(1);
+ exit_daemon("Failed to create directory for lock files, check 'lock directory'", errno);
}
ok = directory_create_or_exist(lp_pid_directory(), geteuid(), 0755);
if (!ok) {
- DEBUG(0, ("Failed to create directory %s for pid files - %s\n",
- lp_pid_directory(), strerror(errno)));
- exit(1);
+ exit_daemon("Failed to create directory for pid files, check 'pid directory'", errno);
}
pidfile_create(lp_pid_directory(), "nmbd");
@@ -993,8 +989,7 @@ static bool open_sockets(bool isdaemon, int port)
false);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("reinit_after_fork() failed\n"));
- exit(1);
+ exit_daemon("reinit_after_fork() failed", map_errno_from_nt_status(status));
}
/*
@@ -1004,16 +999,15 @@ static bool open_sockets(bool isdaemon, int port)
*/
status = init_before_fork();
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("init_before_fork failed: %s\n", nt_errstr(status)));
- exit(1);
+ exit_daemon(nt_errstr(status), map_errno_from_nt_status(status));
}
if (!nmbd_setup_sig_term_handler(msg))
- exit(1);
+ exit_daemon("NMBD failed to setup signal handler", EINVAL);
if (!nmbd_setup_stdin_handler(msg, !Fork))
- exit(1);
+ exit_daemon("NMBD failed to setup stdin handler", EINVAL);
if (!nmbd_setup_sig_hup_handler(msg))
- exit(1);
+ exit_daemon("NMBD failed to setup SIGHUP handler", EINVAL);
/* get broadcast messages */
@@ -1021,8 +1015,7 @@ static bool open_sockets(bool isdaemon, int port)
FLAG_MSG_GENERAL |
FLAG_MSG_NMBD |
FLAG_MSG_DBWRAP)) {
- DEBUG(1, ("Could not register myself in serverid.tdb\n"));
- exit(1);
+ exit_daemon("Could not register NMBD process in serverid.tdb", EACCES);
}
messaging_register(msg, NULL, MSG_FORCE_ELECTION,
@@ -1053,9 +1046,8 @@ static bool open_sockets(bool isdaemon, int port)
/* Create an nmbd subnet record for each of the above. */
if( False == create_subnets() ) {
- DEBUG(0,("ERROR: Failed when creating subnet lists. Exiting.\n"));
kill_async_dns_child();
- exit(1);
+ exit_daemon("NMBD failed when creating subnet lists", EACCES);
}
/* Load in any static local names. */
@@ -1067,9 +1059,8 @@ static bool open_sockets(bool isdaemon, int port)
/* If we are acting as a WINS server, initialise data structures. */
if( !initialise_wins() ) {
- DEBUG( 0, ( "nmbd: Failed when initialising WINS server.\n" ) );
kill_async_dns_child();
- exit(1);
+ exit_daemon( "NMBD failed when initialising WINS server.", EACCES);
}
/*
@@ -1081,21 +1072,19 @@ static bool open_sockets(bool isdaemon, int port)
*/
if( False == register_my_workgroup_and_names() ) {
- DEBUG(0,("ERROR: Failed when creating my my workgroup. Exiting.\n"));
kill_async_dns_child();
- exit(1);
+ exit_daemon( "NMBD failed when creating my workgroup.", EACCES);
}
if (!initialize_nmbd_proxy_logon()) {
- DEBUG(0,("ERROR: Failed setup nmbd_proxy_logon.\n"));
kill_async_dns_child();
- exit(1);
+ exit_daemon( "NMBD failed to setup nmbd_proxy_logon.", EACCES);
}
if (!nmbd_init_packet_server()) {
kill_async_dns_child();
- exit(1);
- }
+ exit_daemon( "NMBD failed to setup packet server.", EACCES);
+ }
if (is_daemon && !opt_interactive) {
daemon_ready("nmbd");