}
func safcmEnviroment(groups []string) []string {
+ exe, err := os.Executable()
+ if err != nil {
+ panic(err) // should not happen on supported systems
+ }
+
env := os.Environ()
- // Provide additional environment variables so commands can check
- // group membership
+ // Provide additional environment variables
env = append(env,
+ fmt.Sprintf("SAFCM_HELPER=%s", exe),
fmt.Sprintf("SAFCM_GROUPS=%s", strings.Join(groups, " ")))
for _, x := range groups {
env = append(env, fmt.Sprintf("SAFCM_GROUP_%s=%s", x, x))
)
func TestSyncCommands(t *testing.T) {
+ exe, err := os.Executable()
+ if err != nil {
+ t.Fatal(err)
+ }
env := append(os.Environ(),
+ "SAFCM_HELPER="+exe,
"SAFCM_GROUPS=all group1 group2 host.example.org",
"SAFCM_GROUP_all=all",
"SAFCM_GROUP_group1=group1",