]> git.armaanb.net Git - opendoas.git/blob - libopenbsd/setresuid.c
Add compatibility functions from OpenBSD.
[opendoas.git] / libopenbsd / setresuid.c
1 /* Copyright 2015 Nathan Holstein */
2
3 #include <sys/types.h>
4 #include <errno.h>
5 #include <unistd.h>
6
7 /* I don't think we can actually mimic the right semantics? */
8 int
9 setresuid(uid_t ruid, uid_t euid, uid_t suid)
10 {
11         int ret;
12         if (suid != ruid) {
13                 errno = EPERM;
14                 return -1;
15         }
16         if ((ret = setuid(ruid)) != 0)
17                 return ret;
18         if ((ret = seteuid(euid)) != 0)
19                 return ret;
20         return 0;
21 }
22