1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

Added patch from Stephen Roylance.

This commit is contained in:
John Terpstra 0001-01-01 00:00:00 +00:00
parent 2dc12c8c64
commit 71369f9089
2 changed files with 26 additions and 26 deletions

View File

@ -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);
}

View File

@ -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("<td><input type=submit name=\"nmbd_start\" value=\"%s\"></td>\n", _("Start nmbd"));
}
d_printf("<td><input type=submit name=\"nmbd_restart\" value=\"%s\"></td>\n", _("Restart nmbd"));
#ifndef WITH_WINBIND
if (nr_running >= 1) {
/* stop, restart all */
d_printf("</tr><tr><td></td><td></td>\n");
d_printf("<td><input type=submit name=\"all_stop\" value=\"%s\"></td>\n", _("Stop All"));
d_printf("<td><input type=submit name=\"all_restart\" value=\"%s\"></td>\n", _("Restart All"));
}
else if (nr_running == 0) {
/* start all */
d_printf("</tr><tr><td></td><td></td>\n");
d_printf("<td><input type=submit name=\"all_start\" value=\"%s\"></td>\n", _("Start All"));
}
#endif
d_printf("<td><input type=submit name=\"nmbd_restart\" value=\"%s\"></td>\n", _("Restart nmbd"));
}
d_printf("</tr>\n");
@ -361,22 +366,23 @@ void status_page(void)
d_printf("<td><input type=submit name=\"winbindd_start\" value=\"%s\"></td>\n", _("Start winbindd"));
}
d_printf("<td><input type=submit name=\"winbindd_restart\" value=\"%s\"></td>\n", _("Restart winbindd"));
}
d_printf("</tr>\n");
#endif
if (geteuid() == 0) {
d_printf("<tr><td></td><td></td>\n");
if (nr_running >= 1) {
/* stop, restart all */
d_printf("</tr><tr><td></td><td></td>\n");
d_printf("<td><input type=submit name=\"all_stop\" value=\"%s\"></td>\n", _("Stop All"));
d_printf("<td><input type=submit name=\"all_restart\" value=\"%s\"></td>\n", _("Restart All"));
}
else if (nr_running == 0) {
/* start all */
d_printf("</tr><tr><td></td><td></td>\n");
d_printf("<td><input type=submit name=\"all_start\" value=\"%s\"></td>\n", _("Start All"));
}
d_printf("</tr>\n");
}
d_printf("</tr>\n");
#endif
d_printf("</table>\n");
fflush(stdout);