Changeset 171 for branches/samba-3.0


Ignore:
Timestamp:
Apr 14, 2009, 4:33:28 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Fix for Ticket #53 and #54

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/web/startstop.c

    r1 r171  
    1818   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    1919*/
    20 
    2120#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
    2232#include "web/swat_proto.h"
    2333#include "dynconfig.h"
    24 
    2534
    2635/** Startup smbd from web interface. */
     
    2837{
    2938        pstring binfile;
    30 
    3139        if (geteuid() != 0) return;
    3240
     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                     
    3344        if (fork()) {
    3445                return;
    3546        }
    36 
    3747        slprintf(binfile, sizeof(pstring) - 1, "%s/smbd", dyn_SBINDIR);
    38 
    3948        become_daemon(True, False);
    40 
    4149        execl(binfile, binfile, "-D", NULL);
    42 
    4350        exit(0);
     51#endif
    4452}
    45 
    4653/* startup nmbd */
    4754void start_nmbd(void)
    4855{
    4956        pstring binfile;
    50 
    5157        if (geteuid() != 0) return;
    5258
     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   
    5362        if (fork()) {
    5463                return;
    5564        }
    56 
    5765        slprintf(binfile, sizeof(pstring) - 1, "%s/nmbd", dyn_SBINDIR);
    5866       
    5967        become_daemon(True, False);
    60 
    6168        execl(binfile, binfile, "-D", NULL);
    62 
    6369        exit(0);
     70#endif
    6471}
    65 
    6672/** Startup winbindd from web interface. */
    6773void start_winbindd(void)
     
    7177        if (geteuid() != 0) return;
    7278
     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
    7383        if (fork()) {
    7484                return;
    7585        }
    76 
    7786        slprintf(binfile, sizeof(pstring) - 1, "%s/winbindd", dyn_SBINDIR);
    78 
    7987        become_daemon(True, False);
    80 
    8188        execl(binfile, binfile, NULL);
    82 
    8389        exit(0);
     90#endif
    8491}
    85 
    8692
    8793/* stop smbd */
     
    8995{
    9096        pid_t pid = pidfile_pid("smbd");
    91 
    9297        if (geteuid() != 0) return;
    9398
     99#ifdef __OS2__  /* we do it a bit nicer */
     100        if (smbd_running()) {
     101        pstring binfile;
     102        SWAT_HELPER(stop, smbd)
     103        }
     104#else
    94105        if (pid <= 0) return;
    95106
    96107        kill(pid, SIGTERM);
     108#endif
    97109}
    98 
    99110/* stop nmbd */
    100111void stop_nmbd(void)
    101112{
    102113        pid_t pid = pidfile_pid("nmbd");
     114        if (geteuid() != 0) return;     
    103115
    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
    106122        if (pid <= 0) return;
    107123
    108124        kill(pid, SIGTERM);
     125#endif
    109126}
     127
    110128#ifdef WITH_WINBIND
    111129/* stop winbindd */
     
    116134        if (geteuid() != 0) return;
    117135
     136#ifdef __OS2__  /* we do it a bit nicer */
     137        if (winbindd_running()) {
     138        pstring binfile;
     139        SWAT_HELPER(stop, winbindd)
     140        }
     141#else
    118142        if (pid <= 0) return;
    119143
    120144        kill(pid, SIGTERM);
     145#endif
    121146}
    122147#endif
     
    125150{
    126151        if (geteuid() != 0) return;
    127 
    128         if (procid_to_pid(&pid) <= 0) return;
     152 
     153    if (procid_to_pid(&pid) <= 0) return;
    129154
    130155        kill(procid_to_pid(&pid), SIGTERM);
Note: See TracChangeset for help on using the changeset viewer.