Teach file.check_perms to handle uids and gids.

Fixes #21423. Allow passing in numeric values for user and group.
This commit is contained in:
Aneesh Agrawal 2015-03-11 23:25:23 -04:00 committed by rallytime
parent 74b9ec2be0
commit b28dba2ecd

View File

@ -2714,9 +2714,13 @@ def check_perms(name, ret, user, group, mode, follow_symlinks=False):
ret['changes']['mode'] = mode
# user/group changes if needed, then check if it worked
if user:
if isinstance(user, int):
user = uid_to_user(user)
if user != perms['luser']:
perms['cuser'] = user
if group:
if isinstance(group, int):
group = gid_to_group(group)
if group != perms['lgroup']:
perms['cgroup'] = group
if 'cuser' in perms or 'cgroup' in perms: