[PATCH 08/22] shell: Get supplementary group IDs in login check

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Nov 18 14:37:14 UTC 2014


---
 cpukit/libmisc/shell/login_check.c |  2 ++
 testsuites/libtests/shell01/init.c | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/cpukit/libmisc/shell/login_check.c b/cpukit/libmisc/shell/login_check.c
index 372d059..9d853f8 100644
--- a/cpukit/libmisc/shell/login_check.c
+++ b/cpukit/libmisc/shell/login_check.c
@@ -33,6 +33,7 @@
 #include <crypt.h>
 
 #include <rtems/shell.h>
+#include <rtems/userenv.h>
 
 bool rtems_shell_login_check(
   const char *user,
@@ -76,6 +77,7 @@ bool rtems_shell_login_check(
     setgid(pw.pw_gid);
     seteuid(pw.pw_uid);
     setegid(pw.pw_gid);
+    rtems_current_user_env_getgroups();
   }
 
   return ok;
diff --git a/testsuites/libtests/shell01/init.c b/testsuites/libtests/shell01/init.c
index 413ce6e..248988b 100644
--- a/testsuites/libtests/shell01/init.c
+++ b/testsuites/libtests/shell01/init.c
@@ -25,6 +25,7 @@
 #include <unistd.h>
 
 #include <rtems/shell.h>
+#include <rtems/userenv.h>
 
 #include "tmacros.h"
 
@@ -47,6 +48,7 @@ static void create_file(const char *name, const char *content)
 
 static void test(void)
 {
+  rtems_user_env_t *uenv;
   bool ok;
   int rv;
 
@@ -73,6 +75,8 @@ static void test(void)
     "F::8:s,moop,t\n"
   );
 
+  uenv = rtems_current_user_env_get();
+
   rv = setuid(0);
   rtems_test_assert(rv == 0);
 
@@ -95,6 +99,7 @@ static void test(void)
   rtems_test_assert(geteuid() == 0);
   rtems_test_assert(getgid() == 0);
   rtems_test_assert(getegid() == 0);
+  rtems_test_assert(uenv->ngroups == 0);
 
   ok = rtems_shell_login_check("zero", NULL);
   rtems_test_assert(ok);
@@ -102,6 +107,8 @@ static void test(void)
   rtems_test_assert(geteuid() == 3);
   rtems_test_assert(getgid() == 5);
   rtems_test_assert(getegid() == 5);
+  rtems_test_assert(uenv->ngroups == 1);
+  rtems_test_assert(uenv->groups[0] == 1);
 
   ok = rtems_shell_login_check("moop", "foo");
   rtems_test_assert(ok);
@@ -109,6 +116,12 @@ static void test(void)
   rtems_test_assert(geteuid() == 1);
   rtems_test_assert(getgid() == 3);
   rtems_test_assert(getegid() == 3);
+  rtems_test_assert(uenv->ngroups == 5);
+  rtems_test_assert(uenv->groups[0] == 1);
+  rtems_test_assert(uenv->groups[1] == 2);
+  rtems_test_assert(uenv->groups[2] == 4);
+  rtems_test_assert(uenv->groups[3] == 5);
+  rtems_test_assert(uenv->groups[4] == 8);
 }
 
 static void Init(rtems_task_argument arg)
-- 
1.8.4.5




More information about the devel mailing list