X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=etc%2Fafpd%2Fquota.c;h=6903a21610ab421bbd3560569ae0e3cb30131d45;hp=4953d798f06d43c7e34da0b337a0bb80036533b2;hb=4111aba41c36a99bfd7eb7e987b24314735cdd10;hpb=a83e8197c7b8af45f8d56acf158920c03698bfc6 diff --git a/etc/afpd/quota.c b/etc/afpd/quota.c index 4953d798..6903a216 100644 --- a/etc/afpd/quota.c +++ b/etc/afpd/quota.c @@ -25,6 +25,7 @@ #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; @@ -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 */