Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid here-documents in systemd mount generator #9802

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions etc/systemd/system-generators/zfs-mount-generator.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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.
Expand Down Expand Up @@ -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}
Expand All @@ -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}"
Expand Down