web/startstop.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    start/stop nmbd and smbd
00004    Copyright (C) Andrew Tridgell 1998
00005    
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015    
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #include "includes.h"
00022 #include "web/swat_proto.h"
00023 #include "dynconfig.h"
00024 
00025 
00026 /** Startup smbd from web interface. */
00027 void start_smbd(void)
00028 {
00029         pstring binfile;
00030 
00031         if (geteuid() != 0) return;
00032 
00033         if (fork()) {
00034                 return;
00035         }
00036 
00037         slprintf(binfile, sizeof(pstring) - 1, "%s/smbd", dyn_SBINDIR);
00038 
00039         become_daemon(True, False);
00040 
00041         execl(binfile, binfile, "-D", NULL);
00042 
00043         exit(0);
00044 }
00045 
00046 /* startup nmbd */
00047 void start_nmbd(void)
00048 {
00049         pstring binfile;
00050 
00051         if (geteuid() != 0) return;
00052 
00053         if (fork()) {
00054                 return;
00055         }
00056 
00057         slprintf(binfile, sizeof(pstring) - 1, "%s/nmbd", dyn_SBINDIR);
00058         
00059         become_daemon(True, False);
00060 
00061         execl(binfile, binfile, "-D", NULL);
00062 
00063         exit(0);
00064 }
00065 
00066 /** Startup winbindd from web interface. */
00067 void start_winbindd(void)
00068 {
00069         pstring binfile;
00070 
00071         if (geteuid() != 0) return;
00072 
00073         if (fork()) {
00074                 return;
00075         }
00076 
00077         slprintf(binfile, sizeof(pstring) - 1, "%s/winbindd", dyn_SBINDIR);
00078 
00079         become_daemon(True, False);
00080 
00081         execl(binfile, binfile, NULL);
00082 
00083         exit(0);
00084 }
00085 
00086 
00087 /* stop smbd */
00088 void stop_smbd(void)
00089 {
00090         pid_t pid = pidfile_pid("smbd");
00091 
00092         if (geteuid() != 0) return;
00093 
00094         if (pid <= 0) return;
00095 
00096         kill(pid, SIGTERM);
00097 }
00098 
00099 /* stop nmbd */
00100 void stop_nmbd(void)
00101 {
00102         pid_t pid = pidfile_pid("nmbd");
00103 
00104         if (geteuid() != 0) return;
00105 
00106         if (pid <= 0) return;
00107 
00108         kill(pid, SIGTERM);
00109 }
00110 #ifdef WITH_WINBIND
00111 /* stop winbindd */
00112 void stop_winbindd(void)
00113 {
00114         pid_t pid = pidfile_pid("winbindd");
00115 
00116         if (geteuid() != 0) return;
00117 
00118         if (pid <= 0) return;
00119 
00120         kill(pid, SIGTERM);
00121 }
00122 #endif
00123 /* kill a specified process */
00124 void kill_pid(struct process_id pid)
00125 {
00126         if (geteuid() != 0) return;
00127 
00128         if (procid_to_pid(&pid) <= 0) return;
00129 
00130         kill(procid_to_pid(&pid), SIGTERM);
00131 }

Sambaに対してSat Aug 29 21:23:30 2009に生成されました。  doxygen 1.4.7