From 966ceb58717ad11940ecbae886f82d434064f0e4 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 10 Jun 2020 09:49:19 -0700 Subject: [PATCH] container: Fix upgrading of freedombox On a development container, we are currently changing the plinth user to be a non-system user to allow folder sharing with the host. This leads to `addgroup --system` and `adduser --system` failing when a non-system user/group already exists. This patch added checks to ensure that plinth user and group don't exist before trying to add them. Several packages in Debian seem to be doing similar checks before running adduser and addgroup. So, this patch is not bad to have even when container hack is not present. Closes: #1875. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- debian/freedombox.postinst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/freedombox.postinst b/debian/freedombox.postinst index 0682cfa5f..acd097800 100755 --- a/debian/freedombox.postinst +++ b/debian/freedombox.postinst @@ -16,8 +16,14 @@ sed -i 's+-:ALL EXCEPT root fbx (admin) (sudo):ALL+-:ALL EXCEPT root fbx plinth case "$1" in configure) - addgroup --system --quiet plinth - adduser --system --quiet --ingroup plinth --no-create-home --home /var/lib/plinth plinth + if ! getent group plinth >/dev/null; then + addgroup --system --quiet plinth + fi + + if ! getent passwd plinth >/dev/null; then + adduser --system --quiet --ingroup plinth --no-create-home --home /var/lib/plinth plinth + fi + chown plinth: /var/lib/plinth chown plinth: /var/lib/plinth/sessions