Skip to content

Commit 35e0048

Browse files
committed
artifact: implement findHomeDir helper as specified
This makes a couple small changes to the findHomeDir helper function to properly match the described behavior. It will attempt to use os.UserHomeDir first, and if no path can be discovered, it will return /dev/null.
1 parent db65801 commit 35e0048

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

client/allocrunner/taskrunner/getter/util_linux.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ var initialDirs = map[string]string{
2828
// os.UserHomeDir returns an error, we return /root if the current process is being
2929
// run by root, or /dev/null otherwise.
3030
func findHomeDir() string {
31+
if home, err := os.UserHomeDir(); err == nil {
32+
return home
33+
}
34+
3135
// When running as a systemd unit the process may not have the $HOME
3236
// environment variable set, and os.UserHomeDir will return an error.
3337

@@ -42,7 +46,7 @@ func findHomeDir() string {
4246
}
4347

4448
// nothing safe to do
45-
return "/nonexistent"
49+
return "/dev/null"
4650
}
4751

4852
// defaultEnvironment is the default minimal environment variables for Linux.

0 commit comments

Comments
 (0)