stulleman
stulleman

Reputation: 173

Run python script with elevated privileges installed with setuptools

I wrote a module that needs elevated privileges.

This is an excerpt from my setup.py:

...

entry_points={
    "console_scripts": [
        "wlan-monitor = wlan_monitor.wlan_monitor:main"
    ],
}

...

Installed with pip3 install . the wlan-monitor command is only available for the current user. sudo wlan-monitor is not available.

Since installing modules with sudo is discouraged, I'm searching for an alternative, where I can install the module as normal user but start the program with elevated privileges.

Upvotes: 1

Views: 435

Answers (1)

vy32
vy32

Reputation: 29655

If you could install a module as a normal user but start the program with elevated privileges, then that would be a technique that ordinary users could use to compromise system security.

@phd notes that you can just use the sudo pip install. That's fine.

Another approach would be to use your operating systems' proprietary privilege escalation approach. For example, MacOS has an approach, and Windows has another.

Upvotes: 1

Related Questions