Fix feedback

This commit is contained in:
Theodor S. Midtlien
2026-06-08 16:15:07 +02:00
parent 23c82b32ff
commit 7b0f5f42f3
4 changed files with 24 additions and 2 deletions

View File

@@ -204,6 +204,9 @@ func (pm *ProfileManager) RemoveProfile(id string) error {
// This is needed for Android-specific path handling (netbird.cfg for default profile)
func (pm *ProfileManager) getProfileConfigPath(id string) (string, error) {
if id == "" || id == profilemanager.DefaultProfileName {
if !profilemanager.IsValidProfileFilenameStem(profilemanager.ID(id)) {
return "", fmt.Errorf("id %q is not valid", id)
}
// Android uses netbird.cfg for default profile instead of default.json
// Default profile is stored in root configDir, not in profiles/
return filepath.Join(pm.configDir, defaultConfigFilename), nil
@@ -226,6 +229,10 @@ func (pm *ProfileManager) GetStateFilePath(id string) (string, error) {
return filepath.Join(pm.configDir, "state.json"), nil
}
if !profilemanager.IsValidProfileFilenameStem(profilemanager.ID(id)) {
return "", fmt.Errorf("id %q is not valid", id)
}
profilesDir := filepath.Join(pm.configDir, profilesSubdir)
return filepath.Join(profilesDir, id+".state.json"), nil
}