]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm-remote/sync/commands.go
safcm: use Command struct instead of string to run commands
[safcm/safcm.git] / cmd / safcm-remote / sync / commands.go
index abc23bcc42a8af74264df5a8e095416a1433791f..84a318d79668b8e43118d9981e5d7736db3f766c 100644 (file)
@@ -40,7 +40,7 @@ func (s *Sync) syncCommands() error {
        // Regular commands afterwards so they can react on triggers if
        // necessary
        for _, x := range s.req.Commands {
-               err := s.syncCommand(x, "")
+               err := s.syncCommand(x.Cmd, "")
                if err != nil {
                        return err
                }
@@ -79,10 +79,15 @@ func (s *Sync) syncCommand(command string, trigger string) error {
 }
 
 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))