summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1997-10-14 00:16:37 +0000
committerJeremy Allison <jra@samba.org>1997-10-14 00:16:37 +0000
commitcdd01aa4dd2660aca01db7b5c22f52a1f506896d (patch)
tree52d937fc74007eec307e4aed49c6d67f0b5b2ab8 /source3
parent23c448b25004ef3b3a8e10cc3eb01bc13d66ca4e (diff)
downloadsamba-cdd01aa4dd2660aca01db7b5c22f52a1f506896d.tar.gz
samba-cdd01aa4dd2660aca01db7b5c22f52a1f506896d.tar.bz2
samba-cdd01aa4dd2660aca01db7b5c22f52a1f506896d.zip
Added fixes for become_user braindamage.
Jeremy (jallison@whistle.com) (This used to be commit 08afa51f5c80f3da983781774378bc1646c431d7)
Diffstat (limited to 'source3')
-rw-r--r--source3/locking/locking.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 639bc7be0b..4af37fdc47 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -722,6 +722,7 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
{
pstring fname;
int fd;
+ ret = True;
*ptok = (share_lock_token)-1;
@@ -759,6 +760,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)
@@ -766,7 +775,8 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
DEBUG(0,("ERROR lock_share_entry: fcntl_lock on file %s failed with %s\n",
fname, strerror(errno)));
close(fd);
- return False;
+ ret = False;
+ break;
}
/*
@@ -784,12 +794,18 @@ 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)
@@ -797,12 +813,12 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
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;
}
/*******************************************************************