Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sudo-0.1.0.linux-x86_64.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file sudo-0.1.0.linux-x86_64.tar.gz.

File metadata

  • Download URL: sudo-0.1.0.linux-x86_64.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • 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

Hashes for sudo-0.1.0.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 25c46711481d904cd32c7d4f4c001700294cff5f0daeb7bfd0bb02c18d286185
MD5 288d9512fb0f67dd0c379eee16e467a5
BLAKE2b-256 25c35b99d68a843c6a2250016a2eee36e902ba98ddf57bd2f872211caa0bcdf3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page