2022-07-18 11:43:25 +00:00
|
|
|
// Copyright (C) 2019-2022 Nicola Murino
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published
|
|
|
|
// by the Free Software Foundation, version 3.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2021-08-19 13:51:43 +00:00
|
|
|
//go:build !windows
|
2019-12-26 07:29:38 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package sftpd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"testing"
|
2020-05-06 17:36:34 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-12-26 07:29:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWrapCmd(t *testing.T) {
|
|
|
|
cmd := exec.Command("ls")
|
|
|
|
cmd = wrapCmd(cmd, 1000, 1001)
|
2020-05-06 17:36:34 +00:00
|
|
|
assert.Equal(t, uint32(1000), cmd.SysProcAttr.Credential.Uid)
|
|
|
|
assert.Equal(t, uint32(1001), cmd.SysProcAttr.Credential.Gid)
|
2019-12-26 07:29:38 +00:00
|
|
|
}
|