init: set groups on L2 system
authorAlan Cox <alan@linux.intel.com>
Fri, 25 Mar 2016 20:20:57 +0000 (20:20 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 25 Mar 2016 20:20:57 +0000 (20:20 +0000)
Applications/util/init.c

index 7751a86..c5631c7 100644 (file)
@@ -22,6 +22,7 @@
 #include <fcntl.h>
 #include <pwd.h>
 #include <utmp.h>
+#include <grp.h>
 #include <errno.h>
 #include <paths.h>
 #include <sys/wait.h>
@@ -742,6 +743,8 @@ static void spawn_login(struct passwd *pwd, const char *tty, const char *id)
        /* Don't leak utmp into the child */
        endutent();
 
+       if (initgroups(pwd->pw_name, pwd->pw_gid) == -1 && errno != ENOSYS)
+               exit(255);
        if (setgid(pwd->pw_gid) == -1 ||
                setuid(pwd->pw_uid) == -1)
                        _exit(255);