other_access
other_access is more flexible implementation of os.access().
While os.access() checks access for current user only, other_access / oaccess can check access for other users/groups. In other words, other_access will return same result, no matter which user runs it (Supposing current user can os.stat() that file).
For example, root user can use other_access.oaccess(path, os.R_OK, 'www-data') to ensure files are readable by www-data user.
Limitation
other_access does not supports filesystem ACL.
Install
pip3 install other-access
Usage
other_access(path, mode, uid, gids=None) - main function. similar to os.access(), but checks for other user (uid) and list of groups (gids). User and group id's are integer (not names).
oaccess(path, mode, user, groups) - wrapper for other_access which takes names for user/groups, converts it to numerical uid/gids and calls other_access(). If groups is None, oaccess will use all groups for this user. (specify only main group or empty list to override this)
Examples
Lets use /etc/shadow for example:
-rw-r----- 1 root shadow 1841 Jun 2 04:07 /etc/shadow
import os
from other_access import oaccess
# user root can read and write
assert oaccess('/etc/shadow', os.R_OK | os.W_OK, 'root') == True
# group shadow can read
assert oaccess('/etc/shadow', os.R_OK, 'nobody', ['shadow']) == True
# Other can check existence of file, but cannot read
assert oaccess('/etc/shadow', os.F_OK, 'nobody') == True
assert oaccess('/etc/shadow', os.R_OK, 'nobody') == False
Metadata
Release files for other-access 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| other_access-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Release files / other_access-0.0.6-py3-none-any.whl
| Download URL | other_access-0.0.6-py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d584155f7446c22fdab1f85fd001d236df9e87e19d65dde2d97402a91cc8a884
|
|
BLAKE2b-256 checksum How to use checksums |
8af488543e8fc82e73252fbb7d207b5016a64a453060be6df48e93689ebe6d08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.3
|
Security for other-access 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.