From add15ac116687ead786f53e3ad99e82d13b15d14 Mon Sep 17 00:00:00 2001 From: TJ Hoplock Date: Wed, 28 Aug 2024 23:18:24 -0400 Subject: [PATCH] fix: filter `EUID` when sourcing variable files Fixes stuff like this: ``` [root@testbox-arch /]# cat /tmp/test-template-01J6DD4XM9BR40A7HZ5349T5TM Testing templating! Printing all variables available, via template ------------------- Printing host variables: EUID: 0 mango_group_template_var: Hi, I'm a group variable! mango_host_template_var: Hi, I'm a host variable! mango_host_var_for_override: This is the original host variable content. mango_role_template_var: Hi, I'm a role variable! package_install: pacman -Sy ------------------- Printing module variables: EUID: 0 mango_host_var_for_override: Module has updated host var! mango_module_template_var: Hi, I'm a module variable! ------------------- Printing all variables (merged, where module variables override host variables): EUID: 0 mango_group_template_var: Hi, I'm a group variable! mango_host_template_var: Hi, I'm a host variable! mango_host_var_for_override: Module has updated host var! mango_module_template_var: Hi, I'm a module variable! mango_role_template_var: Hi, I'm a role variable! package_install: pacman -Sy ``` --- internal/shell/shell.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/shell/shell.go b/internal/shell/shell.go index 367658c..8ede71a 100644 --- a/internal/shell/shell.go +++ b/internal/shell/shell.go @@ -25,7 +25,7 @@ type VariableMap map[string]string // func with const []string return containing environment variables that get // removed from the environent when sourcing a file func getEnvVarBlacklist() []string { - return []string{"PWD", "HOME", "PATH", "IFS", "OPTIND", "GID", "UID"} + return []string{"PWD", "HOME", "PATH", "IFS", "OPTIND", "GID", "UID", "EUID"} } // SourceFile()/SourceNode() functions inspired heavily by old convenience