diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-11-17 07:53:01 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-11-20 10:30:22 +0100 |
commit | ffa71f1cd0af6682aca1da3b05fed02f64ec7e5b (patch) | |
tree | 76fb95010a2698dfff7185b96045587ce9b45ff7 /testsuites/libtests/pwdgrp01/init.c | |
parent | libcsupport: Use POSIX key for getgrent() (diff) | |
download | rtems-ffa71f1cd0af6682aca1da3b05fed02f64ec7e5b.tar.bz2 |
libcsupport: Implement getgroups()
Diffstat (limited to 'testsuites/libtests/pwdgrp01/init.c')
-rw-r--r-- | testsuites/libtests/pwdgrp01/init.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/testsuites/libtests/pwdgrp01/init.c b/testsuites/libtests/pwdgrp01/init.c index f1be7bbfcd..86f8e9030a 100644 --- a/testsuites/libtests/pwdgrp01/init.c +++ b/testsuites/libtests/pwdgrp01/init.c @@ -17,9 +17,12 @@ #endif #include <sys/stat.h> +#include <sys/types.h> +#include <errno.h> #include <grp.h> #include <pwd.h> #include <stdio.h> +#include <unistd.h> #include "tmacros.h" @@ -69,6 +72,7 @@ static void test(void) struct passwd *pwd_res; struct group *grp_res; char buf[256]; + gid_t grps[5]; rv = mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); rtems_test_assert(rv == 0); @@ -80,7 +84,14 @@ static void test(void) create_file( "/etc/group", + "A::1:moop,u,v,w\n" + "B::2:moop\n" "blub:bar:3:moop\n" + "C::4:l,m,n,moop\n" + "D::5:moop,moop\n" + "E::6:x\n" + "E::7:y,z\n" + "F::8:s,moop,t\n" ); memset(&pwd, 0xff, sizeof(pwd)); @@ -106,6 +117,34 @@ static void test(void) rtems_test_assert(rv == 0); rtems_test_assert(&grp == grp_res); assert_grp(grp_res); + + rv = setuid(0); + rtems_test_assert(rv == 0); + + errno = 0; + rv = getgroups(0, NULL); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == EINVAL); + + rv = setuid(1); + rtems_test_assert(rv == 0); + + rv = getgroups(0, NULL); + rtems_test_assert(rv == 5); + + errno = 0; + rv = getgroups(1, &grps[0]); + rtems_test_assert(rv == -1); + rtems_test_assert(errno == EINVAL); + + memset(&grps[0], 0xff, sizeof(grps)); + rv = getgroups(5, &grps[0]); + rtems_test_assert(rv == 5); + rtems_test_assert(grps[0] == 1); + rtems_test_assert(grps[1] == 2); + rtems_test_assert(grps[2] == 4); + rtems_test_assert(grps[3] == 5); + rtems_test_assert(grps[4] == 8); } static void Init(rtems_task_argument arg) @@ -126,6 +165,8 @@ static void Init(rtems_task_argument arg) #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4 #define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 1 +#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 1 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |