mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Add support for MSG_SMB_CONF_UPDATED and MSG_SHUTDOWN to all daemons (smbd, nmbd, winbindd). Reviewed by jerry and tridge.
(This used to be commit 02c5e2fc6f
)
This commit is contained in:
parent
cf8628e585
commit
8c4be2bbc9
@ -254,6 +254,13 @@
|
||||
sent to smbd.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>reload-config</term>
|
||||
<listitem><para>Force daemon to reload smb.conf configuration file. Can be sent
|
||||
to <constant>smbd</constant>, <constant>nmbd</constant>, or <constant>winbindd</constant>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -298,6 +298,28 @@ static BOOL reload_nmbd_services(BOOL test)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**************************************************************************** **
|
||||
* React on 'smbcontrol nmbd reload-config' in the same way as to SIGHUP
|
||||
* We use buf here to return BOOL result to process() when reload_interfaces()
|
||||
* detects that there are no subnets.
|
||||
**************************************************************************** */
|
||||
static void msg_reload_nmbd_services(int msg_type, pid_t src, void *buf, size_t len)
|
||||
{
|
||||
write_browse_list( 0, True );
|
||||
dump_all_namelists();
|
||||
reload_nmbd_services( True );
|
||||
reopen_logs();
|
||||
|
||||
if(buf) {
|
||||
/* We were called from process() */
|
||||
/* If reload_interfaces() returned True */
|
||||
/* we need to shutdown if there are no subnets... */
|
||||
/* pass this info back to process() */
|
||||
*((BOOL*)buf) = reload_interfaces(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************** **
|
||||
The main select loop.
|
||||
**************************************************************************** */
|
||||
@ -305,6 +327,7 @@ static BOOL reload_nmbd_services(BOOL test)
|
||||
static void process(void)
|
||||
{
|
||||
BOOL run_election;
|
||||
BOOL no_subnets;
|
||||
|
||||
while( True ) {
|
||||
time_t t = time(NULL);
|
||||
@ -513,11 +536,8 @@ static void process(void)
|
||||
|
||||
if(reload_after_sighup) {
|
||||
DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) );
|
||||
write_browse_list( 0, True );
|
||||
dump_all_namelists();
|
||||
reload_nmbd_services( True );
|
||||
reopen_logs();
|
||||
if(reload_interfaces(0))
|
||||
msg_reload_nmbd_services(MSG_SMB_CONF_UPDATED, (pid_t) 0, (void*) &no_subnets, 0);
|
||||
if(no_subnets)
|
||||
return;
|
||||
reload_after_sighup = 0;
|
||||
}
|
||||
@ -696,6 +716,7 @@ static BOOL open_sockets(BOOL isdaemon, int port)
|
||||
message_register(MSG_FORCE_ELECTION, nmbd_message_election);
|
||||
message_register(MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry);
|
||||
message_register(MSG_SHUTDOWN, nmbd_terminate);
|
||||
message_register(MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services);
|
||||
|
||||
DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
|
||||
|
||||
|
@ -66,6 +66,7 @@ static BOOL reload_services_file(BOOL test)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
#if DUMP_CORE
|
||||
|
||||
/**************************************************************************** **
|
||||
@ -201,6 +202,20 @@ static void sighup_handler(int signum)
|
||||
sys_select_signal();
|
||||
}
|
||||
|
||||
/* React on 'smbcontrol winbindd reload-config' in the same way as on SIGHUP*/
|
||||
static void msg_reload_services(int msg_type, pid_t src, void *buf, size_t len)
|
||||
{
|
||||
/* Flush various caches */
|
||||
flush_caches();
|
||||
reload_services_file(True);
|
||||
}
|
||||
|
||||
/* React on 'smbcontrol winbindd shutdown' in the same way as on SIGTERM*/
|
||||
static void msg_shutdown(int msg_type, pid_t src, void *buf, size_t len)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
struct dispatch_table {
|
||||
enum winbindd_cmd cmd;
|
||||
enum winbindd_result (*fn)(struct winbindd_cli_state *state);
|
||||
@ -746,11 +761,8 @@ static void process_loop(void)
|
||||
if (do_sighup) {
|
||||
|
||||
DEBUG(3, ("got SIGHUP\n"));
|
||||
|
||||
/* Flush various caches */
|
||||
|
||||
flush_caches();
|
||||
reload_services_file(True);
|
||||
msg_reload_services(MSG_SMB_CONF_UPDATED, (pid_t) 0, NULL, 0);
|
||||
do_sighup = False;
|
||||
}
|
||||
|
||||
@ -919,6 +931,12 @@ int main(int argc, char **argv)
|
||||
DEBUG(0, ("unable to initialise messaging system\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* React on 'smbcontrol winbindd reload-config' in the same way
|
||||
as to SIGHUP signal */
|
||||
message_register(MSG_SMB_CONF_UPDATED, msg_reload_services);
|
||||
message_register(MSG_SHUTDOWN, msg_shutdown);
|
||||
|
||||
poptFreeContext(pc);
|
||||
|
||||
netsamlogon_cache_init(); /* Non-critical */
|
||||
|
@ -553,6 +553,16 @@ static BOOL do_drvupgrade(const pid_t pid, const int argc, const char **argv)
|
||||
pid, MSG_DEBUG, argv[1], strlen(argv[1]) + 1, False);
|
||||
}
|
||||
|
||||
static BOOL do_reload_config(const pid_t pid, const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
fprintf(stderr, "Usage: smbcontrol <dest> reload-config\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
return send_message(pid, MSG_SMB_CONF_UPDATED, NULL, 0, False);
|
||||
}
|
||||
|
||||
/* A list of message type supported */
|
||||
|
||||
static const struct {
|
||||
@ -576,6 +586,7 @@ static const struct {
|
||||
{ "dmalloc-log-changed", do_dmalloc_changed, "" },
|
||||
{ "shutdown", do_shutdown, "Shut down daemon" },
|
||||
{ "drvupgrade", do_drvupgrade, "Notify a printer driver has changed" },
|
||||
{ "reload-config", do_reload_config, "Force smbd or winbindd to reload config file"},
|
||||
{ "noop", do_noop, "Do nothing" },
|
||||
{ NULL }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user