1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

file when UID or GID doesn't exist

This commit is contained in:
Derek Carter 2012-06-29 20:05:23 -04:00
parent 3d7a51f2ec
commit 82832021e8

View file

@ -184,8 +184,16 @@ def user_and_group(filename):
st = os.stat(filename)
uid = st.st_uid
gid = st.st_gid
try:
user = pwd.getpwuid(uid)[0]
except KeyError:
#print('unknown user')
user = 'UID' + str(uid)
try:
group = grp.getgrgid(gid)[0]
except KeyError:
#print('unknown group')
group = 'GID' + str(gid)
return (user, group)
def set_context_if_different(path, context, changed):