diff options
author | Jeremy Allison <jra@samba.org> | 1998-09-25 23:40:49 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-09-25 23:40:49 +0000 |
commit | 5f7ee360567a6b4e1a6f43ff01da057d2998fef8 (patch) | |
tree | b8528e7d3bc30fc7b2ab191bc9235be604daf98e /source3/lib | |
parent | 14f9495e4c5ff98cd15bf18d7fbc63c1b491cfea (diff) | |
download | samba-5f7ee360567a6b4e1a6f43ff01da057d2998fef8.tar.gz samba-5f7ee360567a6b4e1a6f43ff01da057d2998fef8.tar.bz2 samba-5f7ee360567a6b4e1a6f43ff01da057d2998fef8.zip |
Makefile.in: Fixed bug with continuation line causing proto to fail.
Added $(PROGS) $(SPROGS) as targets for make clean.
acconfig.h: Added HAVE_IRIX_SPECIFIC_CAPABILITIES.
configure.in: Added sys/capability.h header check.
Added function checks for srandom random srand rand.
Added HAVE_IRIX_SPECIFIC_CAPABILITIES test.
includes.h: Added #include <sys/capability.h>.
ntdomain.h: Moved struct acct_info into here from smb.h
smb.h: Added KERNEL_OPLOCK_CAPABILITY define.
Moved enum action_type into rpcclient.h
Moved struct cli_state into client.h
Moved struct nt_client_info, struct tar_client_info, struct client_info
into rpcclient.h
lib/genrand.c: Changed to use sys_random() & friends.
lib/smbrun.c: Lose capabilities after fork.
lib/system.c: Added set_process_capability(), set_inherited_process_capability()
sys_random(), sys_srandom().
lib/util.c: Added Ander's EFBIG lock check to fcntl_lock for 64 bit access to an
32 bit mounted NFS filesystem.
nmbd/nmbd.c: Changed to use sys_random() & friends.
nmbd/nmbd_browsesync.c: Changed to use sys_random() & friends.
passdb/ldap.c: Missed one pdb_encode_acct_ctrl call.
passdb/passdb.c: Changed to Ander's code for ' ' characters.
passdb/smbpass.c: Added Ander's code to reset ACB_PWNOTREQ.
script/mkproto.awk: Added 'long' to prototypes.
smbd/chgpasswd.c: Lose capabilities after fork.
smbd/open.c: Do the mmap *after* the kernel oplock.
smbd/oplock.c: Removed stub code from kernel oplock path.
Added set_process_capability(), set_inherited_process_capability() calls.
smbd/reply.c: Initialize count = 0, offset = 0.
smbd/server.c: Added set_process_capability(), set_inherited_process_capability() calls.
tests/summary.c: Ensure we have RANDOM or RAND.
utils/smbpasswd.c: Added Ander's code to reset ACB_PWNOTREQ.
utils/torture.c: Changed to use sys_random() & friends.
Jeremy.
(This used to be commit e8be306f23963ac00b1a383ebe0cc1421529fb02)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/genrand.c | 4 | ||||
-rw-r--r-- | source3/lib/smbrun.c | 6 | ||||
-rw-r--r-- | source3/lib/system.c | 101 | ||||
-rw-r--r-- | source3/lib/util.c | 13 |
4 files changed, 122 insertions, 2 deletions
diff --git a/source3/lib/genrand.c b/source3/lib/genrand.c index c36cdd4b8c..bb1922e4f5 100644 --- a/source3/lib/genrand.c +++ b/source3/lib/genrand.c @@ -192,7 +192,7 @@ void generate_random_buffer( unsigned char *out, int len, BOOL re_seed) unsigned char *p; if(!done_reseed || re_seed) { - srandom(do_reseed(md4_buf)); + sys_srandom(do_reseed(md4_buf)); done_reseed = True; } @@ -218,7 +218,7 @@ void generate_random_buffer( unsigned char *out, int len, BOOL re_seed) memcpy(md4_buf, tmp_buf, sizeof(md4_buf)); /* XOR in output from random(). */ for(i = 0; i < 4; i++) - SIVAL(tmp_buf, i*4, (IVAL(tmp_buf, i*4) ^ (uint32)random())); + SIVAL(tmp_buf, i*4, (IVAL(tmp_buf, i*4) ^ (uint32)sys_random())); memcpy(p, tmp_buf, copy_len); p += copy_len; len -= copy_len; diff --git a/source3/lib/smbrun.c b/source3/lib/smbrun.c index d2abf0e952..86d7cf9e03 100644 --- a/source3/lib/smbrun.c +++ b/source3/lib/smbrun.c @@ -89,6 +89,12 @@ int smbrun(char *cmd,char *outfile,BOOL shared) int uid = current_user.uid; int gid = current_user.gid; + /* + * Lose any kernel oplock capabilities we may have. + */ + set_process_capability(KERNEL_OPLOCK_CAPABILITY, False); + set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY, False); + #ifndef HAVE_EXECL int ret; pstring syscmd; diff --git a/source3/lib/system.c b/source3/lib/system.c index c3d97e0350..f474633dd1 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -533,3 +533,104 @@ struct hostent *sys_gethostbyname(char *name) return(gethostbyname(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))); + return False; + } + + 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))); + return False; + } + + DEBUG(10,("set_inherited_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n")); + } +#endif + return True; +} + +/************************************************************************** + Wrapper for random(). +****************************************************************************/ + +long sys_random(void) +{ +#if defined(HAVE_RANDOM) + return (long)random(); +#elif defined(HAVE_RAND) + return (long)rand(); +#else + DEBUG(0,("Error - no random function available !\n")); + exit(1); +#endif +} + +/************************************************************************** + Wrapper for srandom(). +****************************************************************************/ + +void sys_srandom(unsigned int seed) +{ +#if defined(HAVE_SRANDOM) + srandom(seed); +#elif defined(HAVE_SRAND) + srand(seed); +#else + DEBUG(0,("Error - no srandom function available !\n")); + exit(1); +#endif +} diff --git a/source3/lib/util.c b/source3/lib/util.c index 8569881b3f..72eb1a89c3 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -4328,6 +4328,19 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) errno = 0; ret = fcntl(fd,op,&lock); + if (errno == EFBIG) + { + if( DEBUGLVL( 0 )) + { + dbgtext("fcntl_lock: WARNING: lock request at offset %.0f, length %.0f returned\n", (double)offset,(double)count); + dbgtext("a 'file too large' error. This can happen when using 64 bit lock offsets\n"); + dbgtext("on 32 bit NFS mounted file systems. Retrying with 32 bit truncated length.\n"); + } + /* 32 bit NFS file system, retry with smaller offset */ + errno = 0; + lock.l_len = count & 0xffffffff; + ret = fcntl(fd,op,&lock); + } if (errno != 0) DEBUG(3,("fcntl lock gave errno %d (%s)\n",errno,strerror(errno))); |