SuperCuber / dotter

A dotfile manager and templater written in rust 🦀
The Unlicense
882 stars 46 forks source link

Support environments without sudo installed #70

Closed Rasmus-Bertell closed 3 years ago

Rasmus-Bertell commented 3 years ago

Environment

Description

Running dotter without sudo fails.

Reproduction

Have a file that requires elevation and run dotter on a system without sudo.

Expected behavior

Use su as a backup when sudo is not available, not all systems have sudo. I can also symlink doas to sudo on my gentoo system and it seems to work.

Actual behavior

[ERROR] Failed to update template "portage/make.conf" -> "/etc/portage/make.conf"
Caused by:
    set target file owner
    spawn sudo chown command
    No such file or directory (os error 2)

I understand that sudo is quite popular and implementing this edge case scenario might be a bit out of scope. I can also try to create a solution for this, but I have very little experience with Rust. Let me know if I can help.

SuperCuber commented 3 years ago

Is there a way to change to a user with su based on user id? If there is then it shouldn't be too hard to add another option here and add some logic here to use it

Rasmus-Bertell commented 3 years ago

After a quick search and glance through man pages I can't find a way to use su with user ID, however, id -un <user id> gets the username and could be used in conjunction with su. I'll fork and try to implement this, but it might take a while.

Rasmus-Bertell commented 3 years ago

I ended up installing sudo on my systems since doas had it's own problems so I no longer need this and implementing it is beyond my skills with Rust.