executeRunUnder executes a command with specified PID as parent
(ctx context.Context, client *csclient.Client, beaconID string, action Action)
| 50 | |
| 51 | // executeRunUnder executes a command with specified PID as parent |
| 52 | func (e *Executor) executeRunUnder(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
| 53 | pidVal, ok := action.Parameters["pid"] |
| 54 | if !ok { |
| 55 | return "", fmt.Errorf("pid parameter required for run_under") |
| 56 | } |
| 57 | var pid int |
| 58 | switch v := pidVal.(type) { |
| 59 | case float64: |
| 60 | pid = int(v) |
| 61 | case int: |
| 62 | pid = v |
| 63 | default: |
| 64 | return "", fmt.Errorf("pid must be a number") |
| 65 | } |
| 66 | |
| 67 | command, ok := action.Parameters["command"].(string) |
| 68 | if !ok { |
| 69 | return "", fmt.Errorf("command parameter required for run_under") |
| 70 | } |
| 71 | args, _ := action.Parameters["args"].(string) // optional |
| 72 | |
| 73 | resp, err := client.RunUnder(ctx, beaconID, pid, command, args) |
| 74 | if err != nil { |
| 75 | return "", err |
| 76 | } |
| 77 | return e.waitForOutput(ctx, client, resp.TaskID) |
| 78 | } |
| 79 | |
| 80 | // executeRunNoOutput executes a command without blocking or returning output |
| 81 | func (e *Executor) executeRunNoOutput(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
no test coverage detected