From 3bff4a829d11c0dfbec06bc4f84b12396d6adffe Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 29 Aug 2003 23:40:37 +0000 Subject: [PATCH] * samba/lib/system.c: Remove all unused code. * samba/include/proto.h: Remove some unused prototypes. * samba/include/includes.h: Don't include sys/capability.h, it's not needed. * samba/configure.in: Remove tests for capabilities and groups, which are unused now. Also remove the trivial test. * Makefile.am: Remove unused Samba tests. --- vfs/ChangeLog | 10 ++ vfs/Makefile.am | 4 +- vfs/samba/configure.in | 33 +---- vfs/samba/include/includes.h | 4 - vfs/samba/include/proto.h | 3 - vfs/samba/lib/system.c | 277 ----------------------------------- vfs/samba/tests/getgroups.c | 66 --------- vfs/samba/tests/trivial.c | 4 - 8 files changed, 12 insertions(+), 389 deletions(-) delete mode 100644 vfs/samba/tests/getgroups.c delete mode 100644 vfs/samba/tests/trivial.c diff --git a/vfs/ChangeLog b/vfs/ChangeLog index a743e374a..2faa5f1c4 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,13 @@ +2003-08-29 Pavel Roskin + + * samba/lib/system.c: Remove all unused code. + * samba/include/proto.h: Remove some unused prototypes. + * samba/include/includes.h: Don't include sys/capability.h, + it's not needed. + * samba/configure.in: Remove tests for capabilities and groups, + which are unused now. Also remove the trivial test. + * Makefile.am: Remove unused Samba tests. + 2003-08-29 Andrew V. Samoilov * direntry.c (vfs_s_dump): Commented out. diff --git a/vfs/Makefile.am b/vfs/Makefile.am index 828120b1a..74570ddef 100644 --- a/vfs/Makefile.am +++ b/vfs/Makefile.am @@ -164,7 +164,5 @@ SAMBA_DIST = \ param/loadparm.c \ param/params.c \ tests/README \ - tests/getgroups.c \ - tests/summary.c \ - tests/trivial.c + tests/summary.c diff --git a/vfs/samba/configure.in b/vfs/samba/configure.in index fecfaaec4..1a0e79243 100644 --- a/vfs/samba/configure.in +++ b/vfs/samba/configure.in @@ -51,7 +51,7 @@ AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h t AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h) AC_CHECK_HEADERS(netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) AC_CHECK_HEADERS(sys/security.h security/pam_appl.h) -AC_CHECK_HEADERS(stropts.h poll.h sys/capability.h syscall.h sys/syscall.h) +AC_CHECK_HEADERS(stropts.h poll.h syscall.h sys/syscall.h) AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h) AC_CHECK_SIZEOF(int) @@ -299,24 +299,6 @@ if test x"$samba_cv_HAVE_KERNEL_OPLOCKS" = x"yes"; then AC_DEFINE(HAVE_KERNEL_OPLOCKS, 1, [Define to use kernel oplock capabilities]) fi -AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[ -AC_TRY_RUN([#include -#include -main() { - cap_t cap; - if ((cap = cap_get_proc()) == NULL) - exit(1); - cap->cap_effective |= CAP_NETWORK_MGT; - cap->cap_inheritable |= CAP_NETWORK_MGT; - cap_set_proc(cap); - exit(0); -} -], -samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)]) -if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then - AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES, 1, [Define to support IRIX specific capabilities]) -fi - # # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h # This is *really* broken but some systems (DEC OSF1) do this.... JRA. @@ -388,19 +370,6 @@ if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT, 1, [Define if rpc/rpc.h defines AUTH_ERROR]) fi -AC_MSG_CHECKING([for test routines]) -AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"], - AC_MSG_RESULT(yes), - AC_MSG_ERROR([cant find test code. Aborting config]), - AC_MSG_WARN([cannot run when cross-compiling])) - -AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[ -AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"], - samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)]) -if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then - AC_DEFINE(HAVE_BROKEN_GETGROUPS, 1, [Define if getgroups() is broken]) -fi - netmask=no; AC_CACHE_CHECK([for netmask ifconf],samba_cv_HAVE_NETMASK_IFCONF,[ AC_TRY_RUN([ diff --git a/vfs/samba/include/includes.h b/vfs/samba/include/includes.h index 0b6c8d870..7da54acc7 100644 --- a/vfs/samba/include/includes.h +++ b/vfs/samba/include/includes.h @@ -305,10 +305,6 @@ #include #endif -#ifdef HAVE_SYS_CAPABILITY_H -#include -#endif - #if defined(HAVE_RPC_RPC_H) /* * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h. diff --git a/vfs/samba/include/proto.h b/vfs/samba/include/proto.h index aa7d408fe..115a9e819 100644 --- a/vfs/samba/include/proto.h +++ b/vfs/samba/include/proto.h @@ -160,15 +160,12 @@ SMB_OFF_T sys_ftell(FILE *fp); int sys_creat(const char *path, mode_t mode); int sys_open(const char *path, int oflag, mode_t mode); FILE *sys_fopen(const char *path, const char *type); -void *sys_mmap(void *addr, size_t len, int prot, int flags, int fd, SMB_OFF_T offset); SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp); int sys_waitpid(pid_t pid,int *status,int options); char *sys_getwd(char *s); int sys_chown(const char *fname,uid_t uid,gid_t gid); int sys_chroot(const char *dname); struct hostent *sys_gethostbyname(const char *name); -BOOL set_process_capability( uint32 cap_flag, BOOL enable ); -BOOL set_inherited_process_capability( uint32 cap_flag, BOOL enable ); long sys_random(void); void sys_srandom(unsigned int seed); int sys_getgroups(int setlen, gid_t *gidset); diff --git a/vfs/samba/lib/system.c b/vfs/samba/lib/system.c index d747ce0d7..99675638d 100644 --- a/vfs/samba/lib/system.c +++ b/vfs/samba/lib/system.c @@ -139,40 +139,6 @@ int sys_select(int maxfd, fd_set *fds,struct timeval *tval) #endif /* USE_POLL */ #endif /* NO_SELECT */ -/******************************************************************* - A wrapper for usleep in case we don't have one. -********************************************************************/ - -int sys_usleep(long usecs) -{ -#ifndef HAVE_USLEEP - struct timeval tval; -#endif - - /* - * We need this braindamage as the glibc usleep - * is not SPEC1170 complient... grumble... JRA. - */ - - if(usecs < 0 || usecs > 1000000) { - errno = EINVAL; - return -1; - } - -#if HAVE_USLEEP - usleep(usecs); - return 0; -#else /* HAVE_USLEEP */ - /* - * Fake it with select... - */ - tval.tv_sec = 0; - tval.tv_usec = usecs/1000; - select(0,NULL,NULL,NULL,&tval); - return 0; -#endif /* HAVE_USLEEP */ -} - /******************************************************************* A stat() wrapper that will deal with 64 bit filesizes. ********************************************************************/ @@ -182,15 +148,6 @@ int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf) return stat(fname, sbuf); } -/******************************************************************* - An fstat() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf) -{ - return fstat(fd, sbuf); -} - /******************************************************************* An lstat() wrapper that will deal with 64 bit filesizes. ********************************************************************/ @@ -200,24 +157,6 @@ int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf) return lstat(fname, sbuf); } -/******************************************************************* - An ftruncate() wrapper that will deal with 64 bit filesizes. -********************************************************************/ -#if 0 -int sys_ftruncate(int fd, SMB_OFF_T offset) -{ - return ftruncate(fd, offset); -} -#endif -/******************************************************************* - An lseek() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence) -{ - return lseek(fd, offset, whence); -} - /******************************************************************* An fseek() wrapper that will deal with 64 bit filesizes. ********************************************************************/ @@ -236,15 +175,6 @@ SMB_OFF_T sys_ftell(FILE *fp) return (SMB_OFF_T)ftell(fp); } -/******************************************************************* - A creat() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -int sys_creat(const char *path, mode_t mode) -{ - return sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); -} - /******************************************************************* An open() wrapper that will deal with 64 bit filesizes. ********************************************************************/ @@ -263,19 +193,6 @@ FILE *sys_fopen(const char *path, const char *type) return fopen(path, type); } -#if defined(HAVE_MMAP) - -/******************************************************************* - An mmap() wrapper that will deal with 64 bit filesizes. -********************************************************************/ - -void *sys_mmap(void *addr, size_t len, int prot, int flags, int fd, SMB_OFF_T offset) -{ - return mmap(addr, len, prot, flags, fd, offset); -} - -#endif /* HAVE_MMAP */ - /******************************************************************* A readdir wrapper that will deal with 64 bit filesizes. ********************************************************************/ @@ -285,19 +202,6 @@ SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp) return readdir(dirp); } -/******************************************************************* -The wait() calls vary between systems -********************************************************************/ -#if 0 -int sys_waitpid(pid_t pid,int *status,int options) -{ -#ifdef HAVE_WAITPID - return waitpid(pid,status,options); -#else /* HAVE_WAITPID */ - return wait4(pid, status, options, NULL); -#endif /* HAVE_WAITPID */ -} -#endif /******************************************************************* system wrapper for getwd ********************************************************************/ @@ -370,81 +274,6 @@ struct hostent *sys_gethostbyname(const char *name) #endif /* REDUCE_ROOT_DNS_LOOKUPS */ } - -/************************************************************************** - Try and abstract process capabilities (for systems that have them). -****************************************************************************/ - -BOOL set_process_capability( uint32 cap_flag, BOOL enable ) -{ -#if defined(HAVE_IRIX_SPECIFIC_CAPABILITIES) - if(cap_flag == KERNEL_OPLOCK_CAPABILITY) - { - cap_t cap = cap_get_proc(); - - if (cap == NULL) { - DEBUG(0,("set_process_capability: cap_get_proc failed. Error was %s\n", - strerror(errno))); - return False; - } - - if(enable) - cap->cap_effective |= CAP_NETWORK_MGT; - else - cap->cap_effective &= ~CAP_NETWORK_MGT; - - if (cap_set_proc(cap) == -1) { - DEBUG(0,("set_process_capability: cap_set_proc failed. Error was %s\n", - strerror(errno))); - cap_free(cap); - return False; - } - - cap_free(cap); - - DEBUG(10,("set_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n")); - } -#endif - return True; -} - -/************************************************************************** - Try and abstract inherited process capabilities (for systems that have them). -****************************************************************************/ - -BOOL set_inherited_process_capability( uint32 cap_flag, BOOL enable ) -{ -#if defined(HAVE_IRIX_SPECIFIC_CAPABILITIES) - if(cap_flag == KERNEL_OPLOCK_CAPABILITY) - { - cap_t cap = cap_get_proc(); - - if (cap == NULL) { - DEBUG(0,("set_inherited_process_capability: cap_get_proc failed. Error was %s\n", - strerror(errno))); - return False; - } - - if(enable) - cap->cap_inheritable |= CAP_NETWORK_MGT; - else - cap->cap_inheritable &= ~CAP_NETWORK_MGT; - - if (cap_set_proc(cap) == -1) { - DEBUG(0,("set_inherited_process_capability: cap_set_proc failed. Error was %s\n", - strerror(errno))); - cap_free(cap); - return False; - } - - cap_free(cap); - - DEBUG(10,("set_inherited_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n")); - } -#endif - return True; -} - /************************************************************************** Wrapper for random(). ****************************************************************************/ @@ -477,109 +306,3 @@ void sys_srandom(unsigned int seed) #endif } -/************************************************************************** - Wrapper for getgroups. Deals with broken (int) case. -****************************************************************************/ - -int sys_getgroups(int setlen, gid_t *gidset) -{ -#if !defined(HAVE_BROKEN_GETGROUPS) - return getgroups(setlen, gidset); -#else - - GID_T gid; - GID_T *group_list; - int i, ngroups; - - if(setlen == 0) { - return getgroups(setlen, &gid); - } - - /* - * Broken case. We need to allocate a - * GID_T array of size setlen. - */ - - if(setlen < 0) { - errno = EINVAL; - return -1; - } - - if (setlen == 0) - setlen = 1; - - if((group_list = (GID_T *)malloc(setlen * sizeof(GID_T))) == NULL) { - DEBUG(0,("sys_getgroups: Malloc fail.\n")); - return -1; - } - - if((ngroups = getgroups(setlen, group_list)) < 0) { - int saved_errno = errno; - free((char *)group_list); - errno = saved_errno; - return -1; - } - - for(i = 0; i < ngroups; i++) - gidset[i] = (gid_t)group_list[i]; - - free((char *)group_list); - return ngroups; -#endif /* HAVE_BROKEN_GETGROUPS */ -} - -#ifdef HAVE_SETGROUPS - -/************************************************************************** - Wrapper for setgroups. Deals with broken (int) case. Automatically used - if we have broken getgroups. -****************************************************************************/ - -int sys_setgroups(int setlen, gid_t *gidset) -{ -#if !defined(HAVE_BROKEN_GETGROUPS) - return setgroups(setlen, gidset); -#else - - GID_T *group_list; - int i ; - - if (setlen == 0) - return 0 ; - -#ifdef NGROUPS_MAX - if (setlen > NGROUPS_MAX) { - errno = EINVAL; - return -1; - } -#endif - - /* - * Broken case. We need to allocate a - * GID_T array of size setlen. - */ - - if (setlen == 0) - setlen = 1; - - if((group_list = (GID_T *)malloc(setlen * sizeof(GID_T))) == NULL) { - DEBUG(0,("sys_setgroups: Malloc fail.\n")); - return -1; - } - - for(i = 0; i < setlen; i++) - group_list[i] = (GID_T) gidset[i]; - - if(setgroups(setlen, group_list) != 0) { - int saved_errno = errno; - free((char *)group_list); - errno = saved_errno; - return -1; - } - - free((char *)group_list); - return 0 ; -#endif /* HAVE_BROKEN_GETGROUPS */ -} - -#endif /* HAVE_SETGROUPS */ diff --git a/vfs/samba/tests/getgroups.c b/vfs/samba/tests/getgroups.c deleted file mode 100644 index 343fd5a18..000000000 --- a/vfs/samba/tests/getgroups.c +++ /dev/null @@ -1,66 +0,0 @@ -/* this tests whether getgroups actually returns lists of integers - rather than gid_t. The test only works if the user running - the test is in at least 1 group - - The test is designed to check for those broken OSes that define - getgroups() as returning an array of gid_t but actually return a - array of ints! Ultrix is one culprit - */ - -#if defined(HAVE_UNISTD_H) -#include -#endif - -#include -#include -#include -#include - -main() -{ - int i; - int *igroups; - char *cgroups; - int grp = 0; - int ngroups = getgroups(0,&grp); - - if (sizeof(gid_t) == sizeof(int)) { - fprintf(stderr,"gid_t and int are the same size\n"); - exit(1); - } - - if (ngroups <= 0) - ngroups = 32; - - igroups = (int *)malloc(sizeof(int)*ngroups); - - for (i=0;i