fix using rsync if running sftpgo as non-root user (#1535)
Signed-off-by: Jerome Küttner <j.kuettner@mittwald.de>
This commit is contained in:
parent
e315e48c39
commit
2bbd8b3a5f
1 changed files with 3 additions and 1 deletions
|
@ -18,12 +18,14 @@
|
||||||
package sftpd
|
package sftpd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func wrapCmd(cmd *exec.Cmd, uid, gid int) *exec.Cmd {
|
func wrapCmd(cmd *exec.Cmd, uid, gid int) *exec.Cmd {
|
||||||
if uid > 0 || gid > 0 {
|
isCurrentUser := os.Getuid() == uid && os.Getgid() == gid
|
||||||
|
if (uid > 0 || gid > 0) && !isCurrentUser {
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
|
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue