I'm testing the portability of some stuff I'm writing to BSD. It's working on Linux, FreeBSD, OpenBSD. It isn't working on NetBSD.
The following is on a fresh VM installation I've made just for the purpose of testing this. I've traced the issue to
NetBSD$ uname -a NetBSD NetBSD.local 9.1 NetBSD 9.1 (GENERIC) #0: Sun Oct 18 19:24:30 UTC 2020 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
NetBSD$ cat /etc/shells # $NetBSD: shells,v 1.3 1996/12/29 03:23:07 mrg Exp $ # # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/sh /bin/csh /bin/ksh /usr/pkg/bin/zsh /usr/pkg/bin/bash
NetBSD$ for s in /bin/sh /bin/csh /bin/ksh /usr/pkg/bin/zsh /usr/pkg/bin/bash ; do echo $s; $s -c "echo OK" ; done /bin/sh /bin/csh OK /bin/ksh /usr/pkg/bin/zsh OK /usr/pkg/bin/bash OK NetBSD$ su - Password: NetBSD# for s in /bin/sh /bin/csh /bin/ksh /usr/pkg/bin/zsh /usr/pkg/bin/bash ; do echo $s; $s -c "echo OK" ; done /bin/sh OK /bin/csh OK /bin/ksh OK /usr/pkg/bin/zsh OK /usr/pkg/bin/bash OK
sh -c "echo OK" and
ksh -c "echo OK" work when I'm a non-root user, and why do they work when I'm root?
Other shells (
bash) work correctly, as shown above.