summaryrefslogtreecommitdiff
path: root/source/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
commit16fd4337f79ce33f91050c96c4a566221c5d9126 (patch)
tree35f06822ded7d84e504e664e2d83d902a9730ac5 /source/locking/locking.c
parented606bc7d4e6fb1091e527ea70a3e950d50a1db4 (diff)
downloadsamba-16fd4337f79ce33f91050c96c4a566221c5d9126.tar.gz
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)
Diffstat (limited to 'source/locking/locking.c')
-rw-r--r--source/locking/locking.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 04c198afeac..5071121bed0 100644
--- a/source/locking/locking.c
+++ b/source/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;
}