Export groups even if nobody has that group as a supplementary group, as long as...
authorPeter Palfrader <peter@palfrader.org>
Fri, 8 Jan 2010 22:25:49 +0000 (23:25 +0100)
committerPeter Palfrader <peter@palfrader.org>
Fri, 8 Jan 2010 22:25:49 +0000 (23:25 +0100)
debian/changelog
ud-generate

index c0403b7..ef4e638 100644 (file)
@@ -1,6 +1,14 @@
+userdir-ldap (0.3.76xXx) unstable; urgency=low
+
+  * Export groups even if nobody has that group as a supplementary group,
+    as long as there are users that have it as a primary group.
+
+ -- Peter Palfrader <weasel@debian.org>  Fri, 08 Jan 2010 23:25:32 +0100
+
 userdir-ldap (0.3.75) unstable; urgency=low
 
   * Enable support for mailDefaultOptions
+  * Make a stab at really not exporting empty groups.
 
  -- Stephen Gran <sgran@debian.org>  Mon, 16 Nov 2009 21:36:53 +0000
 
index 9355965..4514bde 100755 (executable)
@@ -426,6 +426,7 @@ def GenGroup(File):
       GroupMap = {}
       for x in GroupIDMap.keys():
          GroupMap[x] = []
+      GroupHasPrimaryMembers = {}
      
       # Fetch all the users
       global PasswdAttrs
@@ -433,6 +434,8 @@ def GenGroup(File):
       # Sort them into a list of groups having a set of users
       for x in PasswdAttrs:
          uid = GetAttr(x, "uid")
+         if 'gidNumber' in x[1]:
+            GroupHasPrimaryMembers[ int(x[1]["gidNumber"][0]) ] = True
          if x[1].has_key("uidNumber") == 0 or not IsInGroup(x):
             continue
          if x[1].has_key("supplementaryGid") == 0:
@@ -446,11 +449,10 @@ def GenGroup(File):
       # Output the group file.
       J = 0
       for x in GroupMap.keys():
-
-         if len(GroupMap[x]) == 0:
+         if GroupIDMap.has_key(x) == 0:
             continue
 
-         if GroupIDMap.has_key(x) == 0:
+         if len(GroupMap[x]) == 0 and GroupIDMap[x] not in GroupHasPrimaryMembers:
             continue
 
          grouprevmap[GroupIDMap[x]] = x