Hi folks,
I use Linux for many years and NixOS is the first distro where my user (my desktop user) is not member of wheel
. I don’t need sudo
since all changes are done by nixos-rebuild
which means I can time to time just su
as root by typing password, run nixos-rebuild
and them logoff. Perfect! Thank you Nix and NixOS and the community!
But today I realized that there is one small thing that might require sudo
…
I have a few special (without home dir) users that are unprivileged (not in wheel) users. I use them for development. I’d like to be able to use them without much of a hassle. Could you please give me some tips that won’t break any security rules?
Ideas:
-
su
as root and thensudo -su dev1user
orsudo su dev1user
- this is what I do now but it’s annoying to type root password all the time… - I can give the
dev1user
user a password and then justsu dev1user
but I’d prefer other option… - I can configure
sudoers
for my user to run a command without password:me ALL = NOPASSWD: ...
. But I’d prefer an option withoutsudo
. - I can create a package with a simple C/Go binary that will execute
su dev1user
and I can set setuid bitchmod u+s
inmkDerivation
for this binary… I know - setuid is evil, but in this case…
#include <unistd.h>
int main() {
setuid(0);
execle("/usr/bin/env","bash","...",(char*) NULL,(char*) NULL);
}