summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server_config.go2
-rw-r--r--server_config_test.go25
2 files changed, 26 insertions, 1 deletions
diff --git a/server_config.go b/server_config.go
index 0a06d749..72585e06 100644
--- a/server_config.go
+++ b/server_config.go
@@ -90,7 +90,7 @@ func (cfg *ServerConfig) makeCommand() (func() *exec.Cmd, error) {
return func() *exec.Cmd {
cmd := exec.Command(cmd[0], cmd[1:]...)
if crd != nil {
- cmd.SysProcAttr.Credential = crd
+ cmd.SysProcAttr = &syscall.SysProcAttr{Credential: crd}
}
return cmd
diff --git a/server_config_test.go b/server_config_test.go
index bd3ee76b..fdd502c2 100644
--- a/server_config_test.go
+++ b/server_config_test.go
@@ -3,6 +3,9 @@ package roadrunner
import (
"testing"
"github.com/stretchr/testify/assert"
+ "os/user"
+ "runtime"
+ "strconv"
)
func Test_ServerConfig_PipeFactory(t *testing.T) {
@@ -68,3 +71,25 @@ func Test_ServerConfig_Cmd(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, cmd)
}
+
+func Test_ServerConfig_Cmd_Credentials(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("not supported on " + runtime.GOOS)
+ }
+
+ u, err := user.Current()
+ assert.NoError(t, err)
+
+ cfg := &ServerConfig{
+ Command: "php php-src/tests/client.php pipes",
+ User: u.Username,
+ Group: u.Gid,
+ }
+
+ cmd, err := cfg.makeCommand()
+ assert.NoError(t, err)
+ assert.NotNil(t, cmd)
+
+ assert.Equal(t, u.Uid, strconv.Itoa(int(cmd().SysProcAttr.Credential.Uid)))
+ assert.Equal(t, u.Gid, strconv.Itoa(int(cmd().SysProcAttr.Credential.Gid)))
+}