Skip to content

Commit a679462

Browse files
committed
DLPX-86523 CIS: /home filesystem and mount options
Fixing the headers in the changed files. Incoprorating new comments from Seb Resolving comments from Seb on redundant nodev PR URL: https://www.github.com/delphix/appliance-build/pull/756
1 parent 97652b1 commit a679462

File tree

8 files changed

+108
-24
lines changed

8 files changed

+108
-24
lines changed

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, 2025 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.
@@ -275,8 +275,8 @@ zfs create \
275275
# contents. During normal boot up, we'll rely on "/etc/fstab" to handle
276276
# these mounts.
277277
#
278-
mkdir -p "$DIRECTORY/export/home"
279-
mount -t zfs "$FSNAME/ROOT/$FSNAME/home" "$DIRECTORY/export/home"
278+
mkdir -p "$DIRECTORY/home"
279+
mount -t zfs "$FSNAME/ROOT/$FSNAME/home" "$DIRECTORY/home"
280280

281281
mkdir -p "$DIRECTORY/var/delphix"
282282
mount -t zfs "$FSNAME/ROOT/$FSNAME/data" "$DIRECTORY/var/delphix"
@@ -312,7 +312,7 @@ rsync --info=stats3 -WaAX binary/* "$DIRECTORY/"
312312
# automatically whenever we boot into the crash kernel.
313313
#
314314
cat <<-EOF >"$DIRECTORY/etc/fstab"
315-
rpool/ROOT/$FSNAME/home /export/home zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
315+
rpool/ROOT/$FSNAME/home /home zfs defaults,nodev,x-systemd.before=zfs-import-cache.service 0 0
316316
rpool/ROOT/$FSNAME/data /var/delphix zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
317317
rpool/ROOT/$FSNAME/log /var/log zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
318318
rpool/ROOT/$FSNAME/tmp /tmp zfs defaults,nosuid,nodev,exec,x-systemd.before=zfs-import-cache.service 0 0
@@ -357,7 +357,7 @@ done
357357

358358
umount "$DIRECTORY/var/log"
359359
umount "$DIRECTORY/var/delphix"
360-
umount "$DIRECTORY/export/home"
360+
umount "$DIRECTORY/home"
361361
umount "$DIRECTORY/tmp"
362362
umount "$DIRECTORY/var/tmp"
363363
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, 2025 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, 2025 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.unittest-internal/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2019 Delphix
2+
# Copyright 2019, 2025 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.
@@ -88,7 +88,7 @@
8888
- user:
8989
name: testrunner
9090
comment: "Delphix"
91-
home: /export/home/testrunner
91+
home: /home/testrunner
9292
groups: docker
9393
password:
9494
"$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, 2025 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, 2025 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/upgrade-container

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 \
@@ -205,6 +205,90 @@ function create_upgrade_container() {
205205
die "failed to create upgrade /var/tmp clone"
206206
fi
207207

208+
case "$type" in
209+
not-in-place)
210+
#
211+
# We need to ensure all of the upgrade container's datasets
212+
# are mounted before running "debootstrap". This way, if any
213+
# packages installed by "debootstrap" happen to deliver
214+
# files to any of these directories, they'll be propertly
215+
# delivered to the correct dataset, rather than the root
216+
# dataset.
217+
#
218+
mount_upgrade_container_dataset \
219+
"rpool/ROOT/$CONTAINER/home" "$DIRECTORY/home"
220+
mount_upgrade_container_dataset \
221+
"rpool/ROOT/$CONTAINER/data" "$DIRECTORY/var/delphix"
222+
mount_upgrade_container_dataset \
223+
"rpool/ROOT/$CONTAINER/log" "$DIRECTORY/var/log"
224+
225+
if $TMP_DATASETS_EXIST; then
226+
mount_upgrade_container_dataset \
227+
"rpool/ROOT/$CONTAINER/tmp" "$DIRECTORY/tmp"
228+
mount_upgrade_container_dataset \
229+
"rpool/ROOT/$CONTAINER/vartmp" "$DIRECTORY/var/tmp"
230+
fi
231+
232+
#
233+
# This function needs to return the container's name to
234+
# stdout, so that consumers of this function/script can
235+
# consume that name and then later start/stop/destroy the
236+
# container. Thus, we have to redirect the output from
237+
# debootstrap away from stdout.
238+
#
239+
# Also, we need to include the "systemd-container" package
240+
# when installing the base systemd with debootstrap so that
241+
# starting the container will work properly. Otherwise,
242+
# after starting the container, we won't be able to
243+
# communicate and later run commands in the container with
244+
# "systemd-run".
245+
#
246+
# On Ubuntu 20.04, in-order to satisfy some package
247+
# dependencies, we must set the variant to "minbase" and list
248+
# "ntp" in the include list before "systemd-container".
249+
# Setting the variant to minbase removes systemd from the
250+
# packages being installed by default. Systemd will still
251+
# be installed, but in a later pass, as a dependency of
252+
# systemd-container. The reason we need to go through those
253+
# hoops is the following:
254+
# - systemd has a package dependency on a "time-daemon"
255+
# virtual package, which is provided by either "ntp" or
256+
# "systemd-timesyncd".
257+
# - If a time-deamon is not already installed when
258+
# installing systemd, then systemd will try to
259+
# install systemd-timesyncd.
260+
# - systemd-timesyncd is not available in our upgrade
261+
# images because we install ntp and ntp conflicts with
262+
# systemd-timesyncd.
263+
# - Setting variant as minbase and list ntp before
264+
# systemd-container in the include list allows debootstrap
265+
# to install ntp before systemd, thus satisfying the
266+
# package dependencies.
267+
# Note that we do not run into those problems during live-build
268+
# because debootstrap is already run with variant=minbase and
269+
# systemd is not installed by debootstrap, but rather by
270+
# delphix-platform which pulls both ntp and systemd.
271+
#
272+
debootstrap --no-check-gpg --variant=minbase \
273+
--components=delphix --include=ntp,systemd-container \
274+
focal "$DIRECTORY" "file://$IMAGE_PATH" 1>&2 ||
275+
die "failed to debootstrap upgrade filesystem"
276+
277+
#
278+
# Now that we've successfully run "deboostrap", we can
279+
# unmount these datasets that were mounted above.
280+
#
281+
unmount_upgrade_container_dataset "rpool/ROOT/$CONTAINER/log"
282+
unmount_upgrade_container_dataset "rpool/ROOT/$CONTAINER/data"
283+
unmount_upgrade_container_dataset "rpool/ROOT/$CONTAINER/home"
284+
285+
if $TMP_DATASETS_EXIST; then
286+
unmount_upgrade_container_dataset "rpool/ROOT/$CONTAINER/tmp"
287+
unmount_upgrade_container_dataset "rpool/ROOT/$CONTAINER/vartmp"
288+
fi
289+
;;
290+
esac
291+
208292
#
209293
# We rely on the "/etc/fstab" file to mount the non-root ZFS
210294
# filesystems, so that when a specific rootfs dataset is booted,
@@ -213,7 +297,7 @@ function create_upgrade_container() {
213297
# before the zfs-import service is run.
214298
#
215299
cat <<-EOF >"$DIRECTORY/etc/fstab"
216-
rpool/ROOT/$CONTAINER/home /export/home zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
300+
rpool/ROOT/$CONTAINER/home /home zfs defaults,nodev,x-systemd.before=zfs-import-cache.service 0 0
217301
rpool/ROOT/$CONTAINER/data /var/delphix zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
218302
rpool/ROOT/$CONTAINER/log /var/log zfs defaults,x-systemd.before=zfs-import-cache.service 0 0
219303
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)