Browse Source

Add group ID parameters to Unix sync

Jon Natkins 13 years ago
parent
commit
2f6157c792

+ 5 - 1
apps/useradmin/src/useradmin/management/commands/useradmin_sync_with_unix.py

@@ -28,6 +28,8 @@ class Command(BaseCommand):
   option_list = BaseCommand.option_list + (
   option_list = BaseCommand.option_list + (
       make_option("--min-uid", help="Minimum UID to import (Inclusive).", default=500),
       make_option("--min-uid", help="Minimum UID to import (Inclusive).", default=500),
       make_option("--max-uid", help="Maximum UID to import (Exclusive).", default=65334),
       make_option("--max-uid", help="Maximum UID to import (Exclusive).", default=65334),
+      make_option("--min-gid", help="Minimum GID to import (Inclusive).", default=500),
+      make_option("--max-gid", help="Maximum GID to import (Exclusive).", default=65334),
       make_option("--check-shell", help="Whether or not to check that the user's shell is not /bin/false", default=True)
       make_option("--check-shell", help="Whether or not to check that the user's shell is not /bin/false", default=True)
   )
   )
 
 
@@ -36,6 +38,8 @@ class Command(BaseCommand):
     # is usually a nobody user at the top of the ID space, so let's avoid those
     # is usually a nobody user at the top of the ID space, so let's avoid those
     min_uid = options['min_uid']
     min_uid = options['min_uid']
     max_uid = options['max_uid']
     max_uid = options['max_uid']
+    min_gid = options['min_gid']
+    max_gid = options['max_gid']
     check_shell = options['check_shell']
     check_shell = options['check_shell']
 
 
-    sync_unix_users_and_groups(min_uid, max_uid, check_shell)
+    sync_unix_users_and_groups(min_uid, max_uid, min_gid, max_gid, check_shell)

+ 2 - 2
apps/useradmin/src/useradmin/views.py

@@ -231,7 +231,7 @@ def _check_remove_last_super(user_obj):
     raise PopupException("You cannot remove the last active "
     raise PopupException("You cannot remove the last active "
                          "superuser from the configuration.")
                          "superuser from the configuration.")
 
 
-def sync_unix_users_and_groups(min_uid, max_uid, check_shell):
+def sync_unix_users_and_groups(min_uid, max_uid, min_gid, max_gid, check_shell):
   """
   """
   Syncs the Hue database with the underlying Unix system, by importing users and
   Syncs the Hue database with the underlying Unix system, by importing users and
   groups from 'getent passwd' and 'getent groups'. This should also pull in
   groups from 'getent passwd' and 'getent groups'. This should also pull in
@@ -240,7 +240,7 @@ def sync_unix_users_and_groups(min_uid, max_uid, check_shell):
   global __users_lock, __groups_lock
   global __users_lock, __groups_lock
 
 
   hadoop_groups = dict((group.gr_name, group) for group in grp.getgrall() \
   hadoop_groups = dict((group.gr_name, group) for group in grp.getgrall() \
-      if (group.gr_gid >= min_uid and group.gr_gid < max_uid) or group.gr_name == 'hadoop')
+      if (group.gr_gid >= min_gid and group.gr_gid < max_gid) or group.gr_name == 'hadoop')
   user_groups = dict()
   user_groups = dict()
 
 
   __users_lock.acquire()
   __users_lock.acquire()