Permalink
Browse files

Handle nonexistent groups in Metadata._apply_common_rec().

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>
  • Loading branch information...
1 parent 4b33b14 commit 6ddad71811edb38e56b35e20b1a2d5305c14015b @rlbdv rlbdv committed Sep 29, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/bup/metadata.py
View
@@ -369,13 +369,13 @@ def _apply_common_rec(self, path, restore_numeric_ids=False):
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:

0 comments on commit 6ddad71

Please sign in to comment.