Use ids if user or group is not present.

This commit is contained in:
Matthias Erll 2015-05-27 11:12:15 +02:00
parent 4a8dbc7f13
commit ee4c9d59ab

View File

@ -156,7 +156,8 @@ def gid_to_group(gid):
try: try:
return grp.getgrgid(gid).gr_name return grp.getgrgid(gid).gr_name
except (KeyError, NameError): except (KeyError, NameError):
return '' # If group is not present, fall back to the gid.
return gid
def group_to_gid(group): def group_to_gid(group):
@ -243,7 +244,8 @@ def uid_to_user(uid):
try: try:
return pwd.getpwuid(uid).pw_name return pwd.getpwuid(uid).pw_name
except (KeyError, NameError): except (KeyError, NameError):
return '' # If user is not present, fall back to the uid.
return uid
def user_to_uid(user): def user_to_uid(user):