diff --git a/Cargo.lock b/Cargo.lock index 299c1e31..f20b0688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4858,9 +4858,9 @@ dependencies = [ [[package]] name = "xdg" -version = "2.5.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" +checksum = "2fb433233f2df9344722454bc7e96465c9d03bff9d77c248f9e7523fe79585b5" [[package]] name = "yoke" diff --git a/Cargo.toml b/Cargo.toml index 1b1cbba7..7a9e76e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -226,7 +226,7 @@ qrcode = { version = "0.14", default-features = false, optional = true } sysexits = "0.9" build-time = "0.1" directories = "6.0" -xdg = "2.5" +xdg = "3.0" rpassword = "7.3" libc = { version = "0.2", features = ["extra_traits"] } rand = "0.9" diff --git a/src/config.rs b/src/config.rs index fe1d4fd8..002ab65a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -54,7 +54,8 @@ pub fn get_default_config_path(config_file: &str) -> Option { // UNIX systems, XDG Base Directory // https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html #[cfg(unix)] - if let Ok(base_directories) = xdg::BaseDirectories::with_prefix("shadowsocks-rust") { + { + let base_directories = xdg::BaseDirectories::with_prefix("shadowsocks-rust"); // $XDG_CONFIG_HOME/shadowsocks-rust/config.json // for dir in $XDG_CONFIG_DIRS; $dir/shadowsocks-rust/config.json for filename in &config_files { @@ -67,12 +68,13 @@ pub fn get_default_config_path(config_file: &str) -> Option { // UNIX global configuration file #[cfg(unix)] { + let mut global_config_path = PathBuf::from("/etc/shadowsocks-rust"); for filename in &config_files { - let path_str = "/etc/shadowsocks-rust/".to_owned() + filename; - let global_config_path = Path::new(&path_str); + global_config_path.push(filename); if global_config_path.exists() { return Some(global_config_path.to_path_buf()); } + global_config_path.pop(); } }