diff options
author | Jeremy Allison <jra@samba.org> | 2012-06-28 13:41:19 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-06-29 03:57:45 +0200 |
commit | 485787f0dfa64bbada7c971ec44f04a1095b4229 (patch) | |
tree | 143ec6a9ac9e7d26e90e41f5110791419a9d29ee /lib/util | |
parent | 821bd95156e8cc6d843aecb0a27d4a08761b7dac (diff) | |
download | samba-485787f0dfa64bbada7c971ec44f04a1095b4229.tar.gz samba-485787f0dfa64bbada7c971ec44f04a1095b4229.tar.bz2 samba-485787f0dfa64bbada7c971ec44f04a1095b4229.zip |
Move back to using per-thread credentials on Linux. Fixes the glibc native AIO lost wakeup problem.
See this post:
https://lists.samba.org/archive/samba-technical/2012-June/085101.html
for details.
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Jun 29 03:57:45 CEST 2012 on sn-devel-104
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/setid.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/lib/util/setid.c b/lib/util/setid.c index 8b2efc076f..66c06397ee 100644 --- a/lib/util/setid.c +++ b/lib/util/setid.c @@ -70,10 +70,22 @@ int samba_setgroups(size_t setlen, const gid_t *gidset); #include "../lib/util/setid.h" +#if defined(USE_LINUX_THREAD_CREDENTIALS) +#if defined(HAVE_SYSCALL_H) +#include <syscall.h> +#endif + +#if defined(HAVE_SYS_SYSCALL_H) +#include <sys/syscall.h> +#endif +#endif + /* All the setXX[ug]id functions and setgroups Samba uses. */ int samba_setresuid(uid_t ruid, uid_t euid, uid_t suid) { -#if defined(HAVE_SETRESUID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + return syscall(SYS_setresuid, ruid, euid, suid); +#elif defined(HAVE_SETRESUID) return setresuid(ruid, euid, suid); #else errno = ENOSYS; @@ -83,7 +95,9 @@ int samba_setresuid(uid_t ruid, uid_t euid, uid_t suid) int samba_setresgid(gid_t rgid, gid_t egid, gid_t sgid) { -#if defined(HAVE_SETRESGID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + return syscall(SYS_setresgid, rgid, egid, sgid); +#elif defined(HAVE_SETRESGID) return setresgid(rgid, egid, sgid); #else errno = ENOSYS; @@ -93,7 +107,9 @@ int samba_setresgid(gid_t rgid, gid_t egid, gid_t sgid) int samba_setreuid(uid_t ruid, uid_t euid) { -#if defined(HAVE_SETREUID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + return syscall(SYS_setreuid, ruid, euid); +#elif defined(HAVE_SETREUID) return setreuid(ruid, euid); #else errno = ENOSYS; @@ -103,7 +119,9 @@ int samba_setreuid(uid_t ruid, uid_t euid) int samba_setregid(gid_t rgid, gid_t egid) { -#if defined(HAVE_SETREGID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + return syscall(SYS_setregid, rgid, egid); +#elif defined(HAVE_SETREGID) return setregid(rgid, egid); #else errno = ENOSYS; @@ -113,7 +131,10 @@ int samba_setregid(gid_t rgid, gid_t egid) int samba_seteuid(uid_t euid) { -#if defined(HAVE_SETEUID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + /* seteuid is not a separate system call. */ + return syscall(SYS_setresuid, -1, euid, -1); +#elif defined(HAVE_SETEUID) return seteuid(euid); #else errno = ENOSYS; @@ -123,7 +144,10 @@ int samba_seteuid(uid_t euid) int samba_setegid(gid_t egid) { -#if defined(HAVE_SETEGID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + /* setegid is not a separate system call. */ + return syscall(SYS_setresgid, -1, egid, -1); +#elif defined(HAVE_SETEGID) return setegid(egid); #else errno = ENOSYS; @@ -133,7 +157,9 @@ int samba_setegid(gid_t egid) int samba_setuid(uid_t uid) { -#if defined(HAVE_SETUID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + return syscall(SYS_setuid, uid); +#elif defined(HAVE_SETUID) return setuid(uid); #else errno = ENOSYS; @@ -143,7 +169,9 @@ int samba_setuid(uid_t uid) int samba_setgid(gid_t gid) { -#if defined(HAVE_SETGID) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + return syscall(SYS_setgid, gid); +#elif defined(HAVE_SETGID) return setgid(gid); #else errno = ENOSYS; @@ -156,6 +184,7 @@ int samba_setuidx(int flags, uid_t uid) #if defined(HAVE_SETUIDX) return setuidx(flags, uid); #else + /* USE_LINUX_THREAD_CREDENTIALS doesn't have this. */ errno = ENOSYS; return -1; #endif @@ -166,6 +195,7 @@ int samba_setgidx(int flags, gid_t gid) #if defined(HAVE_SETGIDX) return setgidx(flags, gid); #else + /* USE_LINUX_THREAD_CREDENTIALS doesn't have this. */ errno = ENOSYS; return -1; #endif @@ -173,7 +203,9 @@ int samba_setgidx(int flags, gid_t gid) int samba_setgroups(size_t setlen, const gid_t *gidset) { -#if defined(HAVE_SETGROUPS) +#if defined(USE_LINUX_THREAD_CREDENTIALS) + return syscall(SYS_setgroups, setlen, gidset); +#elif defined(HAVE_SETGROUPS) return setgroups(setlen, gidset); #else errno = ENOSYS; |