-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should I use sudo or not? #83
Comments
It should be fine without sudo, the issue is the Fedora config meaning that it is writing to the root dir rather than the user that it calls sudo from. The code is: let _res: () = if let Some(base_dirs) = BaseDirs::new() {
pathbuf.push(base_dirs.config_dir());
Ok(())
} else if let Ok(user) = std::env::var("SUDO_USER") {
// TODO: DRY
let confpath = format!("/home/{}/.config", user);
let path = Path::new(&confpath);
if path.exists() {
pathbuf.push(path);
Ok(())
} else {
Err(anyhow!("Could not find valid config directory!"))
} Could you please check if Fedora is setting the XDG_CONFIG_DIR for root (i.e. when call from sudo)? Or not setting the SUDO_USER env var when using sudo? One of these must differ from Arch Linux, causing it to write to the root home dir directly. |
Thanks for the quick response. XDG_CONFIG_DIR is not set but SUDO_USER is:
|
It might be But yeah if that isn't set then it should be the same as Arch 🤔 |
None of the XDG env vars are set when using sudo:
Only the following are set for a non root user under Gnome:
I don't know Rust (or any programming languages for that matter) but, is the first test in your code checking that it can get the sudo user's standard directories? If yes then, won't this pass and base the config dir on the sudo user's home directory, which in my case is:
when it should base the config dir on the calling user's home directory:
I'm not sure if that code is running as the calling user or the sudo user. |
Yeah, there it looks fine. It should be getting the directory from the SUDO_USER variable. Could you please try building from the git clone git@github.com:jamesmcm/vopono.git
cd vopono
git checkout newissues
cargo build
cd target/debug/
./vopono -v sync And copy the output here? As it seems it might be some issue with the XDG base_dirs crate maybe. |
As requested:
Out of curiosity, should sudo even be used just to perform the sync? |
Thanks, these issues are fixed on the I want to finish fixing the openfortivpn and pppd issues before making a new release though. |
Thanks for the update. I pulled the updates and tried to recompile but it fails with:
|
Oops, it's fixed now. And the tl;dr is you should never need to use sudo directly. Note there is still an issue around running as root directly (e.g. in system-level systemd unit files) due to #84 |
I get the following warnings when compiling:
but it does compile, and I can confirm that the config is now written to the non root user's home directory. Many thanks. |
Hi.
I've only just discovered this tool so apologies if this is a basic question.
I couldn't find anyone else asking, so it's probably just me.
In the User Guide it states:
"vopono will call sudo if required, it is recommended to run as the current user and let vopono call sudo so that the configuration directories are correctly inferred and the final command is not run as root."
after this:
The process hangs in the same way as described in #59. As far as I can see it's not able to create the firewall rules.
Everything works as expected.
I believe I'm using the latest release:
and I'm using Fedora 34, which has the following default sudoers config entries:
So, should I always run the application via sudo, do I need to change by default sudo behaviour config, or am I simply doing something wrong?
Many thanks in advance.
The text was updated successfully, but these errors were encountered: