#include "includes.h"
#include "web/swat_proto.h"
#include "dynconfig.h"
void start_smbd(void)
{
pstring binfile;
if (geteuid() != 0) return;
if (fork()) {
return;
}
slprintf(binfile, sizeof(pstring) - 1, "%s/smbd", dyn_SBINDIR);
become_daemon(True);
execl(binfile, binfile, "-D", NULL);
exit(0);
}
void start_nmbd(void)
{
pstring binfile;
if (geteuid() != 0) return;
if (fork()) {
return;
}
slprintf(binfile, sizeof(pstring) - 1, "%s/nmbd", dyn_SBINDIR);
become_daemon(True);
execl(binfile, binfile, "-D", NULL);
exit(0);
}
void start_winbindd(void)
{
pstring binfile;
if (geteuid() != 0) return;
if (fork()) {
return;
}
slprintf(binfile, sizeof(pstring) - 1, "%s/winbindd", dyn_SBINDIR);
become_daemon(True);
execl(binfile, binfile, NULL);
exit(0);
}
void stop_smbd(void)
{
pid_t pid = pidfile_pid("smbd");
if (geteuid() != 0) return;
if (pid <= 0) return;
kill(pid, SIGTERM);
}
void stop_nmbd(void)
{
pid_t pid = pidfile_pid("nmbd");
if (geteuid() != 0) return;
if (pid <= 0) return;
kill(pid, SIGTERM);
}
#ifdef WITH_WINBIND
void stop_winbindd(void)
{
pid_t pid = pidfile_pid("winbindd");
if (geteuid() != 0) return;
if (pid <= 0) return;
kill(pid, SIGTERM);
}
#endif
void kill_pid(pid_t pid)
{
if (geteuid() != 0) return;
if (pid <= 0) return;
kill(pid, SIGTERM);
}