From c94e416035ae7ce0cac937d7eddece9f16bce424 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 23 Nov 2020 14:18:24 -0700 Subject: [PATCH] install.sh: avoid pointless warning when not using a jail Do not attempt to change the owner of the project database passwd and group files to the cgi user if a chroot jail is not in use. Since sudo privileges are not expected when a chroot jail is not in use, if the cgi user differs from the mirror user then a needless warning will be emitted. Just use the mirror user in this case to avoid the warning. The group will still be set correctly in either case (or a warning will be emitted) and that's what really matters in order to provide write access. Signed-off-by: Kyle J. McKay --- install.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index b41d8ab..4d2b866 100755 --- a/install.sh +++ b/install.sh @@ -823,8 +823,18 @@ mkdir -p "$cfg_chroot" "$cfg_chroot/etc" touch "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" chown "$cfg_mirror_user""$owngroup" "$cfg_chroot/etc" || echo "WARNING: Cannot chown $cfg_mirror_user$owngroup $cfg_chroot/etc" -chown "$cfg_cgi_user""$owngroup" "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" || - echo "WARNING: Cannot chown $cfg_cgi_user$owngroup the etc/passwd and/or etc/group files" +if [ -n "$usejail" ]; then + chown "$cfg_cgi_user""$owngroup" "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" || + echo "WARNING: Cannot chown $cfg_cgi_user$owngroup the etc/passwd and/or etc/group files" +else + # If a chroot jail is not in use, sudo privileges are neither expected nor required + # which means it will not be possible to change the owner of the passwd and group + # files if it differs from the mirror user. And that's okay, provided the group + # can still be set correctly to the owning group. But, just in case we're running + # as root, go ahead and set the owner to the mirror user. + chown "$cfg_mirror_user""$owngroup" "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" || + echo "WARNING: Cannot chown $cfg_mirror_user$owngroup the etc/passwd and/or etc/group files" +fi chmod g+w "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" || echo "WARNING: Cannot chmod g+w the etc/passwd and/or etc/group files" chmod 02775 "$cfg_chroot/etc" || echo "WARNING: Cannot chmod 02775 $cfg_chroot/etc" -- 2.11.4.GIT