Skip to content

Commit

Permalink
fix using rsync if running sftpgo as non-root user (#1535)
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Küttner <[email protected]>
  • Loading branch information
jkmw authored Apr 15, 2024
1 parent e315e48 commit 2bbd8b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/sftpd/cmd_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
package sftpd

import (
"os"
"os/exec"
"syscall"
)

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.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
}
Expand Down

0 comments on commit 2bbd8b3

Please sign in to comment.