setuid(2) buggy or bad docs
PATCH 1/1 setuid(2) buggy or bad docs
setuid(2) differs from the OpenBSD setuid(2) in that -EPERM is returned by the syscall even if the euid of the process matches the uid passed to it.
Either I am non compos or the thing is very wrong. The docs (man-pages-1.35) say
ERRORS
EPERM The user is not the super-user, and uid does not
match the effective or saved user ID of the calling process.
The following untested patch changes the kernel to match the documentated behaviour.
kernel/sys.c +3 -1
@@ -603,7 +603,9 @@ asmlinkage long sys_setuid(uid_t uid)if (uid != old_ruid &&set_user (uid, old_euid != uid) <0 )return -EAGAIN ; new_suid = uid; - }else if ((uid != current->uid) && (uid != new_suid)) + }else if ((uid != current->uid) + && (uid != new_suid) + && (uid != old_euid))return -EPERM ;if (old_euid != uid)
Signature · 2 lines
Summer job urgently sought due to last minute visa trouble! Please see http://ape.n3.net/cv.html