Closed security-yunjae closed 7 months ago
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
fluere-config/src/init.rs
✓ https://github.com/SkuldNorniern/fluere/commit/534f9142e5c2bd829755c38fa3ba9e1a33873657
Modify fluere-config/src/init.rs with contents:
• Replace the current implementation of the `home_config_path()` function with a new implementation that correctly handles different operating systems.
• Use the `cfg!` macro to check the operating system at compile time. If the target OS is unix, use the existing logic. If the target OS is macos, use the `dirs::home_dir()` function to get the home directory instead of hardcoding the path.
• The modified `home_config_path()` function should look like this:
fn home_config_path() -> PathBuf {
// Check for the SUDO_USER environment variable
let sudo_user = env::var("SUDO_USER");
let path_base = match sudo_user {
Ok(user) => {
// If SUDO_USER is set, construct the path using the user's home directory
let user_home = if cfg!(target_os = "macos") {
dirs::home_dir().unwrap()
} else {
format!("/home/{}", user)
};
Path::new(&user_home).join(".config")
}
Err(_) => {
// If not running under sudo, just use the config_dir function as before
config_dir().unwrap()
}
};
let path_config = path_base.join("fluere");
path_config
}
I have finished reviewing the code for completeness. I did not find errors for sweep/fix-directory-creation-issue
.
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, try sweep: Refactor <your_file>.py to be more modular
!💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
the part, that you trying to fix it is not relevant to the error, change the part that actually tries to create the config file when is not there
Details
OS: macOS Sonoma 14.1 Arch: Intel
Failed to create directory at config location with os error 45
Checklist
- [X] Modify `fluere-config/src/init.rs` ✓ https://github.com/SkuldNorniern/fluere/commit/534f9142e5c2bd829755c38fa3ba9e1a33873657 ![Flowchart](http://24.199.78.105:8082/public/9615e5e0c59ce822b72d5c4b92c41a72ccb5329ff6da5b41fc11920578c1ce49_74_flowchart.svg)