]> andersk Git - nss_nonlocal.git/commitdiff
Add supplementary nonlocal gids to local users in MAGIC_NONLOCAL_GROUPNAME
authorAnders Kaseorg <andersk@mit.edu>
Sat, 26 Jun 2010 21:34:37 +0000 (17:34 -0400)
committerAnders Kaseorg <andersk@mit.edu>
Wed, 30 Mar 2011 08:56:26 +0000 (04:56 -0400)
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
README
nonlocal-group.c

diff --git a/README b/README
index 47067fb7b362aa08065747f53ccff3f4f5188148..7125dc18103fdc5b836bfcc8b945af960cb176dd 100644 (file)
--- a/README
+++ b/README
@@ -13,7 +13,9 @@ The module also assigns special properties to two local groups, if
 they exist:
 
 • If the local group ‘nss-nonlocal-users’ exists, then nonlocal users
-  will be automatically added to it.
+  will be automatically added to it.  Furthermore, if a local user is
+  added to this group, then that user will inherit any nonlocal
+  supplementary gids from a nonlocal user of the same name.
 
 • If the local group ‘nss-local-users’ exists, then local users will
   be automatically added to it.
index e93a3a25de8225cc584b4dbf9364f5a93e4b28cd..aa9c588a9342073bf6bf337f8d769594ff3eb8b4 100644 (file)
@@ -40,7 +40,9 @@
 
 /*
  * If the MAGIC_NONLOCAL_GROUPNAME local group exists, then nonlocal
- * users will be automatically added to it.
+ * users will be automatically added to it.  Furthermore, if a local
+ * user is added to this group, then that user will inherit any
+ * nonlocal supplementary gids from a nonlocal user of the same name.
  */
 #define MAGIC_NONLOCAL_GROUPNAME "nss-nonlocal-users"
 
@@ -338,7 +340,8 @@ _nss_nonlocal_initgroups_dyn(const char *user, gid_t group, long int *start,
     char *buffer;
     int in, out, i;
 
-    /* Check that the user is a nonlocal user before adding any groups. */
+    /* Check that the user is a nonlocal user, or a member of the
+     * MAGIC_NONLOCAL_GROUPNAME group, before adding any groups. */
     status = check_nonlocal_user(user, errnop);
     if (status == NSS_STATUS_TRYAGAIN) {
        return status;
@@ -369,6 +372,14 @@ _nss_nonlocal_initgroups_dyn(const char *user, gid_t group, long int *start,
            if (!add_group(nonlocal_users_group.gr_gid, start, size, groupsp,
                           limit, errnop, &status))
                return status;
+       } else {
+           int i;
+           for (i = 0; i < *start; ++i) {
+               if ((*groupsp)[i] == nonlocal_users_group.gr_gid) {
+                   is_nonlocal = true;
+                   break;
+               }
+           }
        }
     } else if (status == NSS_STATUS_TRYAGAIN) {
        if (is_nonlocal)
This page took 0.289731 seconds and 5 git commands to generate.