]> arthur.barton.de Git - bup.git/commitdiff
id-other-than: exclude names based on their underlying ids.
authorRob Browning <rlb@defaultvalue.org>
Tue, 10 Dec 2013 01:00:57 +0000 (19:00 -0600)
committerRob Browning <rlb@defaultvalue.org>
Tue, 10 Dec 2013 01:04:10 +0000 (19:04 -0600)
This fixes a failure on systems that have more than one one user/group
name mapped to the same id (i.e. NetBSD's root/toor accounts).

Thanks to Thomas Klausner <tk@giga.or.at> for reporting the problem
and helping track down the solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
t/id-other-than

index 7aef3ae0b8e14d694c59d1dd8c337f2c07d05259..cfa219d4025fa763173596d586928608e3545d84 100755 (executable)
@@ -18,17 +18,21 @@ def is_integer(x):
     except ValueError, e:
         return False
 
-excluded_ids = frozenset(int(x) for x in sys.argv[2:] if is_integer(x))
-excluded_names = frozenset(x for x in sys.argv[2:] if not is_integer(x))
+excluded_ids = set(int(x) for x in sys.argv[2:] if is_integer(x))
+excluded_names = (x for x in sys.argv[2:] if not is_integer(x))
 
 if sys.argv[1] == '--user':
+    for x in excluded_names:
+        excluded_ids.add(pwd.getpwnam(x).pw_uid)
     for x in pwd.getpwall():
-        if x.pw_name not in excluded_names and x.pw_uid not in excluded_ids:
+        if x.pw_uid not in excluded_ids:
             print x.pw_name + ':' + str(x.pw_uid)
             sys.exit(0)
 elif sys.argv[1] == '--group':
+    for x in excluded_names:
+        excluded_ids.add(grp.getgrnam(x).gr_gid)
     for x in grp.getgrall():
-        if x.gr_name not in excluded_names and x.gr_gid not in excluded_ids:
+        if x.gr_gid not in excluded_ids:
             print x.gr_name + ':' + str(x.gr_gid)
             sys.exit(0)
 else: