Changeset 171 for branches/samba-3.0
- Timestamp:
- Apr 14, 2009, 4:33:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/web/startstop.c
r1 r171 18 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 19 */ 20 21 20 #include "includes.h" 21 #ifdef __OS2__ 22 #include "process.h" 23 #define exists(filename) (!access(filename, F_OK)) 24 #define SWAT_HELPER(WHAT, WHO) slprintf(binfile, sizeof(pstring) - 1, "swathelp.cmd"); \ 25 int rc; \ 26 rc=spawnl(P_NOWAIT, binfile, binfile, #WHAT, #WHO, NULL); 27 // printf("BINDIR: %s",dyn_BINDIR); \ 28 // printf("SBINDIR: %s",dyn_SBINDIR); \ 29 // printf("SWATDIR: %s",dyn_SWATDIR); \ 30 // printf(#WHAT " " #WHO " pid:%i", rc); 31 #endif 22 32 #include "web/swat_proto.h" 23 33 #include "dynconfig.h" 24 25 34 26 35 /** Startup smbd from web interface. */ … … 28 37 { 29 38 pstring binfile; 30 31 39 if (geteuid() != 0) return; 32 40 41 #ifdef __OS2__ /* because fork() in our libc ends all child when parent is closed we use spawn() */ 42 SWAT_HELPER(start, smbd) 43 #else 33 44 if (fork()) { 34 45 return; 35 46 } 36 37 47 slprintf(binfile, sizeof(pstring) - 1, "%s/smbd", dyn_SBINDIR); 38 39 48 become_daemon(True, False); 40 41 49 execl(binfile, binfile, "-D", NULL); 42 43 50 exit(0); 51 #endif 44 52 } 45 46 53 /* startup nmbd */ 47 54 void start_nmbd(void) 48 55 { 49 56 pstring binfile; 50 51 57 if (geteuid() != 0) return; 52 58 59 #ifdef __OS2__ /* because fork() in our libc ends all child when parent is closed we use spawn() */ 60 SWAT_HELPER(start, nmbd) 61 #else 53 62 if (fork()) { 54 63 return; 55 64 } 56 57 65 slprintf(binfile, sizeof(pstring) - 1, "%s/nmbd", dyn_SBINDIR); 58 66 59 67 become_daemon(True, False); 60 61 68 execl(binfile, binfile, "-D", NULL); 62 63 69 exit(0); 70 #endif 64 71 } 65 66 72 /** Startup winbindd from web interface. */ 67 73 void start_winbindd(void) … … 71 77 if (geteuid() != 0) return; 72 78 79 #ifdef __OS2__ /* because fork() in our libc ends all child when parent is closed we use spawn() */ 80 SWAT_HELPER(start, winbindd) 81 #else 82 73 83 if (fork()) { 74 84 return; 75 85 } 76 77 86 slprintf(binfile, sizeof(pstring) - 1, "%s/winbindd", dyn_SBINDIR); 78 79 87 become_daemon(True, False); 80 81 88 execl(binfile, binfile, NULL); 82 83 89 exit(0); 90 #endif 84 91 } 85 86 92 87 93 /* stop smbd */ … … 89 95 { 90 96 pid_t pid = pidfile_pid("smbd"); 91 92 97 if (geteuid() != 0) return; 93 98 99 #ifdef __OS2__ /* we do it a bit nicer */ 100 if (smbd_running()) { 101 pstring binfile; 102 SWAT_HELPER(stop, smbd) 103 } 104 #else 94 105 if (pid <= 0) return; 95 106 96 107 kill(pid, SIGTERM); 108 #endif 97 109 } 98 99 110 /* stop nmbd */ 100 111 void stop_nmbd(void) 101 112 { 102 113 pid_t pid = pidfile_pid("nmbd"); 114 if (geteuid() != 0) return; 103 115 104 if (geteuid() != 0) return; 105 116 #ifdef __OS2__ /* we do it a bit nicer */ 117 if (nmbd_running()) { 118 pstring binfile; 119 SWAT_HELPER(stop, nmbd) 120 } 121 #else 106 122 if (pid <= 0) return; 107 123 108 124 kill(pid, SIGTERM); 125 #endif 109 126 } 127 110 128 #ifdef WITH_WINBIND 111 129 /* stop winbindd */ … … 116 134 if (geteuid() != 0) return; 117 135 136 #ifdef __OS2__ /* we do it a bit nicer */ 137 if (winbindd_running()) { 138 pstring binfile; 139 SWAT_HELPER(stop, winbindd) 140 } 141 #else 118 142 if (pid <= 0) return; 119 143 120 144 kill(pid, SIGTERM); 145 #endif 121 146 } 122 147 #endif … … 125 150 { 126 151 if (geteuid() != 0) return; 127 128 152 153 if (procid_to_pid(&pid) <= 0) return; 129 154 130 155 kill(procid_to_pid(&pid), SIGTERM);
Note:
See TracChangeset
for help on using the changeset viewer.