summaryrefslogtreecommitdiff
path: root/EndoForge/openssh/run-sshd
blob: 20e82d8ef7be861955dede59da0eec1d6673a996 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
# Fix file ownership with fakeroot so that OpenSSH will run as a user.
#
# The ownership is not really changed on disk, but 'chmod go-w' might actually
# change permissions on disk.

case "$LD_PRELOAD" in
    libfakeroot-sysv.so) ;;
    '') exec fakeroot -- "$0" "$@" ;;
    *) exit 1 ;;
esac

fixperms()
{
    set -- "$1"
    local p="$1" oldp=
    while [ "$p" != "$oldp" ]
    do
        oldp=$p
        p=${p%/*}/
        set -- "$@" "$p"
    done
    chown root:root "$@"
    chmod go-w "$@"
}

fixperms "$HOME"/.ssh

PATH=/sbin:/usr/sbin:$PATH
cmd="$(which sshd) $*"
runuser -u "$USER" -- sh -c "$cmd"