LCOV - code coverage report
Current view: top level - source3/services - svc_rcinit.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 0 8 0.0 %
Date: 2024-02-28 12:06:22 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  Service Control API Implementation
       4             :  *  Copyright (C) Gerald Carter                   2005.
       5             :  *
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *
      11             :  *  This program is distributed in the hope that it will be useful,
      12             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  *  GNU General Public License for more details.
      15             :  *
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #include "includes.h"
      21             : #include "services/services.h"
      22             : 
      23             : /*********************************************************************
      24             : *********************************************************************/
      25             : 
      26           0 : static WERROR rcinit_stop( const char *service, struct SERVICE_STATUS *status )
      27             : {
      28           0 :         int ret = -1;
      29             : 
      30             :         /*
      31             :          * Disabled due to security concerns and unknown use in the
      32             :          * field -- vl@samba.org
      33             :          */
      34             : #if 0
      35             :         char *command = NULL;
      36             :         int fd;
      37             : 
      38             :         if (asprintf(&command, "%s/%s/%s stop",
      39             :                                 get_dyn_MODULESDIR(), SVCCTL_SCRIPT_DIR, service) < 0) {
      40             :                 return WERR_NOT_ENOUGH_MEMORY;
      41             :         }
      42             : 
      43             :         /* we've already performed the access check when the service was opened */
      44             : 
      45             :         become_root();
      46             :         ret = smbrun(command, &fd, NULL);
      47             :         unbecome_root();
      48             : 
      49             :         DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
      50             :         close(fd);
      51             : 
      52             :         SAFE_FREE(command);
      53             : 
      54             :         ZERO_STRUCTP( status );
      55             : 
      56             :         status->type                 = SERVICE_TYPE_WIN32_SHARE_PROCESS;
      57             :         status->state                        = (ret == 0 ) ? SVCCTL_STOPPED : SVCCTL_RUNNING;
      58             :         status->controls_accepted    = SVCCTL_ACCEPT_STOP |
      59             :                                           SVCCTL_ACCEPT_SHUTDOWN;
      60             : #endif
      61           0 :         return ( ret == 0 ) ? WERR_OK : WERR_ACCESS_DENIED;
      62             : }
      63             : 
      64             : /*********************************************************************
      65             : *********************************************************************/
      66             : 
      67           0 : static WERROR rcinit_start( const char *service )
      68             : {
      69           0 :         int ret = -1;
      70             :         /*
      71             :          * Disabled due to security concerns and unknown use in the
      72             :          * field -- vl@samba.org
      73             :          */
      74             : #if 0
      75             :         char *command = NULL;
      76             :         int fd;
      77             : 
      78             :         if (asprintf(&command, "%s/%s/%s start",
      79             :                                 get_dyn_MODULESDIR(), SVCCTL_SCRIPT_DIR, service) < 0) {
      80             :                 return WERR_NOT_ENOUGH_MEMORY;
      81             :         }
      82             : 
      83             :         /* we've already performed the access check when the service was opened */
      84             : 
      85             :         become_root();
      86             :         ret = smbrun(command, &fd, NULL);
      87             :         unbecome_root();
      88             : 
      89             :         DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
      90             :         close(fd);
      91             : 
      92             :         SAFE_FREE(command);
      93             : #endif
      94           0 :         return ( ret == 0 ) ? WERR_OK : WERR_ACCESS_DENIED;
      95             : }
      96             : 
      97             : /*********************************************************************
      98             : *********************************************************************/
      99             : 
     100           0 : static WERROR rcinit_status( const char *service, struct SERVICE_STATUS *status )
     101             : {
     102             :         /*
     103             :          * Disabled due to security concerns and unknown use in the
     104             :          * field -- vl@samba.org
     105             :          */
     106             : #if 0
     107             :         char *command = NULL;
     108             :         int ret, fd;
     109             : 
     110             :         if (asprintf(&command, "%s/%s/%s status",
     111             :                                 get_dyn_MODULESDIR(), SVCCTL_SCRIPT_DIR, service) < 0) {
     112             :                 return WERR_NOT_ENOUGH_MEMORY;
     113             :         }
     114             : 
     115             :         /* we've already performed the access check when the service was opened */
     116             :         /* assume as return code of 0 means that the service is ok.  Anything else
     117             :            is STOPPED */
     118             : 
     119             :         become_root();
     120             :         ret = smbrun(command, &fd, NULL);
     121             :         unbecome_root();
     122             : 
     123             :         DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
     124             :         close(fd);
     125             : 
     126             :         SAFE_FREE(command);
     127             : 
     128             :         ZERO_STRUCTP( status );
     129             : 
     130             :         status->type                 = SERVICE_TYPE_WIN32_SHARE_PROCESS;
     131             :         status->state                        = (ret == 0 ) ? SVCCTL_RUNNING : SVCCTL_STOPPED;
     132             :         status->controls_accepted    = SVCCTL_ACCEPT_STOP |
     133             :                                           SVCCTL_ACCEPT_SHUTDOWN;
     134             : 
     135             :         return WERR_OK;
     136             : #else
     137           0 :         return WERR_ACCESS_DENIED;
     138             : #endif
     139             : }
     140             : 
     141             : /*********************************************************************
     142             : *********************************************************************/
     143             : 
     144             : /* struct for svcctl control to manipulate rcinit service */
     145             : 
     146             : SERVICE_CONTROL_OPS rcinit_svc_ops = {
     147             :         rcinit_stop,
     148             :         rcinit_start,
     149             :         rcinit_status
     150             : };

Generated by: LCOV version 1.14