aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorBryan McNulty <bryanmcnulty@protonmail.com>2025-04-10 22:02:23 -0500
committerBryan McNulty <bryanmcnulty@protonmail.com>2025-04-10 22:02:23 -0500
commitf6135204f3339393732444bf92cfdfc9cd932124 (patch)
tree8caee23508d484c457516e788920acfc274ea4fd /internal
parent1d82f299b433a17849b576b6e715a93240b29fd8 (diff)
downloadgoexec-f6135204f3339393732444bf92cfdfc9cd932124.tar.gz
goexec-f6135204f3339393732444bf92cfdfc9cd932124.zip
Add session hijack feature to TSCH module
Diffstat (limited to 'internal')
-rw-r--r--internal/exec/tsch/exec.go15
-rw-r--r--internal/exec/tsch/module.go6
2 files changed, 16 insertions, 5 deletions
diff --git a/internal/exec/tsch/exec.go b/internal/exec/tsch/exec.go
index 1996f27..49a2dc2 100644
--- a/internal/exec/tsch/exec.go
+++ b/internal/exec/tsch/exec.go
@@ -145,10 +145,12 @@ func (mod *Module) Exec(ctx context.Context, ecfg *exec.ExecutionConfig) (err er
} else {
taskPath := cfg.TaskPath
+
if taskPath == "" {
log.Debug().Msg("Task path not defined. Using random path")
taskPath = `\` + util.RandomString()
}
+
st := newSettings(true, true, false)
tk := newTask(st, nil, triggers{}, ecfg.ExecutableName, ecfg.ExecutableArgs)
@@ -157,12 +159,20 @@ func (mod *Module) Exec(ctx context.Context, ecfg *exec.ExecutionConfig) (err er
if err != nil {
return fmt.Errorf("call registerTask: %w", err)
}
+
if !cfg.NoDelete {
defer mod.deleteTask(ctx, taskPath)
}
+
+ var flags uint32
+
+ if cfg.SessionId != 0 {
+ flags |= 4
+ }
_, err := mod.tsch.Run(ctx, &itaskschedulerservice.RunRequest{
- Path: taskPath,
- Flags: 0, // Maybe we want to use these?
+ Path: taskPath,
+ Flags: flags,
+ SessionID: cfg.SessionId,
})
if err != nil {
log.Error().Str("task", taskPath).Err(err).Msg("Failed to run task")
@@ -170,6 +180,7 @@ func (mod *Module) Exec(ctx context.Context, ecfg *exec.ExecutionConfig) (err er
}
log.Info().Str("task", taskPath).Msg("Started task")
}
+
} else {
return fmt.Errorf("method '%s' not implemented", ecfg.ExecutionMethod)
}
diff --git a/internal/exec/tsch/module.go b/internal/exec/tsch/module.go
index 6e379a7..33c0723 100644
--- a/internal/exec/tsch/module.go
+++ b/internal/exec/tsch/module.go
@@ -14,9 +14,8 @@ type Module struct {
}
type MethodRegisterConfig struct {
- NoDelete bool
- CallDelete bool
- //TaskName string
+ NoDelete bool
+ CallDelete bool
TaskPath string
StartDelay time.Duration
StopDelay time.Duration
@@ -26,6 +25,7 @@ type MethodRegisterConfig struct {
type MethodDemandConfig struct {
NoDelete bool
CallDelete bool
+ SessionId uint32
TaskName string
TaskPath string
StopDelay time.Duration