Modular Python to execute any subprocess commands as another user(not necessarily superuser/root)
Project description
python-sudo
Modular Python to execute any subprocess commands as another user (not necessarily superuser/root)
calling sudo -u
Usage:
This module does not take a user password for security and efficiency reasons (aiming for no user interaction to run).
Configure the sudoers file to allow running commands as another user (not necessarily the superuser):
sudo visudo
:
parent_user ALL=(run_user) NOPASSWD: ALL
from sudo import run_as_sudo
# run `whoami` from user 'user'
cmd = "whoami"
sudo_user = "user"
run_as_sudo(sudo_user, cmd)
# optional shell, timeout (secs)
run_as_sudo(sudo_user, cmd, shell=True, timeout=20)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
sudo-1.0.0-py3-none-any.whl
(2.4 kB
view details)
File details
Details for the file sudo-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: sudo-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ace059d4173d2d7ffb0f0697ee64faeaef833ae2a1328b3124a39aea00a19c |
|
MD5 | 49e930ce011a5cb0a09dba6ca7ed4c98 |
|
BLAKE2b-256 | bb67d6f3d7cca5de7525bd75e1743fbc278bf3f995015c4c16848f2084da4b6d |