SkuldNorniern / fluere

Fluere is a powerful and versatile tool designed for network monitoring and analysis. It is capable of capturing network packets in pcap format and converting them into NetFlow data, providing a comprehensive view of network traffic. It also Provides Terminal User Interface.
Apache License 2.0
29 stars 3 forks source link

fix: Failed to create directory (os error 45) #74

Closed security-yunjae closed 7 months ago

security-yunjae commented 8 months ago

Details

OS: macOS Sonoma 14.1 Arch: Intel

Failed to create directory at config location with os error 45

sudo ./fluere online -i en0
Password:
Online mode
Interface en0 selected
path_file: "/home/<User>/.config/fluere/fluere.toml"
Failed to create directory at "/home/<User>/.config/fluere": Operation not supported (os error 45)
Requested Device : en0
-en0 device has been captured! in 3.757678ms
Created directory: ./output
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)
sweep-ai[bot] commented 8 months ago

Here's the PR! https://github.com/SkuldNorniern/fluere/pull/77.

Sweep Basic Tier: I'm using GPT-4. You have 3 GPT-4 tickets left for the month and 3 for the day.

For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets).

Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/SkuldNorniern/fluere/blob/0efb6ed6386c6abefef03dd2d6c703385eebb304/fluere-config/src/init.rs#L1-L71

Step 2: ⌨️ Coding

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
}


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/fix-directory-creation-issue.


🎉 Latest improvements to Sweep:


💡 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

SkuldNorniern commented 7 months ago

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