nosu is not su. It switches the user, but it exec(3)s w/o fork(2)ing.
50K+
nosu is not su(1). It switches the user and group and exec(3)s a command, but without fork(2)ing.
su(1) executes the given command in a separate process and waits for it to exit:
root@206aece88a19:/# ps -eH
PID TTY TIME CMD
6 pts/1 00:00:00 bash
17 pts/1 00:00:00 ps
1 pts/0 00:00:00 bash
13 pts/0 00:00:00 su
14 ? 00:00:00 sleep
root@206aece88a19:/#
nosu doesn't create any additional process:
root@206aece88a19:/# ps -eH
PID TTY TIME CMD
6 pts/1 00:00:00 bash
17 pts/1 00:00:00 ps
1 pts/0 00:00:00 bash
13 pts/0 00:00:00 sleep
root@206aece88a19:/#
sleep 10 & kill -9 $! works as expected.$ mkdir build
$ pushd build
$ cmake ..
$ make
# mv nosu /usr/local/bin/
nosu must be run as root:
# nosu USER GROUP COMMAND [ARGUMENT...]
For the user's group specify the empty string.
COPY --from=grandmaster/nosu:latest /usr/local/bin/nosu /usr/local/bin/nosu
$ docker run -it grandmaster/nosu bash
root@8189bcbd304f:/# nosu nobody www-data id
uid=65534(nobody) gid=33(www-data) groups=33(www-data)
root@8189bcbd304f:/#
$ docker run -it grandmaster/nosu bash
root@721c52f28ab7:/# nosu nobody www-data nosu root root id
setgid(): Operation not permitted
root@721c52f28ab7:/#
Content type
Image
Digest
Size
43.2 MB
Last updated
almost 8 years ago
docker pull grandmaster/nosu