cryptroot hook does not handle quotes in fstab

Bug #784203 reported by xenoson
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cryptsetup (Ubuntu)
Triaged
Undecided
Unassigned

Bug Description

Binary package hint: cryptsetup

Hello!
It seems all the utils handle UUID="" and LABEL="" statements in fstab with quotes like blkid prints them.
While chasing a missing conf/conf.d/cryptroot in initrd.img I noticed a misleading warning message, but sure enough another opened crypto container does not need to be in /etc/crypttab so this should not be reason to complain about an invalid line.

[ -h "$dev" ] fails on something like "/dev/disk/by-uuid/"foo"" so I would suggest we strip quotes first.

Tags: patch
Revision history for this message
xenoson (xenoson) wrote :
tags: added: patch
Revision history for this message
Steve Langasek (vorlon) wrote :

Thanks for the patch!

@@ -181,11 +181,16 @@
  key=$( echo $opt | cut -d " " -f3 )
  rootopts=$( echo $opt | cut -d " " -f4- )

- if [ -z "$opt" ] || [ -z "$source" ] || [ -z "$key" ] || [ -z "$rootopts" ]; then
- echo "cryptsetup: WARNING: invalid line in /etc/crypttab - $opt" >&2
+ if [ -z "$opt" ]; then
+ echo "cryptsetup: INFO: mapped volume $target has no line in /etc/crypttab" >&2
   return 1
  fi

+ if [ -z "$source" ] || [ -z "$key" ] || [ -z "$rootopts" ]; then
+ echo "cryptsetup: WARNING: invalid line in /etc/crypttab - $opt" >&2
+ return 1
+ fi
+
  # Sanity checks for $source
  if [ -h "$source" ]; then
   link=$(readlink -nqe "$source")

This seems unrelated to the present bug report. Isn't only the change to canonical_dev needed?

Can you provide an example of a tool that handles quotes in /etc/fstab as you describe, that I can check this behavior against?

Changed in cryptsetup (Ubuntu):
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for cryptsetup (Ubuntu) because there has been no activity for 60 days.]

Changed in cryptsetup (Ubuntu):
status: Incomplete → Expired
Revision history for this message
xenoson (xenoson) wrote :

Hey, sorry I didn't check back here for a while.
Steve you are right, on the first glance two unrelated things.
My use case gives the relation: I was restoring a box from file system backups to a crypt container with new file systems and UUIDs and used blkid output to edit my fstab. I saw the output and thought, ok do we put quotes there now? In the changeroot 'mount -a' worked with quotes so it seemed the way to go. But building the initrd failed with warnings about invalid lines. I changed back the quotes, still got the warning but found my conf/conf.d/cryptroot in the ramdisk image. So I investigated the reason for the warning that didn't give helpful information.

Steve Langasek (vorlon)
Changed in cryptsetup (Ubuntu):
status: Expired → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.