From 9df16b85784fc6eb494444b04b04890c5c6ef0f8 Mon Sep 17 00:00:00 2001 From: bol-van Date: Sat, 6 Nov 2021 11:45:59 +0300 Subject: [PATCH] init.d: sysv adduser_compat check readonly /etc --- init.d/sysv/functions | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/init.d/sysv/functions b/init.d/sysv/functions index da5c361..1d88bcc 100644 --- a/init.d/sysv/functions +++ b/init.d/sysv/functions @@ -31,14 +31,18 @@ user_exists() useradd_compat() { # $1 - username - if exists useradd ; then - useradd --no-create-home --system --shell /bin/false $1 - elif is_linked_to_busybox adduser ; then - # busybox has special adduser syntax - adduser -S -H -D $1 - elif exists adduser; then - adduser --no-create-home --system --disabled-login $1 - fi + + # skip for readonly systems + [ -w "/etc" ] && { + if exists useradd ; then + useradd --no-create-home --system --shell /bin/false $1 + elif is_linked_to_busybox adduser ; then + # busybox has special adduser syntax + adduser -S -H -D $1 + elif exists adduser; then + adduser --no-create-home --system --disabled-login $1 + fi + } user_exists $1 } prepare_user()