windows plugin: prioritize AppData over default user directory ( UserProfile )

It was the default behaviour before.
It is also standard for a binary to use files from the AppData directory. ex: c453e0c757/google/default.go (L104)

More on home: https://en.wikipedia.org/wiki/Home_directory
This commit is contained in:
Adrien Delorme 2019-01-04 14:10:30 +01:00
parent 624c58c678
commit 7384b86e95
2 changed files with 12 additions and 4 deletions

View File

@ -44,12 +44,17 @@ func ConfigTmpDir() (string, error) {
func homeDir() (string, error) {
// First prefer the HOME environmental variable
// Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470
if home := os.Getenv("HOME"); home != "" {
log.Printf("Detected home directory from env var: %s", home)
return home, nil
}
if home := os.Getenv("APPDATA"); home != "" {
log.Printf("Detected home directory from env var: %s", home)
return home, nil
}
// Fall back to the passwd database if not found which follows
// the same semantics as bourne shell
u, err := user.Current()

View File

@ -52,10 +52,13 @@ later, it will take precedence over one found earlier.
1. The directory where `packer` is, or the executable directory.
2. `~/.packer.d/plugins` on Unix systems or `%APPDATA%/packer.d/plugins` on
Windows.
2. The `$HOME/packer.d/plugins` directory, if `$HOME` is defined (unix)
3. The current working directory.
3. The `%APPDATA%/packer.d/plugins` if `%APPDATA%` is defined (windows)
4. The `%USERPROFILE%/packer.d/plugins` if `%USERPROFILE%` is defined (windows)
4. The current working directory.
The valid types for plugins are: