Merge pull request #24179 from Precis/fix-file-uid-gid-2015.0

Changing user and group only possible for existing ids.
This commit is contained in:
Thomas S Hatch 2015-05-29 09:52:43 -06:00
commit ba02f6509e

View file

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