diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-10-16 11:20:57 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:56 -0500 |
commit | 645067efc69ff510612f7b63cf262cc9d60df700 (patch) | |
tree | 147c637e41ff0ebf6f5e72f8903bd41ce12c8ee5 /source4/lib | |
parent | addb2a9fd45ad4df21f22d1b712e37ff0a5affd4 (diff) | |
download | samba-645067efc69ff510612f7b63cf262cc9d60df700.tar.gz samba-645067efc69ff510612f7b63cf262cc9d60df700.tar.bz2 samba-645067efc69ff510612f7b63cf262cc9d60df700.zip |
r3004: removed some unused functions
(This used to be commit 247421ee648d1935b68a47195fe1709bb861a7d5)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/basic.mk | 1 | ||||
-rw-r--r-- | source4/lib/smbrun.c | 176 | ||||
-rw-r--r-- | source4/lib/util.c | 120 |
3 files changed, 0 insertions, 297 deletions
diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index f8bb46a95d..addef77a20 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -17,7 +17,6 @@ ADD_OBJ_FILES = \ lib/time.o \ lib/genrand.o \ lib/username.o \ - lib/smbrun.o \ lib/bitmap.o \ lib/snprintf.o \ lib/dprintf.o \ diff --git a/source4/lib/smbrun.c b/source4/lib/smbrun.c deleted file mode 100644 index ab36ec6e40..0000000000 --- a/source4/lib/smbrun.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - Unix SMB/CIFS implementation. - run a command as a specified user - Copyright (C) Andrew Tridgell 1992-1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" - - -#if 1 -int smbrun(char *cmd, int *outfd) -{ - DEBUG(0,("smbrun() needs a rewrite: struct current_user is gone!\n")); - return -1; -} -#else -/**************************************************************************** -This is a utility function of smbrun(). -****************************************************************************/ -static int setup_out_fd(void) -{ - int fd; - pstring path; - - slprintf(path, sizeof(path)-1, "%s/smb.XXXXXX", tmpdir()); - - /* now create the file */ - fd = smb_mkstemp(path); - - if (fd == -1) { - DEBUG(0,("setup_out_fd: Failed to create file %s. (%s)\n", - path, strerror(errno) )); - return -1; - } - - DEBUG(10,("setup_out_fd: Created tmp file %s\n", path )); - - /* Ensure file only kept around by open fd. */ - unlink(path); - return fd; -} - -/**************************************************************************** -run a command being careful about uid/gid handling and putting the output in -outfd (or discard it if outfd is NULL). -****************************************************************************/ - -int smbrun(char *cmd, int *outfd) -{ - pid_t pid; - uid_t uid = current_user.uid; - gid_t gid = current_user.gid; - - /* - * Lose any kernel oplock capabilities we may have. - */ - oplock_set_capability(False, False); - - /* point our stdout at the file we want output to go into */ - - if (outfd && ((*outfd = setup_out_fd()) == -1)) { - return -1; - } - - /* in this method we will exec /bin/sh with the correct - arguments, after first setting stdout to point at the file */ - - /* - * We need to temporarily stop CatchChild from eating - * SIGCLD signals as it also eats the exit status code. JRA. - */ - - CatchChildLeaveStatus(); - - if ((pid=fork()) < 0) { - DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) )); - CatchChild(); - if (outfd) { - close(*outfd); - *outfd = -1; - } - return errno; - } - - if (pid) { - /* - * Parent. - */ - int status=0; - pid_t wpid; - - - /* the parent just waits for the child to exit */ - while((wpid = sys_waitpid(pid,&status,0)) < 0) { - if(errno == EINTR) { - errno = 0; - continue; - } - break; - } - - CatchChild(); - - if (wpid != pid) { - DEBUG(2,("waitpid(%d) : %s\n",(int)pid,strerror(errno))); - if (outfd) { - close(*outfd); - *outfd = -1; - } - return -1; - } - - /* Reset the seek pointer. */ - if (outfd) { - sys_lseek(*outfd, 0, SEEK_SET); - } - -#if defined(WIFEXITED) && defined(WEXITSTATUS) - if (WIFEXITED(status)) { - return WEXITSTATUS(status); - } -#endif - - return status; - } - - CatchChild(); - - /* we are in the child. we exec /bin/sh to do the work for us. we - don't directly exec the command we want because it may be a - pipeline or anything else the config file specifies */ - - /* point our stdout at the file we want output to go into */ - if (outfd) { - close(1); - if (sys_dup2(*outfd,1) != 1) { - DEBUG(2,("Failed to create stdout file descriptor\n")); - close(*outfd); - exit(80); - } - } - - /* now completely lose our privileges. This is a fairly paranoid - way of doing it, but it does work on all systems that I know of */ - - become_user_permanently(uid, gid); - - if (getuid() != uid || geteuid() != uid || - getgid() != gid || getegid() != gid) { - /* we failed to lose our privileges - do not execute - the command */ - exit(81); /* we can't print stuff at this stage, - instead use exit codes for debugging */ - } - - execl("/bin/sh","sh","-c",cmd,NULL); - - /* not reached */ - exit(82); - return 1; -} -#endif diff --git a/source4/lib/util.c b/source4/lib/util.c index fde5390127..0982694823 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -28,7 +28,6 @@ Find a suitable temporary directory. The result should be copied immediately as it may be overwritten by a subsequent call. ****************************************************************************/ - const char *tmpdir(void) { char *p; @@ -37,28 +36,10 @@ const char *tmpdir(void) return "/tmp"; } -/**************************************************************************** - Determine whether we are in the specified group. -****************************************************************************/ - -BOOL in_group(gid_t group, gid_t current_gid, int ngroups, const gid_t *groups) -{ - int i; - - if (group == current_gid) - return(True); - - for (i=0;i<ngroups;i++) - if (group == groups[i]) - return(True); - - return(False); -} /******************************************************************* Check if a file exists - call vfs_file_exist for samba files. ********************************************************************/ - BOOL file_exist(const char *fname,SMB_STRUCT_STAT *sbuf) { SMB_STRUCT_STAT st; @@ -766,107 +747,6 @@ const char *shlib_ext(void) } -/********************************************************* - Recursive routine that is called by unix_wild_match. -*********************************************************/ - -static BOOL unix_do_match(char *regexp, char *str) -{ - char *p; - - for( p = regexp; *p && *str; ) { - - switch(*p) { - case '?': - str++; - p++; - break; - - case '*': - - /* - * Look for a character matching - * the one after the '*'. - */ - p++; - if(!*p) - return True; /* Automatic match */ - while(*str) { - - while(*str && (*p != *str)) - str++; - - /* - * Patch from weidel@multichart.de. In the case of the regexp - * '*XX*' we want to ensure there are at least 2 'X' characters - * in the string after the '*' for a match to be made. - */ - - { - int matchcount=0; - - /* - * Eat all the characters that match, but count how many there were. - */ - - while(*str && (*p == *str)) { - str++; - matchcount++; - } - - /* - * Now check that if the regexp had n identical characters that - * matchcount had at least that many matches. - */ - - while ( *(p+1) && (*(p+1) == *p)) { - p++; - matchcount--; - } - - if ( matchcount <= 0 ) - return False; - } - - str--; /* We've eaten the match char after the '*' */ - - if(unix_do_match(p, str)) - return True; - - if(!*str) - return False; - else - str++; - } - return False; - - default: - if(*str != *p) - return False; - str++; - p++; - break; - } - } - - if(!*p && !*str) - return True; - - if (!*p && str[0] == '.' && str[1] == 0) - return(True); - - if (!*str && *p == '?') { - while (*p == '?') - p++; - return(!*p); - } - - if(!*str && (*p == '*' && p[1] == '\0')) - return True; - - return False; -} - void dump_data_pw(const char *msg, const uint8_t * data, size_t len) { #ifdef DEBUG_PASSWORD |