pikaur icon indicating copy to clipboard operation
pikaur copied to clipboard

Config option to prevent running as root

Open Ape opened this issue 7 years ago • 5 comments

I would like to have a configuration option that prevents me from running pikaur as root. I want to always use the same directories in my home, but when running pikaur as root it would use different directories.

The option would work like this if I accidentally run pikaur as root:

$ sudo pikaur -S pikaur
Error: Do not run pikaur as root!
$ pikaur -S pikaur
...

Ape avatar Sep 15 '18 09:09 Ape

what about adding an option "Disable systemd dynamic users"?

actionless avatar Sep 15 '18 14:09 actionless

I think it easy for you @Ape do create a function in your .bashrc which check before running pikaur thanks to command whoami e.g.

if [whoami == root];
   pikaur;
else

the same could be done upstream, with a behaviour like this:

is root?
            no -> continue
            yes -> check config option:
                                        config option enabled (default)   -> stop execution of pikaur
                                        config option disabled            -> just print a warning

mattia-b89 avatar Oct 03 '19 16:10 mattia-b89

If someone had to implement this what files would they need to work with? I am assuming pikaur/config.py

sakshatshinde avatar Mar 08 '20 14:03 sakshatshinde

@sakshatshinde pikaur/config.py and pikaur/main.py

actionless avatar Mar 08 '20 18:03 actionless

To whom it may concern: A function in your .bashrc will not work, since sudo pikaur runs pikaur as root and not as you.

I worked around this by adding !/usr/bin/pikaur to my entry in the sudoers file: thus, my system prints an error message instead of allowing me to run sudo pikaur.

This is not secure—see "Limitations of the ‘!’ operator" in the sudoers manual entry—but is sufficient to prevent accidents.

foghawk avatar Oct 16 '21 19:10 foghawk

fixed in 99fa4549e9f25661c65c7c031027033c9be3dadc

actionless avatar May 01 '23 04:05 actionless