Skip to content

Commit f692156

Browse files
justsanjeevclaude
authored andcommitted
DLPX-86523 CIS: /home filesystem and mount options
Squash of #756: mount the home ZFS dataset at /home instead of /export/home for CIS compliance, with nodev,nosuid on the /home fstab entry. Includes the build-side fstab (90-raw-disk-image), upgrade-container template, ansible role path updates, and the upgrade execute changes as authored in #756. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3ae2aa3 commit f692156

10 files changed

Lines changed: 70 additions & 24 deletions

File tree

live-build/config/hooks/vm-artifacts/90-raw-disk-image.binary

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -ex
22
#
3-
# Copyright 2018 Delphix
3+
# Copyright 2018, 2026 Delphix
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -274,8 +274,8 @@ zfs create \
274274
# contents. During normal boot up, we'll rely on "/etc/fstab" to handle
275275
# these mounts.
276276
#
277-
mkdir -p "$DIRECTORY/export/home"
278-
mount -t zfs "$FSNAME/ROOT/$FSNAME/home" "$DIRECTORY/export/home"
277+
mkdir -p "$DIRECTORY/home"
278+
mount -t zfs "$FSNAME/ROOT/$FSNAME/home" "$DIRECTORY/home"
279279

280280
mkdir -p "$DIRECTORY/var/delphix"
281281
mount -t zfs "$FSNAME/ROOT/$FSNAME/data" "$DIRECTORY/var/delphix"
@@ -314,7 +314,7 @@ rsync --info=stats3 -WaAX binary/* "$DIRECTORY/"
314314
# automatically whenever we boot into the crash kernel.
315315
#
316316
cat <<-EOF >"$DIRECTORY/etc/fstab"
317-
rpool/ROOT/$FSNAME/home /export/home zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
317+
rpool/ROOT/$FSNAME/home /home zfs defaults,nodev,nosuid,x-systemd.before=zfs-import-cache.service 0 0
318318
rpool/ROOT/$FSNAME/data /var/delphix zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
319319
rpool/ROOT/$FSNAME/log /var/log zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
320320
rpool/ROOT/$FSNAME/tmp /tmp zfs defaults,nosuid,nodev,exec,x-systemd.before=zfs-import-cache.service 0 0
@@ -440,7 +440,7 @@ done
440440

441441
umount "$DIRECTORY/var/log"
442442
umount "$DIRECTORY/var/delphix"
443-
umount "$DIRECTORY/export/home"
443+
umount "$DIRECTORY/home"
444444
umount "$DIRECTORY/tmp"
445445
umount "$DIRECTORY/var/tmp"
446446
umount "/var/crash"

live-build/misc/ansible-roles/appliance-build.masking-development/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2018 Delphix
2+
# Copyright 2018, 2026 Delphix
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -26,14 +26,14 @@
2626
- git:
2727
repo: "https://{{ lookup('env', 'GITHUB_TOKEN') }}@github.com/delphix/dms-core-gate.git"
2828
dest:
29-
"/export/home/delphix/dms-core-gate"
29+
"/home/delphix/dms-core-gate"
3030
version: "develop"
3131
accept_hostkey: yes
3232
update: no
3333
when: lookup('env', 'GITHUB_TOKEN') != ''
3434

3535
- file:
36-
path: "/export/home/delphix/{{ item }}"
36+
path: "/home/delphix/{{ item }}"
3737
owner: delphix
3838
group: staff
3939
mode: "g+w"

live-build/misc/ansible-roles/appliance-build.minimal-common/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2018 Delphix
2+
# Copyright 2018, 2026 Delphix
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626
no_log: true
2727

2828
- file:
29-
path: /export/home
29+
path: /home
3030
state: directory
3131
mode: 0755
3232

@@ -39,7 +39,7 @@
3939
shell: /bin/bash
4040
create_home: yes
4141
comment: Delphix User
42-
home: /export/home/delphix
42+
home: /home/delphix
4343
password:
4444
"{{ lookup('env', 'APPLIANCE_PASSWORD') | password_hash('sha512') }}"
4545

live-build/misc/ansible-roles/appliance-build.minimal-internal/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
ansible.builtin.pip:
3535
name: awscli
3636
break_system_packages: true
37+
extra_args: --no-cache-dir
3738
become: true
3839

3940
# Add /usr/local/bin to the PATH (awscli needs it)

live-build/misc/ansible-roles/appliance-build.unittest-internal/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
- user:
9595
name: testrunner
9696
comment: "Delphix"
97-
home: /export/home/testrunner
97+
home: /home/testrunner
9898
groups: docker
9999
password:
100100
"$6$pWQE0MPZWgue7fNC$8RvR0u04Mt67792b.x4ao0G2Z/H/hrYPWezOqCkz59MIA\

live-build/misc/ansible-roles/appliance-build.virtualization-development/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2018 Delphix
2+
# Copyright 2018, 2026 Delphix
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -73,14 +73,14 @@
7373
7474
- git:
7575
repo: "https://{{ lookup('env', 'GITHUB_TOKEN') }}@github.com/delphix/dlpx-app-gate.git"
76-
dest: "/export/home/delphix/dlpx-app-gate"
76+
dest: "/home/delphix/dlpx-app-gate"
7777
version: "develop"
7878
accept_hostkey: yes
7979
update: no
8080
when: lookup('env', 'GITHUB_TOKEN') != ''
8181

8282
- file:
83-
path: "/export/home/delphix/{{ item }}"
83+
path: "/home/delphix/{{ item }}"
8484
owner: delphix
8585
group: staff
8686
mode: "g+w"

live-build/misc/ansible-roles/appliance-build.zfsonlinux-development/tasks/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2018 Delphix
2+
# Copyright 2018, 2026 Delphix
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -67,26 +67,26 @@
6767
- git:
6868
repo: "https://{{ lookup('env', 'GITHUB_TOKEN') }}@github.com/delphix/zfs.git"
6969
dest:
70-
"/export/home/delphix/zfs"
70+
"/home/delphix/zfs"
7171
version: develop
7272
accept_hostkey: yes
7373
update: no
7474
when: lookup('env', 'GITHUB_TOKEN') != ''
7575

7676
- file:
77-
path: "/export/home/delphix/zfs"
77+
path: "/home/delphix/zfs"
7878
owner: delphix
7979
group: staff
8080
state: directory
8181
recurse: yes
8282

8383
- file:
84-
path: "/export/home/delphix/.cargo/"
84+
path: "/home/delphix/.cargo/"
8585
state: directory
8686
owner: delphix
8787
group: staff
8888
- copy:
89-
dest: "/export/home/delphix/.cargo/config.toml"
89+
dest: "/home/delphix/.cargo/config.toml"
9090
content: |
9191
[target.x86_64-unknown-linux-gnu]
9292
rustflags = ["-C", "link-arg=-B/usr/libexec/mold"]

upgrade/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ resemble the following:
8989

9090
A "rootfs container" is a collection of ZFS datasets that can be used as
9191
the "root filesytsem" of the appliance. This includes a dataset for "/"
92-
of the appliance, but also seperate datasets for "/export/home" and
92+
of the appliance, but also seperate datasets for "/home" and
9393
"/var/delphix".
9494

9595
Here's an example of the datasets for a rootfs container:

upgrade/upgrade-scripts/execute

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,32 @@ if [[ -n "$CURRENT_VERSION" ]]; then
221221
"$ROOTFS_CONTAINER" "$ROOTFS_CONTAINER@execute-upgrade.$UNIQUE"
222222
fi
223223

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+
224250
#
225251
# Delete the central /etc/apt/sources.list and also all files in
226252
# /etc/apt/sources.list.d/ because only the Delphix repository
@@ -752,6 +778,25 @@ if ! systemd-detect-virt -qc; then
752778
die "failed to set-bootfs '$ROOTFS_CONTAINER'"
753779
fi
754780

781+
#
782+
# Ensure nodev and nosuid mount options are present for the /home entry
783+
# in /etc/fstab on the running host system. This is required for CIS
784+
# compliance on systems being upgraded that predate this hardening.
785+
# New upgrade containers already have these options set by upgrade-container.
786+
# This check is idempotent and only runs outside a container, consistent
787+
# with the pattern used for the GRUB update above.
788+
#
789+
if ! systemd-detect-virt -qc; then
790+
if grep -qE '^[^#].*[[:space:]]/home[[:space:]]' /etc/fstab; then
791+
if ! grep -qE '^[^#].*[[:space:]]/home[[:space:]].*nodev' /etc/fstab ||
792+
! grep -qE '^[^#].*[[:space:]]/home[[:space:]].*nosuid' /etc/fstab; then
793+
sed -i '/^[^#].*[[:space:]]\/home[[:space:]]/ s/defaults/defaults,nodev,nosuid/' \
794+
/etc/fstab ||
795+
die "failed to add nodev,nosuid to /home entry in /etc/fstab"
796+
fi
797+
fi
798+
fi
799+
755800
systemctl reload delphix-platform.service ||
756801
die "failed to reload delphix-platform.service"
757802

upgrade/upgrade-scripts/upgrade-container

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright 2018, 2025 Delphix
3+
# Copyright 2018, 2026 Delphix
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -177,7 +177,7 @@ function create_upgrade_container() {
177177
-o mountpoint=legacy \
178178
"$ROOTFS_DATASET/home@$SNAPSHOT_NAME" \
179179
"rpool/ROOT/$CONTAINER/home" ||
180-
die "failed to create upgrade /export/home clone"
180+
die "failed to create upgrade /home clone"
181181

182182
zfs clone \
183183
-o mountpoint=legacy \
@@ -213,7 +213,7 @@ function create_upgrade_container() {
213213
# before the zfs-import service is run.
214214
#
215215
cat <<-EOF >"$DIRECTORY/etc/fstab"
216-
rpool/ROOT/$CONTAINER/home /export/home zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
216+
rpool/ROOT/$CONTAINER/home /home zfs defaults,nodev,nosuid,x-systemd.before=zfs-import-cache.service 0 0
217217
rpool/ROOT/$CONTAINER/data /var/delphix zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
218218
rpool/ROOT/$CONTAINER/log /var/log zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
219219
rpool/crashdump /var/crash zfs defaults,x-systemd.before=zfs-import-cache.service,x-systemd.before=kdump-tools.service 0 0

0 commit comments

Comments
 (0)