diff options
author | Antonio Russo <[email protected]> | 2019-05-07 12:32:23 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-05-07 09:32:23 -0700 |
commit | 6aff30ad803fd677d873dd5220a37e6e3876aa0d (patch) | |
tree | 73be73e786e8f3e1fbd2394610457a50ef1f170e /etc/systemd | |
parent | bca06413f7db1b04a943c04e7bacbcfa13a6727d (diff) |
Fix zfs-mount-generator for datasets with spaces
Alternative implementation of @rlaager's original modification
of zfs-mount-generator fix, with @chrisrd's comments. Set
IFS to be only the tab character, matching our `-H` call in
`zfs list`, allowing spaces to appear in dataset names (and
mountpoints).
Also adds comments explaining our rationale.
Reviewed-by: Chris Dunlop <[email protected]>
Reviewed-by: Richard Laager <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Antonio Russo <[email protected]>
Closes #8708
Closes #8718
Diffstat (limited to 'etc/systemd')
-rwxr-xr-x | etc/systemd/system-generators/zfs-mount-generator.in | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/etc/systemd/system-generators/zfs-mount-generator.in b/etc/systemd/system-generators/zfs-mount-generator.in index 2c93111f3..5428eb25d 100755 --- a/etc/systemd/system-generators/zfs-mount-generator.in +++ b/etc/systemd/system-generators/zfs-mount-generator.in @@ -22,7 +22,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -set -ef +set -e FSLIST="@sysconfdir@/zfs/zfs-list.cache" @@ -55,7 +55,12 @@ mkdir -p "${req_dir}" process_line() { - # -o name + # zfs list -H -o name,... + # fields are tab separated + IFS="$(printf '\t')" + # protect against special characters in, e.g., mountpoints + set -f + set -- $1 dataset="${1}" p_mountpoint="${2}" p_canmount="${3}" @@ -175,7 +180,7 @@ process_line() { # Automatically generated by zfs-mount-generator [Unit] -SourcePath=${FSLIST}/${cachefile} +SourcePath=${cachefile} Documentation=man:zfs-mount-generator(8) Before=local-fs.target zfs-mount.service After=zfs-import.target @@ -193,8 +198,8 @@ EOF } # Feed each line into process_line -for cachefile in $(ls "${FSLIST}") ; do +for cachefile in "${FSLIST}/"* ; do while read -r fs ; do - process_line $fs - done < "${FSLIST}/${cachefile}" + process_line "${fs}" + done < "${cachefile}" done |