lists.arthurdejong.org
RSS feed

nss-pam-ldapd branch master updated. 0.9.13-25-gd237dc6

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd branch master updated. 0.9.13-25-gd237dc6



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "nss-pam-ldapd".

The branch, master has been updated
       via  d237dc6bb7ae53f4d73d3ed43c552b45e7b20cc0 (commit)
      from  15de33be9f17203c0805697c3ed458260c0c6b91 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/nss-pam-ldapd/commit/?id=d237dc6bb7ae53f4d73d3ed43c552b45e7b20cc0

commit d237dc6bb7ae53f4d73d3ed43c552b45e7b20cc0
Author: CHAPUIS Bertille <bertille.chapuis@alstomgroup.com>
Date:   Mon Dec 8 08:12:42 2025 +0000

    Add nss_min_gid option to filter users and groups
    
    This option, somewhat similarly to nss_min_uid will filter out users and
    groups with a GID from the LDAP server lower than a particular value.

diff --git a/man/nslcd.conf.5.xml b/man/nslcd.conf.5.xml
index 77d757d..af43fdf 100644
--- a/man/nslcd.conf.5.xml
+++ b/man/nslcd.conf.5.xml
@@ -771,6 +771,21 @@
      </listitem>
     </varlistentry>
 
+    <varlistentry id="nss_min_gid"> <!-- since 0.9.14 -->
+     <term><option>nss_min_gid</option> <replaceable>GID</replaceable></term>
+     <listitem>
+      <para>
+       This option ensures that <acronym>LDAP</acronym> users and groups with a
+       numeric group id lower than the specified value are ignored. Also 
requests for
+       groups with a lower group id are ignored.
+      </para>
+      <para>
+       Group membership is not restricted so users with a too low primary GID
+       will still show up as members of a group.
+      </para>
+     </listitem>
+    </varlistentry>
+
     <varlistentry id="nss_uid_offset"> <!-- since 0.9.9 -->
      <term><option>nss_uid_offset</option> 
<replaceable>NUMBER</replaceable></term>
      <listitem>
@@ -798,6 +813,10 @@
        when using <literal>objectSid</literal> attributes, for compatibility
        reasons.
       </para>
+      <para>
+       The value from the <option>nss_min_gid</option> option is evaluated
+       after applying the offset.
+      </para>
      </listitem>
     </varlistentry>
 
diff --git a/nslcd/cfg.c b/nslcd/cfg.c
index e02f567..7f43630 100644
--- a/nslcd/cfg.c
+++ b/nslcd/cfg.c
@@ -1300,6 +1300,7 @@ static void cfg_defaults(struct ldap_config *cfg)
   cfg->pagesize = 0;
   cfg->nss_initgroups_ignoreusers = NULL;
   cfg->nss_min_uid = 0;
+  cfg->nss_min_gid = 0;
   cfg->nss_uid_offset = 0;
   cfg->nss_gid_offset = 0;
   cfg->nss_nested_groups = 0;
@@ -1693,6 +1694,11 @@ static void cfg_read(const char *filename, struct 
ldap_config *cfg)
       cfg->nss_min_uid = get_int(filename, lnr, keyword, &line);
       get_eol(filename, lnr, keyword, &line);
     }
+    else if (strcasecmp(keyword, "nss_min_gid") == 0)
+    {
+      cfg->nss_min_gid = get_int(filename, lnr, keyword, &line);
+      get_eol(filename, lnr, keyword, &line);
+    }
     else if (strcasecmp(keyword, "nss_uid_offset") == 0)
     {
       cfg->nss_uid_offset = get_int(filename, lnr, keyword, &line);
@@ -2006,6 +2012,7 @@ static void cfg_dump(void)
     log_log(LOG_DEBUG, "CFG: nss_initgroups_ignoreusers %s", buffer);
   }
   log_log(LOG_DEBUG, "CFG: nss_min_uid %lu", (unsigned long 
int)nslcd_cfg->nss_min_uid);
+  log_log(LOG_DEBUG, "CFG: nss_min_gid %lu", (unsigned long 
int)nslcd_cfg->nss_min_gid);
   log_log(LOG_DEBUG, "CFG: nss_uid_offset %lu", (unsigned long 
int)nslcd_cfg->nss_uid_offset);
   log_log(LOG_DEBUG, "CFG: nss_gid_offset %lu", (unsigned long 
int)nslcd_cfg->nss_gid_offset);
   log_log(LOG_DEBUG, "CFG: nss_nested_groups %s", 
print_boolean(nslcd_cfg->nss_nested_groups));
diff --git a/nslcd/cfg.h b/nslcd/cfg.h
index db31c3a..551f1d1 100644
--- a/nslcd/cfg.h
+++ b/nslcd/cfg.h
@@ -122,6 +122,7 @@ struct ldap_config {
   int pagesize; /* set to a greater than 0 to enable handling of paged results 
with the specified size */
   SET *nss_initgroups_ignoreusers;  /* the users for which no initgroups() 
searches should be done */
   uid_t nss_min_uid;  /* minimum uid for users retrieved from LDAP */
+  uid_t nss_min_gid;  /* minimum gid for users retrieved from LDAP */
   uid_t nss_uid_offset; /* offset for uids retrieved from LDAP to avoid local 
uid clashes */
   gid_t nss_gid_offset; /* offset for gids retrieved from LDAP to avoid local 
gid clashes */
   int nss_nested_groups; /* whether to expand nested groups */
diff --git a/nslcd/group.c b/nslcd/group.c
index dd5211f..5620b73 100644
--- a/nslcd/group.c
+++ b/nslcd/group.c
@@ -244,11 +244,14 @@ static int do_write_group(TFILE *fp, MYLDAP_ENTRY *entry,
     {
       for (j = 0; j < numgids; j++)
       {
-        WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
-        WRITE_STRING(fp, names[i]);
-        WRITE_STRING(fp, passwd);
-        WRITE_INT32(fp, gids[j]);
-        WRITE_STRINGLIST(fp, members);
+        if (gids[j] >= nslcd_cfg->nss_min_gid)
+        {
+          WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+          WRITE_STRING(fp, names[i]);
+          WRITE_STRING(fp, passwd);
+          WRITE_INT32(fp, gids[j]);
+          WRITE_STRINGLIST(fp, members);
+        }
       }
     }
   }
@@ -376,6 +379,11 @@ static int write_group(TFILE *fp, MYLDAP_ENTRY *entry, 
const char *reqname,
         }
       }
       gids[numgids] += nslcd_cfg->nss_gid_offset;
+      if (gids[numgids] < nslcd_cfg->nss_min_gid)
+      {
+        log_log(LOG_DEBUG, "%s: %s: less than nss_min_gid",
+                myldap_get_dn(entry), attmap_group_gidNumber);
+      }
     }
   }
   /* get group passwd (userPassword) (use only first entry) */
@@ -446,7 +454,17 @@ NSLCD_HANDLE(
   gid_t gid;
   char filter[BUFLEN_FILTER];
   READ_INT32(fp, gid);
-  log_setrequest("group=%lu", (unsigned long int)gid);,
+  log_setrequest("group=%lu", (unsigned long int)gid);
+  if (gid < nslcd_cfg->nss_min_gid)
+  {
+    log_log(LOG_DEBUG, "request ignored by nss_min_gid option");
+    /* return an empty result */
+    WRITE_INT32(fp, NSLCD_VERSION);
+    WRITE_INT32(fp, NSLCD_ACTION_GROUP_BYGID);
+    WRITE_INT32(fp, NSLCD_RESULT_END);
+    return 0;
+  }
+  ,
   mkfilter_group_bygid(gid, filter, sizeof(filter)),
   write_group(fp, entry, NULL, &gid, 1, session)
 )
diff --git a/nslcd/passwd.c b/nslcd/passwd.c
index db3732b..d506826 100644
--- a/nslcd/passwd.c
+++ b/nslcd/passwd.c
@@ -544,6 +544,12 @@ static int write_passwd(TFILE *fp, MYLDAP_ENTRY *entry, 
const char *requser,
     }
   }
   gid += nslcd_cfg->nss_gid_offset;
+  if (gid < nslcd_cfg->nss_min_gid)
+  {
+    log_log(LOG_DEBUG, "%s: %s: less than nss_min_gid",
+            myldap_get_dn(entry), attmap_group_gidNumber);
+    return 0;
+  }
   /* get the gecos for this entry */
   attmap_get_value(entry, attmap_passwd_gecos, gecos, sizeof(gecos));
   /* get the home directory for this entry */

-----------------------------------------------------------------------

Summary of changes:
 man/nslcd.conf.5.xml | 19 +++++++++++++++++++
 nslcd/cfg.c          |  7 +++++++
 nslcd/cfg.h          |  1 +
 nslcd/group.c        | 30 ++++++++++++++++++++++++------
 nslcd/passwd.c       |  6 ++++++
 5 files changed, 57 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
nss-pam-ldapd