summaryrefslogtreecommitdiff
path: root/source3/locking/locking.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1997-10-15 21:53:59 +0000
committerJeremy Allison <jra@samba.org>1997-10-15 21:53:59 +0000
commit359d42c08d012b3e1c1bc6ac1071f8add706ba35 (patch)
tree459ec199cb796f91443349e3b4c67e6fa7264d8f /source3/locking/locking.c
parentd83845241381fb6ff86890d1d43c3d3bf6522a2b (diff)
downloadsamba-359d42c08d012b3e1c1bc6ac1071f8add706ba35.tar.gz
samba-359d42c08d012b3e1c1bc6ac1071f8add706ba35.tar.bz2
samba-359d42c08d012b3e1c1bc6ac1071f8add706ba35.zip
ipc.c: Adding Andrews become_root code to the main branch.
locking.c: Adding Andrews become_root code to the main branch. pipes.c: Fixing the close_file issue. proto.h: The usual. reply.c: Move smb_pass into NTDOMAIN defined code. Fixing the close_file issue. server.c: Fixing the close_file issue. trans2.c: Fixing the close_file issue. uid.c: Adding Andrews become_root code to the main branch. Jeremy (jallison@whistle.com) (This used to be commit 16fd4337f79ce33f91050c96c4a566221c5d9126)
Diffstat (limited to 'source3/locking/locking.c')
-rw-r--r--source3/locking/locking.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 04c198afea..5071121bed 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -729,10 +729,12 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
if(!share_name(cnum, dev, inode, fname))
return False;
+ /* we need to do this as root */
+ become_root(False);
+
{
int old_umask;
BOOL gotlock = False;
- unbecome_user();
old_umask = umask(0);
/*
@@ -801,23 +803,13 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
*/
umask(old_umask);
- if(!become_user(cnum,Connections[cnum].vuid))
- {
- DEBUG(0,("lock_share_entry: Can't become connected user!\n"));
- close(fd);
- 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);
- ret = False;
- }
}
*ptok = (share_lock_token)fd;
+
+ /* return to our previous privilage level */
+ unbecome_root(False);
+
return ret;
}
@@ -848,27 +840,22 @@ Force a share file to be deleted.
static int delete_share_file( int cnum, char *fname )
{
- unbecome_user();
+ /* 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));
}
- DEBUG(5,("delete_share_file: Deleted share file %s\n", fname));
+ /* return to our previous privilage level */
+ unbecome_root(False);
- if(!become_user(cnum,Connections[cnum].vuid))
- {
- DEBUG(0,("delete_share_file: Can't become connected user!\n"));
- return -1;
- }
- /* We need to change directory back to the connection root. */
- if (ChDir(Connections[cnum].connectpath) != 0)
- {
- DEBUG(0,("delete_share_file: Can't change directory to %s (%s)\n",
- Connections[cnum].connectpath, strerror(errno)));
- return -1;
- }
return 0;
}