diff --git a/sftpd/internal_test.go b/sftpd/internal_test.go index 70379acf..e000be1c 100644 --- a/sftpd/internal_test.go +++ b/sftpd/internal_test.go @@ -7,7 +7,6 @@ import ( "io/ioutil" "net" "os" - "os/exec" "runtime" "strings" "testing" @@ -1213,17 +1212,3 @@ func TestSFTPExtensions(t *testing.T) { } sftpExtensions = initialSFTPExtensions } - -func TestWrapCmd(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("executing a command as another uid/gid is not supported on Windows") - } - cmd := exec.Command("ls") - cmd = wrapCmd(cmd, 1000, 1001) - if cmd.SysProcAttr.Credential.Uid != 1000 { - t.Errorf("unexpected uid") - } - if cmd.SysProcAttr.Credential.Gid != 1001 { - t.Errorf("unexpected gid") - } -} diff --git a/sftpd/internal_unix_test.go b/sftpd/internal_unix_test.go new file mode 100644 index 00000000..6ccf87be --- /dev/null +++ b/sftpd/internal_unix_test.go @@ -0,0 +1,19 @@ +// +build !windows + +package sftpd + +import ( + "os/exec" + "testing" +) + +func TestWrapCmd(t *testing.T) { + cmd := exec.Command("ls") + cmd = wrapCmd(cmd, 1000, 1001) + if cmd.SysProcAttr.Credential.Uid != 1000 { + t.Errorf("unexpected uid") + } + if cmd.SysProcAttr.Credential.Gid != 1001 { + t.Errorf("unexpected gid") + } +}