mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Add gr_name and pw_name in find module
The fix adds gr_name and pw_name in return output. Integration test added. Fixes: #25643 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
58239671c0
commit
fc4ab22f05
2 changed files with 31 additions and 0 deletions
|
@ -172,7 +172,9 @@ examined:
|
|||
'''
|
||||
|
||||
import fnmatch
|
||||
import grp
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import stat
|
||||
import sys
|
||||
|
@ -263,6 +265,19 @@ def contentfilter(fsname, pattern):
|
|||
|
||||
|
||||
def statinfo(st):
|
||||
pw_name = ""
|
||||
gr_name = ""
|
||||
|
||||
try: # user data
|
||||
pw_name = pwd.getpwuid(st.st_uid).pw_name
|
||||
except:
|
||||
pass
|
||||
|
||||
try: # group data
|
||||
gr_name = grp.getgrgid(st.st_gid).gr_name
|
||||
except:
|
||||
pass
|
||||
|
||||
return {
|
||||
'mode': "%04o" % stat.S_IMODE(st.st_mode),
|
||||
'isdir': stat.S_ISDIR(st.st_mode),
|
||||
|
@ -281,6 +296,8 @@ def statinfo(st):
|
|||
'atime': st.st_atime,
|
||||
'mtime': st.st_mtime,
|
||||
'ctime': st.st_ctime,
|
||||
'gr_name': gr_name,
|
||||
'pw_name': pw_name,
|
||||
'wusr': bool(st.st_mode & stat.S_IWUSR),
|
||||
'rusr': bool(st.st_mode & stat.S_IRUSR),
|
||||
'xusr': bool(st.st_mode & stat.S_IXUSR),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue