Skip to content

Refactor script to be sudoers-friendly#87

Open
ExoticMatter wants to merge 3 commits intoWitko:masterfrom
ExoticMatter:master
Open

Refactor script to be sudoers-friendly#87
ExoticMatter wants to merge 3 commits intoWitko:masterfrom
ExoticMatter:master

Conversation

@ExoticMatter
Copy link

By extracting the parts of the script that require sudo into a different script, it is (probably) safe to add the extracted script to your sudoers file for use with NOPASSWD.

(Also includes unrelated error handling [if one module fails to load, the rest of the commands will probably fail too; if one can't be unloaded, you can't shut off the GPU])

@lilydjwg
Copy link

lilydjwg commented Apr 8, 2019

I have another idea: refactor script so that users are required to run with sudo. Invoking sudo inside will work poorly on exit: it prompts the user to enter password again.

nvidia-xrun.txt

@Witko Witko added this to the Version 0.4.0 milestone May 6, 2019
@tangxinfa
Copy link

I'm try to fix this problem by rewrite the privilege functions with C:

https://github.com/tangxinfa/nvidia-xrun.git

Implementing details:

The privilege functions use by `nvidia-xrun` was rewrited with C program
`nvidia-xrun-util`, we put the set-user-ID and set-group-ID  bits to the
executable. When executed it will parse the config file
`/etc/default/nvidia-xrun` by itself, then `setuid`/`setgid` to `root` user
for call privilege operations.

So it will not introduce new security problems.

Anyone interesting can try it:

# Build
git clone https://github.com/tangxinfa/nvidia-xrun.git
cd nvidia-xrun
git checkout fix-no-sudo
make permission
# Install by overwrite original nvidia-xrun executable files
sudo ln -sf ./nvidia-xrun /usr/bin/nvidia-xrun
sudo ln -sf ./nvidia-xrun-util /usr/bin/nvidia-xrun-util

If anyone like it i will make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments