]> arthur.barton.de Git - bup.git/commitdiff
Handle nonexistent groups in Metadata._apply_common_rec().
authorRob Browning <rlb@defaultvalue.org>
Sat, 29 Sep 2012 16:21:32 +0000 (11:21 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 3 Feb 2013 03:00:14 +0000 (21:00 -0600)
Thanks to Oei, Yung-Chin <yungchin@yungchin.nl> for tracking this
down.

Reported-by: Yung-Chin <yungchin@yungchin.nl>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
lib/bup/metadata.py

index dfb7438b8a8efc467d3dd3969ce6ffa45795691e..58f2989fd795a8fedd44c4ffd86b07357df7cc1f 100644 (file)
@@ -369,13 +369,13 @@ class Metadata:
             user_gids = os.getgroups()
             if self.gid in user_gids:
                 gid = self.gid
-            if not restore_numeric_ids and \
-                    self.gid != 0 and \
-                    self.group in [grp_from_gid(x).gr_name for x in user_gids]:
-                try:
-                    gid = grp_from_name(self.group).gr_gid
-                except KeyError:
-                    pass # Fall back to gid.
+            if not restore_numeric_ids and self.gid != 0:
+                # The grp might not exist on the local system.
+                grps = filter(None, [grp_from_gid(x) for x in user_gids])
+                if self.group in [x.gr_name for x in grps]:
+                    g = grp_from_name(self.group)
+                    if g:
+                        gid = g.gr_gid
 
         if uid != -1 or gid != -1:
             try: