From 5b4ee77a5fefe3a22a98519a1dceaf9981a14e8d Mon Sep 17 00:00:00 2001 From: John Terpstra Date: Thu, 24 Apr 2003 02:34:27 +0000 Subject: Added patch from Stephen Roylance. (This used to be commit 308e3848622de0da7f1b73369c0429ac54d672ef) --- source3/web/startstop.c | 6 ------ source3/web/statuspage.c | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'source3') diff --git a/source3/web/startstop.c b/source3/web/startstop.c index c6babff954..93e8650c2b 100644 --- a/source3/web/startstop.c +++ b/source3/web/startstop.c @@ -22,8 +22,6 @@ #include "../web/swat_proto.h" #include "dynconfig.h" -/** Need to wait for daemons to startup */ -#define SLEEP_TIME 3 /** Startup smbd from web interface. */ void start_smbd(void) @@ -33,7 +31,6 @@ void start_smbd(void) if (geteuid() != 0) return; if (fork()) { - sleep(SLEEP_TIME); return; } @@ -54,7 +51,6 @@ void start_nmbd(void) if (geteuid() != 0) return; if (fork()) { - sleep(SLEEP_TIME); return; } @@ -75,7 +71,6 @@ void start_winbindd(void) if (geteuid() != 0) return; if (fork()) { - sleep(SLEEP_TIME); return; } @@ -133,5 +128,4 @@ void kill_pid(pid_t pid) if (pid <= 0) return; kill(pid, SIGTERM); - sleep(SLEEP_TIME); } diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index ddbe658a6c..44461232b8 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -23,6 +23,9 @@ #define PIDMAP struct PidMap +/* how long to wait for start/stops to take effect */ +#define SLEEP_TIME 3 + PIDMAP { PIDMAP *next, *prev; pid_t pid; @@ -158,6 +161,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); if (cgi_variable(buf)) { kill_pid(crec.pid); + sleep(SLEEP_TIME); } } return 0; @@ -221,48 +225,62 @@ void status_page(void) int refresh_interval=30; TDB_CONTEXT *tdb; int nr_running=0; + BOOL waitup = False; smbd_pid = pidfile_pid("smbd"); if (cgi_variable("smbd_restart") || cgi_variable("all_restart")) { stop_smbd(); start_smbd(); + waitup=True; } if (cgi_variable("smbd_start") || cgi_variable("all_start")) { start_smbd(); + waitup=True; } if (cgi_variable("smbd_stop") || cgi_variable("all_stop")) { stop_smbd(); + waitup=True; } if (cgi_variable("nmbd_restart") || cgi_variable("all_restart")) { stop_nmbd(); start_nmbd(); + waitup=True; } if (cgi_variable("nmbd_start") || cgi_variable("all_start")) { start_nmbd(); + waitup=True; } if (cgi_variable("nmbd_stop")|| cgi_variable("all_stop")) { stop_nmbd(); + waitup=True; } #ifdef WITH_WINBIND if (cgi_variable("winbindd_restart") || cgi_variable("all_restart")) { stop_winbindd(); start_winbindd(); + waitup=True; } if (cgi_variable("winbindd_start") || cgi_variable("all_start")) { start_winbindd(); + waitup=True; } if (cgi_variable("winbindd_stop") || cgi_variable("all_stop")) { stop_winbindd(); + waitup=True; } #endif + /* wait for daemons to start/stop */ + if (waitup) + sleep(SLEEP_TIME); + if (cgi_variable("autorefresh")) { autorefresh = 1; } else if (cgi_variable("norefresh")) { @@ -333,20 +351,7 @@ void status_page(void) } else { d_printf("\n", _("Start nmbd")); } - d_printf("\n", _("Restart nmbd")); -#ifndef WITH_WINBIND - if (nr_running >= 1) { - /* stop, restart all */ - d_printf("\n"); - d_printf("\n", _("Stop All")); - d_printf("\n", _("Restart All")); - } - else if (nr_running == 0) { - /* start all */ - d_printf("\n"); - d_printf("\n", _("Start All")); - } -#endif + d_printf("\n", _("Restart nmbd")); } d_printf("\n"); @@ -361,22 +366,23 @@ void status_page(void) d_printf("\n", _("Start winbindd")); } d_printf("\n", _("Restart winbindd")); + } + d_printf("\n"); +#endif + + if (geteuid() == 0) { + d_printf("\n"); if (nr_running >= 1) { /* stop, restart all */ - d_printf("\n"); d_printf("\n", _("Stop All")); d_printf("\n", _("Restart All")); } else if (nr_running == 0) { /* start all */ - d_printf("\n"); d_printf("\n", _("Start All")); } - + d_printf("\n"); } - d_printf("\n"); -#endif - d_printf("\n"); fflush(stdout); -- cgit