diff options
author | Jeremy Allison <jra@samba.org> | 1997-10-14 01:53:20 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1997-10-14 01:53:20 +0000 |
commit | 366ec4de30c34b30a9c2a0a0525fcfaa1a6f4bee (patch) | |
tree | c3d76b4ec46577e5f36e89842f1ede038cc413d2 | |
parent | 849875f85196c0d3461b9466785c8f00ade0ec1f (diff) | |
download | samba-366ec4de30c34b30a9c2a0a0525fcfaa1a6f4bee.tar.gz |
Updated to stop problems with become_user.
Jeremy (jallison@whistle.com)
-rw-r--r-- | source/locking/locking.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source/locking/locking.c b/source/locking/locking.c index b86ef76a2b8..db4990a7263 100644 --- a/source/locking/locking.c +++ b/source/locking/locking.c @@ -604,6 +604,7 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok { pstring fname; int fd; + int ret = True; *ptok = (share_lock_token)-1; @@ -640,6 +641,14 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666); #endif /* SECURE_SHARE_MODES */ + if(fd < 0) + { + DEBUG(0,("ERROR lock_share_entry: failed to open share file %s. Error was %s\n", + fname, strerror(errno))); + ret = False; + break; + } + /* At this point we have an open fd to the share mode file. Lock the first byte exclusively to signify a lock. */ if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False) @@ -647,7 +656,8 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok DEBUG(0,("ERROR lock_share_entry: fcntl_lock failed with %s\n", strerror(errno))); close(fd); - return False; + ret = False; + break; } /* @@ -665,25 +675,32 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok gotlock = True; } while(!gotlock); + /* + * We have to come here if any of the above calls fail + * as we don't want to return and leave ourselves running + * as root ! + */ + umask(old_umask); if(!become_user(cnum,Connections[cnum].vuid)) { DEBUG(0,("lock_share_entry: Can't become connected user!\n")); close(fd); - return False; + ret = False; } + /* We need to change directory back to the connection root. */ if (ChDir(Connections[cnum].connectpath) != 0) { DEBUG(0,("lock_share_entry: Can't change directory to %s (%s)\n", Connections[cnum].connectpath, strerror(errno))); close(fd); - return False; + ret = False; } } *ptok = (share_lock_token)fd; - return True; + return ret; } /******************************************************************* |