diff options
author | Jeremy Allison <jra@samba.org> | 1997-10-17 23:08:07 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1997-10-17 23:08:07 +0000 |
commit | c336a2f08183f63031b0a08b2111669bc36a5f30 (patch) | |
tree | e6773bb1bbbde2c829a55ec608f270233f8a925f /source3/locking | |
parent | a0a28db75365d974ee05aee9dd4fde1ffc3db72c (diff) | |
download | samba-c336a2f08183f63031b0a08b2111669bc36a5f30.tar.gz samba-c336a2f08183f63031b0a08b2111669bc36a5f30.tar.bz2 samba-c336a2f08183f63031b0a08b2111669bc36a5f30.zip |
.cvsignore: Added make_smbcodepage
interface.c: Added is_local_net().
locking.c: Added Fix for zero length share files from Gerald Werner <wernerg@mfldclin.edu>
plus a race condition fix for the fix.
nameannounce.c: Made function static.
namedbresp.c: extern int ClientDGRAM removed - not used.
namedbserver.c: extern int ClientDGRAM removed - not used.
namedbsubnet.c: Added code to make sockets per subnet.
namepacket.c: Added code to read from all sockets & filter.
nameresp.c: extern int ClientDGRAM removed - not used.
nameserv.c: Indentation tidyup :-).
nameserv.h: Added sockets to struct subnet.
nameservresp.c: Improved debug message.
nmbd.c: Changed to terminte on listen_for_packets exiting.
nmbsync.c: extern int ClientDGRAM & ClientNMB removed - not used.
proto.h: The usual.
util.c: Fixed debug message.
Jeremy (jallison@whistle.com)
(This used to be commit 6904c2de080b2a9702800e9e4126386ced20569d)
Diffstat (limited to 'source3/locking')
-rw-r--r-- | source3/locking/locking.c | 75 |
1 files changed, 50 insertions, 25 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 5071121bed..bbc0c0033f 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -716,6 +716,31 @@ static BOOL share_name(int cnum, uint32 dev, uint32 inode, char *name) } /******************************************************************* +Force a share file to be deleted. +********************************************************************/ + +static int delete_share_file( int cnum, char *fname ) +{ + /* the share file could be owned by anyone, so do this as root */ + become_root(False); + + if(unlink(fname) != 0) + { + DEBUG(0,("delete_share_file: Can't delete share file %s (%s)\n", + fname, strerror(errno))); + } + else + { + DEBUG(5,("delete_share_file: Deleted share file %s\n", fname)); + } + + /* return to our previous privilage level */ + unbecome_root(False); + + return 0; +} + +/******************************************************************* lock a share mode file. ******************************************************************/ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok) @@ -820,6 +845,31 @@ BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token tok { int fd = (int)token; int ret = True; + struct stat sb; + pstring fname; + + /* Fix for zero length share files from + Gerald Werner <wernerg@mfldclin.edu> */ + + share_name(cnum, dev, inode, fname); + + /* get the share mode file size */ + if(fstat((int)token, &sb) != 0) + { + DEBUG(0,("ERROR: unlock_share_entry: Failed to do stat on share file %s (%s)\n", + fname, strerror(errno))); + sb.st_size = 1; + ret = False; + } + + /* If the file was zero length, we must delete before + doing the unlock to avoid a race condition (see + the code in lock_share_mode_entry for details. + */ + + /* remove the share file if zero length */ + if(sb.st_size == 0) + delete_share_file(cnum, fname); /* token is the fd of the open share mode file. */ /* Unlock the first byte. */ @@ -835,31 +885,6 @@ BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token tok } /******************************************************************* -Force a share file to be deleted. -********************************************************************/ - -static int delete_share_file( int cnum, char *fname ) -{ - /* the share file could be owned by anyone, so do this as root */ - become_root(False); - - if(unlink(fname) != 0) - { - DEBUG(0,("delete_share_file: Can't delete share file %s (%s)\n", - fname, strerror(errno))); - } - else - { - DEBUG(5,("delete_share_file: Deleted share file %s\n", fname)); - } - - /* return to our previous privilage level */ - unbecome_root(False); - - return 0; -} - -/******************************************************************* Read a share file into a buffer. ********************************************************************/ |