pkg: add a user for www-only access #8521

Added a group as well, but we can always drop it if it doesn't
make sense.
This commit is contained in:
Franco Fichtner 2025-04-23 09:07:42 +02:00
parent bdb3f73315
commit 08a86fdae9

View file

@ -1,3 +1,23 @@
PW=/usr/sbin/pw
USER=wwwonly
UID=789
GROUP=${USER}
GID=${UID}
if ! ${PW} groupshow ${GROUP} >/dev/null 2>&1; then
echo "Creating group '${GROUP}' with gid '${GID}'"
${PW} groupadd ${GROUP} -g ${GID}
else
echo "Using existing group '${GROUP}'"
fi
if ! ${PW} usershow ${USER} >/dev/null 2>&1; then
echo "Creating user '${USER}' with uid '${UID}'"
${PW} useradd ${USER} -u ${UID} -g ${GID} -c "World Wide Web Only" -d /nonexistent -s /usr/sbin/nologin
else
echo "Using existing user '${USER}'"
fi
echo "Updating /etc/shells"
cp /etc/shells /etc/shells.bak
(grep -v /usr/local/sbin/opnsense-shell /etc/shells.bak; \