uid_wrapper.git
8 years agoBump version to 1.2.1 uid_wrapper-1.2.1
Andreas Schneider [Wed, 16 Mar 2016 13:53:37 +0000 (14:53 +0100)]
Bump version to 1.2.1

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Make sure prefix is not used uninitialized
Andreas Schneider [Fri, 13 Nov 2015 12:46:24 +0000 (13:46 +0100)]
uwrap: Make sure prefix is not used uninitialized

Signed-off-by: Andreas Schneider <asn@samba.org>
8 years agodoc: Document missing options
Andreas Schneider [Tue, 3 Nov 2015 09:54:07 +0000 (10:54 +0100)]
doc: Document missing options

Signed-off-by: Andreas Schneider <asn@samba.org>
8 years agoBump version to 1.2.0 uid_wrapper-1.2.0
Andreas Schneider [Thu, 29 Oct 2015 07:21:21 +0000 (08:21 +0100)]
Bump version to 1.2.0

Signed-off-by: Andreas Schneider <asn@samba.org>
8 years agotests: Add checks for return values in test_thread_setreuid
Andreas Schneider [Thu, 29 Oct 2015 07:16:32 +0000 (08:16 +0100)]
tests: Add checks for return values in test_thread_setreuid

CID #131817

Signed-off-by: Andreas Schneider <asn@samba.org>
8 years agotests: Rename test_syscall_gid32 to test_syscall_setgroups32
Andreas Schneider [Wed, 28 Oct 2015 08:34:18 +0000 (09:34 +0100)]
tests: Rename test_syscall_gid32 to test_syscall_setgroups32

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall setregid32 test to own executable
Andreas Schneider [Wed, 28 Oct 2015 08:33:16 +0000 (09:33 +0100)]
tests: Move syscall setregid32 test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall setregid32 test to own executable
Andreas Schneider [Wed, 28 Oct 2015 08:23:23 +0000 (09:23 +0100)]
tests: Move syscall setregid32 test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall setgid32 test to own executable
Andreas Schneider [Wed, 28 Oct 2015 07:36:53 +0000 (08:36 +0100)]
tests: Move syscall setgid32 test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Rename syscall setresuid32 test and improve it
Andreas Schneider [Wed, 28 Oct 2015 07:26:32 +0000 (08:26 +0100)]
tests: Rename syscall setresuid32 test and improve it

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall setreuid32 test to own executable
Andreas Schneider [Wed, 28 Oct 2015 07:19:43 +0000 (08:19 +0100)]
tests: Move syscall setreuid32 test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall setuid32 test to own executable
Andreas Schneider [Wed, 28 Oct 2015 07:15:37 +0000 (08:15 +0100)]
tests: Move syscall setuid32 test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Fix build warning with release build
Andreas Schneider [Wed, 28 Oct 2015 07:05:11 +0000 (08:05 +0100)]
uwrap: Fix build warning with release build

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agoIgnore build and all obj* directories
Andreas Schneider [Wed, 28 Oct 2015 08:24:08 +0000 (09:24 +0100)]
Ignore build and all obj* directories

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agocmake: Run threaded tests also on BSD and Solaris
Andreas Schneider [Mon, 12 Oct 2015 16:41:16 +0000 (18:41 +0200)]
cmake: Run threaded tests also on BSD and Solaris

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Get the tests working on BSD
Andreas Schneider [Thu, 8 Oct 2015 15:03:48 +0000 (17:03 +0200)]
tests: Get the tests working on BSD

The setuid and seteuid behaviour is different to Linux and Solaris.

The setuid euid tests on BSD look like a bug?

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Rename test_gid to test_setgroups
Andreas Schneider [Fri, 9 Oct 2015 11:22:35 +0000 (13:22 +0200)]
tests: Rename test_gid to test_setgroups

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Add setresgid unprivileged user test
Andreas Schneider [Tue, 27 Oct 2015 09:42:35 +0000 (10:42 +0100)]
tests: Add setresgid unprivileged user test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move setresgid test to own executable
Andreas Schneider [Fri, 9 Oct 2015 11:21:20 +0000 (13:21 +0200)]
tests: Move setresgid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move setregid test to own executable
Andreas Schneider [Fri, 9 Oct 2015 11:10:23 +0000 (13:10 +0200)]
tests: Move setregid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move setegid test to own executable
Andreas Schneider [Fri, 9 Oct 2015 07:40:14 +0000 (09:40 +0200)]
tests: Move setegid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move setgid test to own executable
Andreas Schneider [Fri, 9 Oct 2015 07:31:10 +0000 (09:31 +0200)]
tests: Move setgid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Add new test_setuid_euid1 and test_setuid_euid2
Andreas Schneider [Thu, 8 Oct 2015 13:23:24 +0000 (15:23 +0200)]
tests: Add new test_setuid_euid1 and test_setuid_euid2

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Create a test for threaded SYS_setuid
Andreas Schneider [Tue, 27 Oct 2015 09:19:57 +0000 (10:19 +0100)]
tests: Create a test for threaded SYS_setuid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Fix test_syscall_setuid to work with privilege checks
Andreas Schneider [Tue, 27 Oct 2015 09:18:54 +0000 (10:18 +0100)]
tests: Fix test_syscall_setuid to work with privilege checks

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Create a test for threaded sync SYS_setreuid
Andreas Schneider [Wed, 23 Sep 2015 12:06:20 +0000 (14:06 +0200)]
tests: Create a test for threaded sync SYS_setreuid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Create a test for threaded SYS_setreuid
Andreas Schneider [Tue, 27 Oct 2015 09:21:26 +0000 (10:21 +0100)]
tests: Create a test for threaded SYS_setreuid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Fix test_syscall_setreuid to work with privilege checks
Andreas Schneider [Tue, 27 Oct 2015 09:20:53 +0000 (10:20 +0100)]
tests: Fix test_syscall_setreuid to work with privilege checks

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Make syscall setresuid test from test_syscall_uid
Andreas Schneider [Tue, 22 Sep 2015 15:41:04 +0000 (17:41 +0200)]
tests: Make syscall setresuid test from test_syscall_uid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall setreuid test to own executable
Andreas Schneider [Tue, 22 Sep 2015 15:33:04 +0000 (17:33 +0200)]
tests: Move syscall setreuid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Add test_getresuid out of test_uid
Andreas Schneider [Tue, 22 Sep 2015 15:21:11 +0000 (17:21 +0200)]
tests: Add test_getresuid out of test_uid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move setresuid test to own executable
Andreas Schneider [Tue, 22 Sep 2015 14:55:43 +0000 (16:55 +0200)]
tests: Move setresuid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move setreuid test to own executable
Andreas Schneider [Tue, 22 Sep 2015 12:29:49 +0000 (14:29 +0200)]
tests: Move setreuid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move seteuid test to own executable
Andreas Schneider [Tue, 22 Sep 2015 12:21:17 +0000 (14:21 +0200)]
tests: Move seteuid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move setuid test to own executable
Andreas Schneider [Tue, 22 Sep 2015 12:17:28 +0000 (14:17 +0200)]
tests: Move setuid test to own executable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agocmake: Always set UID_WRAPPER_ROOT=1 for tests
Andreas Schneider [Fri, 18 Sep 2015 14:23:17 +0000 (16:23 +0200)]
cmake: Always set UID_WRAPPER_ROOT=1 for tests

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Add the EINVAL check to setegid()
Andreas Schneider [Fri, 9 Oct 2015 07:14:34 +0000 (09:14 +0200)]
uwrap: Add the EINVAL check to setegid()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Allow setgid calls only for privileged users
Andreas Schneider [Fri, 9 Oct 2015 07:17:16 +0000 (09:17 +0200)]
uwrap: Allow setgid calls only for privileged users

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Allow setregid calls only for privileged users
Andreas Schneider [Fri, 9 Oct 2015 07:13:27 +0000 (09:13 +0200)]
uwrap: Allow setregid calls only for privileged users

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Allow setresgid calls only for privileged users
Andreas Schneider [Fri, 9 Oct 2015 07:08:21 +0000 (09:08 +0200)]
uwrap: Allow setresgid calls only for privileged users

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Move the EINVAL check down in seteuid()
Andreas Schneider [Thu, 8 Oct 2015 14:52:00 +0000 (16:52 +0200)]
uwrap: Move the EINVAL check down in seteuid()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Allow setuid calls only for privileged users
Andreas Schneider [Thu, 8 Oct 2015 14:55:01 +0000 (16:55 +0200)]
uwrap: Allow setuid calls only for privileged users

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Allow setreuid calls only for privileged users
Andreas Schneider [Thu, 8 Oct 2015 14:50:01 +0000 (16:50 +0200)]
uwrap: Allow setreuid calls only for privileged users

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Allow setresuid calls only for privileged users
Andreas Schneider [Thu, 8 Oct 2015 14:46:27 +0000 (16:46 +0200)]
uwrap: Allow setresuid calls only for privileged users

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Fix a possible null pointer dereference
Andreas Schneider [Tue, 20 Oct 2015 13:06:02 +0000 (15:06 +0200)]
uwrap: Fix a possible null pointer dereference

If uid_wrapper is loaded but not enabled (UID_WRAPPER environment
variable not set), then we dereference a NULL pointer while forking.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Improve debug output
Andreas Schneider [Tue, 22 Sep 2015 15:11:57 +0000 (17:11 +0200)]
uwrap: Improve debug output

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agouwrap: Fix debug line in uwrap_init()
Andreas Schneider [Tue, 22 Sep 2015 15:06:01 +0000 (17:06 +0200)]
uwrap: Fix debug line in uwrap_init()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agoBump version to 1.1.1 uid_wrapper-1.1.1
Andreas Schneider [Thu, 20 Aug 2015 08:20:31 +0000 (10:20 +0200)]
Bump version to 1.1.1

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agodoc: Make the manpage reproducible
Andreas Schneider [Tue, 18 Aug 2015 10:32:03 +0000 (12:32 +0200)]
doc: Make the manpage reproducible

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
8 years agotests: Fix tests on Solaris
Andreas Schneider [Tue, 18 Aug 2015 08:10:41 +0000 (10:10 +0200)]
tests: Fix tests on Solaris

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
8 years agouwrap: Removed double newline
Andreas Schneider [Mon, 17 Aug 2015 08:43:55 +0000 (10:43 +0200)]
uwrap: Removed double newline

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Add 32bit syscall gid tests
Andreas Schneider [Fri, 14 Aug 2015 07:04:13 +0000 (09:04 +0200)]
tests: Add 32bit syscall gid tests

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Improve syscall gid tests
Andreas Schneider [Fri, 14 Aug 2015 07:01:02 +0000 (09:01 +0200)]
tests: Improve syscall gid tests

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Add 32bit syscall uid tests
Andreas Schneider [Fri, 14 Aug 2015 06:52:08 +0000 (08:52 +0200)]
tests: Add 32bit syscall uid tests

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Improve syscall uid tests
Andreas Schneider [Fri, 14 Aug 2015 06:43:55 +0000 (08:43 +0200)]
tests: Improve syscall uid tests

The plan is to have a 32bit version compiled dependent on the support
for it.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Rename testsuite to test_syscall_gid
Andreas Schneider [Fri, 14 Aug 2015 06:27:14 +0000 (08:27 +0200)]
tests: Rename testsuite to test_syscall_gid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall uid tests to own test
Andreas Schneider [Fri, 14 Aug 2015 06:26:17 +0000 (08:26 +0200)]
tests: Move syscall uid tests to own test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move syscall test to own test
Andreas Schneider [Fri, 14 Aug 2015 06:20:57 +0000 (08:20 +0200)]
tests: Move syscall test to own test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move set(re)gid function to own test
Andreas Schneider [Fri, 14 Aug 2015 06:17:34 +0000 (08:17 +0200)]
tests: Move set(re)gid function to own test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Move set(re)uid function to own test
Andreas Schneider [Fri, 14 Aug 2015 06:11:58 +0000 (08:11 +0200)]
tests: Move set(re)uid function to own test

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agocmake: Do not optimize the code by default
Andreas Schneider [Wed, 12 Aug 2015 08:21:36 +0000 (10:21 +0200)]
cmake: Do not optimize the code by default

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 years agotests: Add test_uwrap_syscall_setresuid()
Andreas Schneider [Fri, 31 Jul 2015 12:25:21 +0000 (14:25 +0200)]
tests: Add test_uwrap_syscall_setresuid()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
8 years agotests: Fix syscall detection
Andreas Schneider [Fri, 31 Jul 2015 12:11:45 +0000 (14:11 +0200)]
tests: Fix syscall detection

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
8 years agotests: Add test for syscall SYS_setresgid
Andreas Schneider [Fri, 31 Jul 2015 12:07:20 +0000 (14:07 +0200)]
tests: Add test for syscall SYS_setresgid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
8 years agotests: Update to new cmocka test runner
Andreas Schneider [Fri, 31 Jul 2015 12:03:19 +0000 (14:03 +0200)]
tests: Update to new cmocka test runner

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
8 years agouwrap: Fix build if getres(uid|gid) are not available.
Andreas Schneider [Fri, 23 Jan 2015 15:01:49 +0000 (16:01 +0100)]
uwrap: Fix build if getres(uid|gid) are not available.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
9 years agocmake: Drop test results via https.
Andreas Schneider [Wed, 25 Feb 2015 10:21:19 +0000 (11:21 +0100)]
cmake: Drop test results via https.

Signed-off-by: Andreas Schneider <asn@samba.org>
9 years agoBump version to 1.1.0. uid_wrapper-1.1.0
Andreas Schneider [Mon, 19 Jan 2015 16:06:10 +0000 (17:06 +0100)]
Bump version to 1.1.0.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
9 years agouwrap: Make sure we leave if the id is NULL.
Andreas Schneider [Thu, 8 Jan 2015 09:10:52 +0000 (10:10 +0100)]
uwrap: Make sure we leave if the id is NULL.

CID #97616

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Add new test_thread_create_thread_setgid.
Robin Hack [Fri, 5 Dec 2014 09:51:15 +0000 (10:51 +0100)]
tests: Add new test_thread_create_thread_setgid.

Test aims case where thread change uid/gid and then create new thread.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Support scenario where threads fork or creates threads.
Robin Hack [Tue, 21 Oct 2014 06:55:56 +0000 (08:55 +0200)]
uwrap: Support scenario where threads fork or creates threads.

When fork() is called here there is no need to disable uwrap as a whole.
This change disables only uwrap for the thread which called fork().

uwrap catches calls of pthread_create() and pthread_exit() functions
from libpthread library now.

Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Prepare for overload of libpthread functions.
Robin Hack [Tue, 16 Dec 2014 11:09:55 +0000 (12:09 +0100)]
uwrap: Prepare for overload of libpthread functions.

uwrap_bind_symbol are now renamed to uwrap_bind_symbol_libc
and simlilar uwrap_bind_symbol_libpthread are introduced.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL macros
Robin Hack [Tue, 16 Dec 2014 11:00:31 +0000 (12:00 +0100)]
uwrap: Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL macros

Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL which make
locking easier.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Rewrite uwrap_libc_fns struct to pass strict aliasing rules.
Robin Hack [Wed, 29 Oct 2014 09:29:27 +0000 (10:29 +0100)]
uwrap: Rewrite uwrap_libc_fns struct to pass strict aliasing rules.

Now uwrap is compiled with -O2 -fstrict-aliasing -Wstrict-aliasing=2
C compiler flags.

Also rename struct uwrap_libc_fns fns to uwrap_libc_symbols and
uwrap_load_lib_function to uwrap_bind_symbol (same for _uwrap_load_...
variant.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Fix wrong data types in syscalls switch.
Robin Hack [Thu, 16 Oct 2014 10:23:53 +0000 (12:23 +0200)]
uwrap: Fix wrong data types in syscalls switch.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Add new test_uwrap_getresuid().
Robin Hack [Tue, 21 Oct 2014 06:54:04 +0000 (08:54 +0200)]
tests: Add new test_uwrap_getresuid().

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Add support for getresuid() and getresgid() glibc/syscall.
Robin Hack [Tue, 21 Oct 2014 06:53:32 +0000 (08:53 +0200)]
uwrap: Add support for getresuid() and getresgid() glibc/syscall.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Add new test test_sync_setgroups().
Robin Hack [Tue, 21 Oct 2014 06:36:52 +0000 (08:36 +0200)]
tests: Add new test test_sync_setgroups().

This test is almost same as test_sync_setgid but covers the setgroups
function.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Extend support for (set|get)groups libc functions and syscalls.
Robin Hack [Tue, 21 Oct 2014 06:35:45 +0000 (08:35 +0200)]
uwrap: Extend support for (set|get)groups libc functions and syscalls.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Fix test_uwrap_getgroups.
Robin Hack [Wed, 15 Oct 2014 08:20:31 +0000 (10:20 +0200)]
tests: Fix test_uwrap_getgroups.

This test doesn't run on machines if there are more than one
supplementary group.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Add test_real_sync_setuid().
Robin Hack [Tue, 21 Oct 2014 06:34:16 +0000 (08:34 +0200)]
tests: Add test_real_sync_setuid().

This also extends test_syscall_setreuid().

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Extend support for syscalls called from threads or main process.
Robin Hack [Tue, 21 Oct 2014 06:33:24 +0000 (08:33 +0200)]
uwrap: Extend support for syscalls called from threads or main process.

We need to distinguish if the syscall is called from main process or
from a thread.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Small uwrap_init optimalization.
Robin Hack [Thu, 2 Oct 2014 13:45:09 +0000 (15:45 +0200)]
uwrap: Small uwrap_init optimalization.

Don't call libc_getuid/getgid function twice.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Add more authors to AUTHORS file.
Robin Hack [Wed, 1 Oct 2014 07:08:02 +0000 (09:08 +0200)]
uwrap: Add more authors to AUTHORS file.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Enable test_glibc_thread_support.c on MacOSX.
Robin Hack [Tue, 30 Sep 2014 11:58:40 +0000 (13:58 +0200)]
tests: Enable test_glibc_thread_support.c on MacOSX.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agosrc: Add support for running with address sanitizer.
Andreas Schneider [Mon, 20 Oct 2014 07:22:42 +0000 (09:22 +0200)]
src: Add support for running with address sanitizer.

It address sanitzer will complain about our hack with variable function
attributes. This disables the checking of it.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Reflect changes of uid/gid in threads to main process.
Robin Hack [Mon, 29 Sep 2014 07:53:21 +0000 (09:53 +0200)]
uwrap: Reflect changes of uid/gid in threads to main process.

When thread changes uid/gid this change must be reflected to main
process.

Syscalls changes only uid/gid of thread. Call of libc functions changes
also uid/gid of main process.

TESTS: Fix test_sync_setgid_syscall in test_glibc_thread_support.c

When changes of gid (and uid of course) is reflected to main process
test must check if call of setgid syscall changes gid of thread ONLY.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Extend test_sync_setgid in test_glibc_thread_support.c
Robin Hack [Sun, 28 Sep 2014 19:19:13 +0000 (21:19 +0200)]
tests: Extend test_sync_setgid in test_glibc_thread_support.c

Extend test to case when thread changes gid of main process.
After this change main process start new thread which should have
same gid set as a main process.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Small optimalization of uwrap_init().
Robin Hack [Fri, 26 Sep 2014 14:25:58 +0000 (16:25 +0200)]
uwrap: Small optimalization of uwrap_init().

Don't call getenv("UID_WRAPPER") on start of uwrap_init().

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: test_glibc_thread_support: Add bigger load.
Robin Hack [Fri, 26 Sep 2014 14:19:09 +0000 (16:19 +0200)]
tests: test_glibc_thread_support: Add bigger load.

This can help (and helped) with revealing race conditions.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Added two new tests aimed to setgid() and getgid() functions.
Robin Hack [Fri, 26 Sep 2014 14:17:18 +0000 (16:17 +0200)]
tests: Added two new tests aimed to setgid() and getgid() functions.

New tests:
 * test_sync_setgid - test if call of setgid() in thread changes gid
                      of main process
 * test_sync_setgid_syscall - test setgid() syscall

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Small phtread_attr cleanup.
Robin Hack [Fri, 26 Sep 2014 13:25:09 +0000 (15:25 +0200)]
tests: Small phtread_attr cleanup.

This change should make valgrind happy.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agotests: Get rid of malloc calls in test_glibc_thread_support.c.
Robin Hack [Fri, 26 Sep 2014 12:31:39 +0000 (14:31 +0200)]
tests: Get rid of malloc calls in test_glibc_thread_support.c.

Thread structures are allocated on stack now.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Optimalization of uid_wrapper_enabled() function.
Robin Hack [Fri, 26 Sep 2014 12:00:27 +0000 (14:00 +0200)]
uwrap: Optimalization of uid_wrapper_enabled() function.

Check only bool variable inside uwrap structure instead
of calling whole uid_init().

In the best case only one mutex lock is need when check.

NOTES:
 * This patch uses __atomic_load gcc builtin function.
 * uid_init() were moved outside uid_wrapper_enabled() function.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouid_wrapper: Fix race condition - uwrap_init.
Robin Hack [Fri, 26 Sep 2014 11:26:17 +0000 (13:26 +0200)]
uid_wrapper: Fix race condition - uwrap_init.

Patch moves uwrap_id_mutex before if (uwrap.initialised) statement
which can be passed by concurrent threads.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Fix race condition - glibc lookups.
Robin Hack [Fri, 26 Sep 2014 11:05:43 +0000 (13:05 +0200)]
uwrap: Fix race condition - glibc lookups.

Patch adds libc_symbol_binding_mutex which guards global table of libc
functions and their lookup.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Add library constructor and move pthread_atfork inside.
Robin Hack [Fri, 26 Sep 2014 10:33:21 +0000 (12:33 +0200)]
uwrap: Add library constructor and move pthread_atfork inside.

Library constructor is used for pthread_atfork call. Moved here because
pthread_atfork is cumulative and should be called only once.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Use UWRAP_LOCK/UNLOCK macros instead of pthread_mutex_lock/unlock calls.
Robin Hack [Fri, 26 Sep 2014 10:08:58 +0000 (12:08 +0200)]
uwrap: Use UWRAP_LOCK/UNLOCK macros instead of pthread_mutex_lock/unlock calls.

New macros UWRAP_LOCK/UNLOCK has been created and all calls to
pthread_mutex_lock/unlock has been replaced by these macros.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
9 years agouwrap: Fix the handle loop for older gcc versions.
Andreas Schneider [Wed, 1 Oct 2014 15:17:43 +0000 (17:17 +0200)]
uwrap: Fix the handle loop for older gcc versions.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
9 years agoTESTS: SYS_gettimeofday behaves differently on OS X
Jakub Hrozek [Sat, 23 Aug 2014 22:52:26 +0000 (00:52 +0200)]
TESTS: SYS_gettimeofday behaves differently on OS X

SYS_gettimeofday returns the number of seconds on OS X and doesn't set
the tz parameter.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>