summaryrefslogtreecommitdiffstats
path: root/etc/systemd/system-generators
diff options
context:
space:
mode:
authorlorenz <[email protected]>2020-01-08 02:03:00 +0100
committerBrian Behlendorf <[email protected]>2020-01-07 17:03:00 -0800
commit028e3b3b1a8d15a9ab5a0c925ca32fd3851cfa36 (patch)
treebeb384b78209d0d2f9e6a59bf6cd83837eed88f8 /etc/systemd/system-generators
parent67709516db7fb15f1e482a3c4f53ca7d4bc8a4ff (diff)
Avoid here-documents in systemd mount generator
On some systems - openSUSE, for example - there is not yet a writeable temporary file system available, so bash bails out with an error, 'cannot create temp file for here-document: Read-only file system', on the here documents in zfs-mount-generator. The simple fix is to change these into a multi-line echo statement. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-By: Richard Laager <[email protected]> Reviewed-by: George Melikov <[email protected]> Signed-off-by: Lorenz Hüdepohl <[email protected]> Closes #9802
Diffstat (limited to 'etc/systemd/system-generators')
-rwxr-xr-xetc/systemd/system-generators/zfs-mount-generator.in22
1 files changed, 14 insertions, 8 deletions
diff --git a/etc/systemd/system-generators/zfs-mount-generator.in b/etc/systemd/system-generators/zfs-mount-generator.in
index 850396fb6..066896009 100755
--- a/etc/systemd/system-generators/zfs-mount-generator.in
+++ b/etc/systemd/system-generators/zfs-mount-generator.in
@@ -104,8 +104,13 @@ process_line() {
fi
# Generate the key-load .service unit
- cat > "${dest_norm}/${keyloadunit}" << EOF
-# Automatically generated by zfs-mount-generator
+ #
+ # Note: It is tempting to use a `<<EOF` style here-document for this, but
+ # bash requires a writable /tmp or $TMPDIR for that. This is not always
+ # available early during boot.
+ #
+ echo \
+"# Automatically generated by zfs-mount-generator
[Unit]
Description=Load ZFS key for ${dataset}
@@ -120,8 +125,7 @@ ${pathdep}
Type=oneshot
RemainAfterExit=yes
ExecStart=${keyloadcmd}
-ExecStop=@sbindir@/zfs unload-key '${dataset}'
-EOF
+ExecStop=@sbindir@/zfs unload-key '${dataset}'" > "${dest_norm}/${keyloadunit}"
fi
# Update the dependencies for the mount file to require the
# key-loading unit.
@@ -235,8 +239,11 @@ EOF
# Create the .mount unit file.
# By ordering before zfs-mount.service, we avoid race conditions.
- cat > "${dest_norm}/${mountfile}" << EOF
-# Automatically generated by zfs-mount-generator
+ #
+ # (Do not use `<<EOF`-style here-documents for this, see warning above)
+ #
+ echo \
+"# Automatically generated by zfs-mount-generator
[Unit]
SourcePath=${cachefile}
@@ -249,8 +256,7 @@ Wants=${wants}
Where=${p_mountpoint}
What=${dataset}
Type=zfs
-Options=defaults${opts},zfsutil
-EOF
+Options=defaults${opts},zfsutil" > "${dest_norm}/${mountfile}"
# Finally, create the appropriate dependency
ln -s "../${mountfile}" "${req_dir}"