summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-07-28 23:16:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:24 -0500
commit981350a03c14ca526b703925c65d61b70b1f38cb (patch)
treedc574dd2dacdef07a50d9bd228db0537f7c6fe71 /source3
parent5b3d559aa808210b1d6d61bc9bb9088b06e4c9c8 (diff)
downloadsamba-981350a03c14ca526b703925c65d61b70b1f38cb.tar.gz
samba-981350a03c14ca526b703925c65d61b70b1f38cb.tar.bz2
samba-981350a03c14ca526b703925c65d61b70b1f38cb.zip
r17296: Replace the understandable parts of the quota
code with become_root_uid_only()/unbecome_root_uid_only() pairs. This code needs working on..... Jeremy. (This used to be commit 0661d4e26614180636bc57de0c48adf8b9ce7a21)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/quotas.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c
index d6ba7bc2d5..35bb94bcef 100644
--- a/source3/smbd/quotas.c
+++ b/source3/smbd/quotas.c
@@ -238,8 +238,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
if (!found)
return(False);
- save_re_uid();
- set_effective_uid(0);
+ become_root_uid_only();
if (strcmp(mnt->mnt_type, "xfs")==0) {
r=get_smb_linux_xfs_quota(mnt->mnt_fsname, euser_id, egrp_id, &D);
@@ -252,7 +251,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
}
}
- restore_re_uid();
+ unbecome_root_uid_only();
/* Use softlimit to determine disk space, except when it has been exceeded */
*bsize = D.bsize;
@@ -654,21 +653,20 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
if ( ! found )
return(False) ;
- save_re_uid();
- set_effective_uid(0);
+ become_root_uid_only();
#if defined(SUNOS5)
if ( strcmp( mnt.mnt_fstype, "nfs" ) == 0) {
BOOL retval;
DEBUG(5,("disk_quotas: looking for mountpath (NFS) \"%s\"\n", mnt.mnt_special));
retval = nfs_quotas(mnt.mnt_special, euser_id, bsize, dfree, dsize);
- restore_re_uid();
+ unbecome_root_uid_only();
return retval;
}
DEBUG(5,("disk_quotas: looking for quotas file \"%s\"\n", name));
if((file=sys_open(name, O_RDONLY,0))<0) {
- restore_re_uid();
+ unbecome_root_uid_only();
return(False);
}
command.op = Q_GETQUOTA;
@@ -681,7 +679,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
ret = quotactl(Q_GETQUOTA, name, euser_id, &D);
#endif
- restore_re_uid();
+ unbecome_root_uid_only();
if (ret < 0) {
DEBUG(5,("disk_quotas ioctl (Solaris) failed. Error = %s\n", strerror(errno) ));
@@ -841,8 +839,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
}
euser_id=geteuid();
- save_re_uid();
- set_effective_uid(0);
+ become_root_uid_only();
/* Use softlimit to determine disk space, except when it has been exceeded */
@@ -852,7 +849,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
{
r=quotactl (Q_GETQUOTA, mnt->mnt_fsname, euser_id, (caddr_t) &D);
- restore_re_uid();
+ unbecome_root_uid_only();
if (r==-1)
return(False);
@@ -883,7 +880,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
{
r=quotactl (Q_XGETQUOTA, mnt->mnt_fsname, euser_id, (caddr_t) &F);
- restore_re_uid();
+ unbecome_root_uid_only();
if (r==-1)
{
@@ -917,7 +914,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
}
else
{
- restore_re_uid();
+ unbecome_root_uid_only();
return(False);
}
@@ -1181,14 +1178,13 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
return False;
#endif
- save_re_uid();
- set_effective_uid(0);
+ become_root_uid_only();
#if defined(__FreeBSD__) || defined(__DragonFly__)
if (strcmp(mnts[i].f_fstypename,"nfs") == 0) {
BOOL retval;
retval = nfs_quotas(mnts[i].f_mntfromname,euser_id,bsize,dfree,dsize);
- restore_re_uid();
+ unbecome_root_uid_only();
return retval;
}
#endif
@@ -1202,7 +1198,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB
r= quotactl(path,QCMD(Q_GETQUOTA,GRPQUOTA),egrp_id,(char *) &D);
}
- restore_re_uid();
+ unbecome_root_uid_only();
}
#elif defined(AIX)
/* AIX has both USER and GROUP quotas: