Skip to content

Commit 329e5fe

Browse files
committed
fix: set XDG_CONFIG_DIRS and XDG_DATA_DIRS defaults in tryGetPamEnvVars
When snap or other environments strip XDG_CONFIG_DIRS and XDG_DATA_DIRS, and PAM env files do not define them, child shells receive no value for these vars. Apply XDG Base Directory spec defaults (/etc/xdg and /usr/local/share:/usr/share) following the same pattern already used for XDG_RUNTIME_DIR. Fixes #2970 Signed-off-by: majiayu000 <1835304752@qq.com>
1 parent 0ee1224 commit 329e5fe

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/shellexec/shellexec.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,5 +760,11 @@ func tryGetPamEnvVars() map[string]string {
760760
if runtime_dir, ok := envVars["XDG_RUNTIME_DIR"]; !ok || runtime_dir == "" {
761761
envVars["XDG_RUNTIME_DIR"] = "/run/user/" + fmt.Sprint(os.Getuid())
762762
}
763+
if configDirs, ok := envVars["XDG_CONFIG_DIRS"]; !ok || configDirs == "" {
764+
envVars["XDG_CONFIG_DIRS"] = "/etc/xdg"
765+
}
766+
if dataDirs, ok := envVars["XDG_DATA_DIRS"]; !ok || dataDirs == "" {
767+
envVars["XDG_DATA_DIRS"] = "/usr/local/share:/usr/share"
768+
}
763769
return envVars
764770
}

0 commit comments

Comments
 (0)