* 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.
This commit is contained in:
Pavel Roskin 2003-08-29 23:40:37 +00:00
parent 94e14aacfb
commit 3bff4a829d
8 changed files with 12 additions and 389 deletions

View File

@ -1,3 +1,13 @@
2003-08-29 Pavel Roskin <proski@gnu.org>
* 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 <sav@bcs.zp.ua>
* direntry.c (vfs_s_dump): Commented out.

View File

@ -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

View File

@ -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 <sys/types.h>
#include <sys/capability.h>
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([

View File

@ -305,10 +305,6 @@
#include <poll.h>
#endif
#ifdef HAVE_SYS_CAPABILITY_H
#include <sys/capability.h>
#endif
#if defined(HAVE_RPC_RPC_H)
/*
* Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.

View File

@ -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);

View File

@ -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 */

View File

@ -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 <unistd.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <grp.h>
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<ngroups;i++)
igroups[i] = 0x42424242;
ngroups = getgroups(ngroups,(gid_t *)igroups);
if (igroups[0] == 0x42424242)
ngroups = 0;
if (ngroups == 0) {
printf("WARNING: can't determine getgroups return type\n");
exit(1);
}
cgroups = (char *)igroups;
if (ngroups == 1 &&
cgroups[2] == 0x42 && cgroups[3] == 0x42) {
fprintf(stderr,"getgroups returns gid_t\n");
exit(1);
}
for (i=0;i<ngroups;i++) {
if (igroups[i] == 0x42424242) {
fprintf(stderr,"getgroups returns gid_t\n");
exit(1);
}
}
exit(0);
}

View File

@ -1,4 +0,0 @@
main()
{
exit(0);
}