Skip to content

samayer12/sudome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sudome

A proof-of-concept for PyCharm projects that must run with elevated permissions on Linux. python-sudo.sh sources the virtual environment and then executes the project with elevated permissions. setup.sh places the appropriate entry in /etc/sudoers.d/python. The user must enter their sudo credentials during setup.sh.

Usage

  1. Ensure setup.sh is executable (ls -l setup.sh).

    -rwxr--r-- 1 user user   535 Mmm DD HH:MM python-sudo.sh
  2. Run ./setup.sh from project root. Example output:

    [user@host sudome]$ /bin/bash /home/user/PycharmProjects/sudome/setup.sh
    Configuration Line:
    [sudo] password for user: 
    user host = (root) NOPASSWD: /usr/bin/python
    File contents: /etc/sudoers.d/python
    user host = (root) NOPASSWD: /usr/bin/python
  3. Add python as a venv project interpreter in PyCharm.

  4. Add python-sudo.sh as a project interpreter in PyCharm. This will time out or throw an error, but it will be okay.

  5. Observe the available run configs from .idea/runConfigurations/.

  6. Choose any config through PyCharm and run it (Shift + F10).

Required Project Structure

ProjectRoot/
  |-.idea/
  |  \- runConfigurations/
  |     \- [XML files]
  |- src/
  |- test/
  |- python-sudo.sh
  |- requirements.txt
  \- setup.sh

Inspired by Eric Smith.

About

PoC for privileged projects from non-privileged PyCharm sessions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published