Skip to content

Commit ef744c6

Browse files
committed
Fix broken argument handling
1 parent 343086e commit ef744c6

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

cerberus.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ func (i *InstallCommand) checkAndConfigureArgs() error {
156156
}
157157
}
158158

159+
if len(i.Args) > 0 {
160+
i.logDebug("Removing leading/trailing quotes from arguments...")
161+
for j := range i.Args {
162+
n := len(i.Args[j]) - 1
163+
if i.Args[j][0] == '\'' && i.Args[j][n] == '\'' {
164+
i.Args[j] = i.Args[j][1:n]
165+
}
166+
}
167+
}
168+
159169
if i.DisplayName == "" {
160170
i.logDebug("Creating a display name..")
161171
i.DisplayName = i.Name
@@ -255,7 +265,7 @@ type cerberusSvc struct {
255265
// Execute will be called when the service is started.
256266
func (c *cerberusSvc) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) {
257267
changes <- svc.Status{State: svc.StartPending}
258-
cmd := exec.Cmd{Path: c.cfg.ExePath, Dir: c.cfg.WorkDir, Args: c.cfg.Args, Env: append(os.Environ(), c.cfg.Env...)}
268+
cmd := exec.Cmd{Path: c.cfg.ExePath, Dir: c.cfg.WorkDir, Args: append([]string{c.cfg.ExePath}, c.cfg.Args...), Env: append(os.Environ(), c.cfg.Env...)}
259269
if err := cmd.Start(); err != nil {
260270
c.log.Error(2, fmt.Sprintf("Failed to start service: %v", err))
261271
return false, 2
@@ -275,7 +285,7 @@ loop:
275285
select {
276286
case err := <-done:
277287
if err != nil {
278-
c.log.Error(3, fmt.Sprintf("Executable exited with error: %v", err))
288+
c.log.Error(3, fmt.Sprintf("Executable '%v' exited with error: %v", c.cfg.ExePath, err))
279289
exitCode = 3
280290
}
281291
break loop

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/jessevdk/go-flags"
99
)
1010

11-
const version = "1.0.0"
11+
const version = "1.0.1"
1212

1313
var installCommand cerberus.InstallCommand
1414
var runCommand cerberus.RunCommand

0 commit comments

Comments
 (0)