added read-/write-/executeable flags for invoking user (#4130)

This commit is contained in:
tobixx 2016-07-14 19:11:35 +02:00 committed by Matt Clay
parent aa1e9e3d5f
commit ed1d80b7d8

View file

@ -294,6 +294,21 @@ stat:
returned: success, path exists and user can read stats and installed python supports it and the `mime` option was true, will return 'unknown' on error. returned: success, path exists and user can read stats and installed python supports it and the `mime` option was true, will return 'unknown' on error.
type: string type: string
sample: us-ascii sample: us-ascii
readable:
description: Tells you if the invoking user has the right to read the path
returned: success, path exists and user can read the path
type: boolean
sample: False
writeable:
description: Tells you if the invoking user has the right to write the path
returned: success, path exists and user can write the path
type: boolean
sample: False
executable:
description: Tells you if the invoking user has the execute the path
returned: success, path exists and user can execute the path
type: boolean
sample: False
''' '''
import os import os
@ -368,6 +383,9 @@ def main():
'xoth' : bool(mode & stat.S_IXOTH), 'xoth' : bool(mode & stat.S_IXOTH),
'isuid' : bool(mode & stat.S_ISUID), 'isuid' : bool(mode & stat.S_ISUID),
'isgid' : bool(mode & stat.S_ISGID), 'isgid' : bool(mode & stat.S_ISGID),
'readable' : os.access(path, os.R_OK),
'writeable' : os.access(path, os.W_OK),
'excutable' : os.access(path, os.X_OK),
} }
if S_ISLNK(mode): if S_ISLNK(mode):