services/svc_rcinit.c

説明を見る。
00001 /* 
00002  *  Unix SMB/CIFS implementation.
00003  *  Service Control API Implementation
00004  *  Copyright (C) Gerald Carter                   2005.
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 
00023 /*********************************************************************
00024 *********************************************************************/
00025 
00026 static WERROR rcinit_stop( const char *service, SERVICE_STATUS *status )
00027 {
00028         pstring command;
00029         int ret, fd;
00030         
00031         pstr_sprintf( command, "%s/%s/%s stop", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service );
00032         
00033         /* we've already performed the access check when the service was opened */
00034         
00035         become_root();
00036         ret = smbrun( command , &fd );
00037         unbecome_root();
00038         
00039         DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
00040         close(fd);
00041         
00042         ZERO_STRUCTP( status );
00043         status->type = 0x0020;
00044         status->state = (ret == 0 ) ? 0x0001 : 0x0004;
00045         status->controls_accepted = 0x0005;
00046 
00047         return ( ret == 0 ) ? WERR_OK : WERR_ACCESS_DENIED;
00048 }
00049 
00050 /*********************************************************************
00051 *********************************************************************/
00052 
00053 static WERROR rcinit_start( const char *service )
00054 {
00055         pstring command;
00056         int ret, fd;
00057         
00058         pstr_sprintf( command, "%s/%s/%s start", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service );
00059         
00060         /* we've already performed the access check when the service was opened */
00061         
00062         become_root();
00063         ret = smbrun( command , &fd );
00064         unbecome_root();
00065         
00066         DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
00067         close(fd);      
00068 
00069         return ( ret == 0 ) ? WERR_OK : WERR_ACCESS_DENIED;
00070 }
00071 
00072 /*********************************************************************
00073 *********************************************************************/
00074 
00075 static WERROR rcinit_status( const char *service, SERVICE_STATUS *status )
00076 {
00077         pstring command;
00078         int ret, fd;
00079         
00080         pstr_sprintf( command, "%s/%s/%s status", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service );
00081         
00082         /* we've already performed the access check when the service was opened */
00083         /* assume as return code of 0 means that the service is ok.  Anything else
00084            is STOPPED */
00085         
00086         become_root();
00087         ret = smbrun( command , &fd );
00088         unbecome_root();
00089         
00090         DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
00091         close(fd);
00092         
00093         ZERO_STRUCTP( status );
00094         status->type = 0x0020;
00095         status->state = (ret == 0 ) ? 0x0004 : 0x0001;
00096         status->controls_accepted = 0x0005;
00097 
00098         return WERR_OK;
00099 }
00100 
00101 /*********************************************************************
00102 *********************************************************************/
00103 
00104 /* struct for svcctl control to manipulate rcinit service */
00105 
00106 SERVICE_CONTROL_OPS rcinit_svc_ops = {
00107         rcinit_stop,
00108         rcinit_start,
00109         rcinit_status
00110 };

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