@@ -183,13 +183,6 @@ if [[ -n "$CURRENT_VERSION" ]]; then
183183 [[ -n " $ROOTFS_CONTAINER " ]] ||
184184 die " unable to determine currently mounted rootfs container"
185185
186- #
187- # Update fstab for security compliance before performing any upgrade
188- # operations. This ensures the system is properly configured before
189- # package installation and snapshot creation.
190- #
191- update_fstab_for_upgrade
192-
193186 #
194187 # It's possible for this script to be run multiple times,
195188 # and each time this script is run, we want to keep a
@@ -228,6 +221,32 @@ if [[ -n "$CURRENT_VERSION" ]]; then
228221 " $ROOTFS_CONTAINER " " $ROOTFS_CONTAINER @execute-upgrade.$UNIQUE "
229222fi
230223
224+ #
225+ # Home directories were previously mounted under /export/home, and this was
226+ # changed to /home. This upgrade logic updates the /etc/fstab and /etc/passwd
227+ # files to reflect that change.
228+ #
229+ # Home directories will be mounted in both /export/home and /home until the
230+ # system is rebooted to ensure that running processes referencing the old
231+ # /export/home paths continue to function while also enabling new logins
232+ # under /home to work.
233+ #
234+ # This check only runs outside a container and during upgrades, consistent
235+ # with the pattern used for the GRUB and nodev/nosuid updates.
236+ #
237+ if [[ -n " $CURRENT_VERSION " ]] && ! systemd-detect-virt -qc; then
238+ if grep -q " /export/home" /etc/fstab; then
239+ sed -i ' s|/export/home|/home|g' /etc/fstab ||
240+ die " failed to update /export/home to /home in /etc/fstab"
241+ mount /home || die " failed to mount /home"
242+ fi
243+
244+ if grep -q " /export/home" /etc/passwd; then
245+ sed -i ' s|/export/home|/home|g' /etc/passwd ||
246+ die " failed to update /export/home to /home in /etc/passwd"
247+ fi
248+ fi
249+
231250#
232251# Delete the central /etc/apt/sources.list and also all files in
233252# /etc/apt/sources.list.d/ because only the Delphix repository
@@ -761,6 +780,25 @@ if ! systemd-detect-virt -qc; then
761780 die " failed to set-bootfs '$ROOTFS_CONTAINER '"
762781fi
763782
783+ #
784+ # Ensure nodev and nosuid mount options are present for the /home entry
785+ # in /etc/fstab on the running host system. This is required for CIS
786+ # compliance on systems being upgraded that predate this hardening.
787+ # New upgrade containers already have these options set by upgrade-container.
788+ # This check is idempotent and only runs outside a container, consistent
789+ # with the pattern used for the GRUB update above.
790+ #
791+ if ! systemd-detect-virt -qc; then
792+ if grep -qE ' ^[^#].*[[:space:]]/home[[:space:]]' /etc/fstab; then
793+ if ! grep -qE ' ^[^#].*[[:space:]]/home[[:space:]].*nodev' /etc/fstab ||
794+ ! grep -qE ' ^[^#].*[[:space:]]/home[[:space:]].*nosuid' /etc/fstab; then
795+ sed -i ' /^[^#].*[[:space:]]\/home[[:space:]]/ s/defaults/defaults,nodev,nosuid/' \
796+ /etc/fstab ||
797+ die " failed to add nodev,nosuid to /home entry in /etc/fstab"
798+ fi
799+ fi
800+ fi
801+
764802systemctl reload delphix-platform.service ||
765803 die " failed to reload delphix-platform.service"
766804
0 commit comments