Skip to content
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

Read-only filesystem fixes for when ~/.config is not writable #3990

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions v2/pkg/catalog/config/nucleiconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/projectdiscovery/gologger"
errorutil "github.com/projectdiscovery/utils/errors"
fileutil "github.com/projectdiscovery/utils/file"
folderutil "github.com/projectdiscovery/utils/folder"
)

// DefaultConfig is the default nuclei configuration
Expand Down Expand Up @@ -290,8 +289,9 @@ func init() {
gologger.Error().Msgf("failed to create config directory at %v got: %s", ConfigDir, err)
}
}
homeDir, _ := os.UserHomeDir()
DefaultConfig = &Config{
homeDir: folderutil.HomeDirOrDefault(""),
homeDir: homeDir,
configDir: ConfigDir,
}
// try to read config from file
Expand All @@ -314,11 +314,11 @@ func getDefaultConfigDir() string {
// Review Needed: Earlier a dependency was used to locate home dir
// i.e "github.com/mitchellh/go-homedir" not sure if it is needed
// Even if such case exists it should be abstracted via below function call in utils/folder
homedir := folderutil.HomeDirOrDefault("")
// TBD: we should probably stick to specification and use config directories provided by distro
// instead of manually creating one since $HOME/.config/ is config directory of Linux desktops
// Ref: https://pkg.go.dev/os#UserConfigDir
// some distros like NixOS or others have totally different config directories this causes issues for us (since we are not using os.UserConfigDir)
homedir, _ := os.UserConfigDir()
userCfgDir := filepath.Join(homedir, ".config")
return filepath.Join(userCfgDir, "nuclei")
}
Expand Down
Loading