X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=etc%2Fafpd%2Fquota.c;h=614a7f95e74956a6d5881b4b35b0915cf20c3fe4;hb=9f957894d9a60f32adc56edddf72fa767ded8219;hp=4953d798f06d43c7e34da0b337a0bb80036533b2;hpb=321a0107c48da7b3fbf895a2b32244174c1ff39c;p=netatalk.git diff --git a/etc/afpd/quota.c b/etc/afpd/quota.c index 4953d798..614a7f95 100644 --- a/etc/afpd/quota.c +++ b/etc/afpd/quota.c @@ -1,5 +1,4 @@ /* - * $Id: quota.c,v 1.35 2010-04-03 07:11:35 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -25,6 +24,8 @@ #include #include #include +#include +#include #include "auth.h" #include "volume.h" @@ -47,16 +48,15 @@ getfreespace(const AFPObj *obj, struct vol *vol, VolSpace *bfree, VolSpace *btot return -1; } - if ( seteuid( getuid() ) != 0 ) { - LOG(log_info, logtype_afpd, "seteuid(): %s", - strerror(errno)); - return -1; - } + become_root(); + if ((retq = getfsquota(obj, vol, ufsq, uid, classq)) < 0) { LOG(log_info, logtype_afpd, "getfsquota(%s, %s): %s", vol->v_path, classq, strerror(errno)); } - seteuid( uid ); + + unbecome_root(); + if (retq < 1) return retq; @@ -370,7 +370,7 @@ mountp( char *file, int *nfs) dev_t devno; static struct mnttab mnt; - if ( lstat( file, &sb ) < 0 ) { + if (stat(file, &sb) < 0) { return( NULL ); } devno = sb.st_dev; @@ -381,14 +381,14 @@ mountp( char *file, int *nfs) while ( getmntent( mtab, &mnt ) == 0 ) { /* local fs */ - if ( (lstat( mnt.mnt_special, &sb ) == 0) && (devno == sb.st_rdev)) { + if ( (stat( mnt.mnt_special, &sb ) == 0) && (devno == sb.st_rdev)) { fclose( mtab ); return mnt.mnt_mountp; } /* check for nfs. we probably should use * strcmp(mnt.mnt_fstype, MNTTYPE_NFS), but that's not as fast. */ - if ((lstat(mnt.mnt_mountp, &sb) == 0) && (devno == sb.st_dev) && + if ((stat(mnt.mnt_mountp, &sb) == 0) && (devno == sb.st_dev) && strchr(mnt.mnt_special, ':')) { *nfs = 1; fclose( mtab ); @@ -458,7 +458,7 @@ special(char *file, int *nfs) struct mntent *mnt; int found=0; - if ( lstat( file, &sb ) < 0 ) { + if (stat(file, &sb) < 0 ) { return( NULL ); } devno = sb.st_dev; @@ -469,14 +469,14 @@ special(char *file, int *nfs) while (( mnt = getmntent( mtab )) != NULL ) { /* check for local fs */ - if ( (lstat( mnt->mnt_fsname, &sb ) == 0) && devno == sb.st_rdev) { + if ( (stat( mnt->mnt_fsname, &sb ) == 0) && devno == sb.st_rdev) { found = 1; break; } /* check for an nfs mount entry. the alternative is to use * strcmp(mnt->mnt_type, MNTTYPE_NFS) instead of the strchr. */ - if ((lstat(mnt->mnt_dir, &sb) == 0) && (devno == sb.st_dev) && + if ((stat(mnt->mnt_dir, &sb) == 0) && (devno == sb.st_dev) && strchr(mnt->mnt_fsname, ':')) { *nfs = 1; found = 1; @@ -541,29 +541,19 @@ static int getfsquota(const AFPObj *obj, struct vol *vol, const int uid, struct #endif /* TRU64 */ #ifdef BSD4_4 - if ( seteuid( getuid() ) == 0 ) { + become_root(); if ( quotactl( vol->v_path, QCMD(Q_GETQUOTA,USRQUOTA), uid, (char *)dq ) != 0 ) { /* try group quotas */ if (obj->ngroups >= 1) { if ( quotactl(vol->v_path, QCMD(Q_GETQUOTA, GRPQUOTA), obj->groups[0], (char *) &dqg) != 0 ) { - seteuid( uid ); + unbecome_root(); return( AFPERR_PARAM ); } } } - seteuid( uid ); - } - -#elif defined(TRU64) - if ( seteuid( getuid() ) == 0 ) { - if ( quotactl( vol->v_path, QCMD(Q_GETQUOTA, USRQUOTA), - uid, (char *)dq ) != 0 ) { - seteuid( uid ); - return ( AFPERR_PARAM ); - } - seteuid( uid ); + unbecome_root(); } #else /* BSD4_4 */