diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index a9645927dcfb..e3524967d8da 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1222,8 +1222,7 @@ TUNABLE_INT("security.bsd.suser_enabled", &suser_enabled); /* * Test whether the specified credentials imply "super-user" privilege. - * Return 0 or EPERM. The flag argument is currently used only to - * specify jail interaction. + * Return 0 or EPERM. */ int suser_cred(struct ucred *cred, int flag) @@ -1231,7 +1230,7 @@ suser_cred(struct ucred *cred, int flag) if (!suser_enabled) return (EPERM); - if (cred->cr_uid != 0) + if (((flag & SUSER_RUID) ? cred->cr_ruid : cred->cr_uid) != 0) return (EPERM); if (jailed(cred) && !(flag & PRISON_ROOT)) return (EPERM); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 77603ad4a251..f8f4ac31cf55 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -217,6 +217,7 @@ void cpu_stopprofclock(void); /* flags for suser() and suser_cred() */ #define PRISON_ROOT 1 +#define SUSER_RUID 2 int suser(struct thread *td); int suser_cred(struct ucred *cred, int flag);