Merge lp:~jderose/ecryptfs/fix-1597154 into lp:ecryptfs
|Merged at revision:||882|
|Diff against target:||
20 lines (+8/-2)
1 file modified
|To merge this branch:||bzr merge lp:~jderose/ecryptfs/fix-1597154|
Description of the Change
In ecryptfs-setup-swap on line 169, the $drive and $partno are currently built from $swap like this:
But this is incorrect for /dev/nvme* and /dev/mmcblk* drives.
For example, when $swap is "/dev/nvme0n1p3", you get a correct $partno of "3", but an incorrect $drive of "/dev/nvme0n1p" (it should be "/dev/nvme0n1", with no "p" at the end).
To fix this I added a conditional to build $drive differently when $swap matches "^/dev/
To verify the logic I wrote a little (out-of-band) test script:
if echo $swap | grep -qE "^/dev/
Which correctly outputs:
/dev/sda3 /dev/sda 3
/dev/vda3 /dev/vda 3
/dev/nvme0n1p3 /dev/nvme0n1 3
/dev/mmcblk0p3 /dev/mmcblk0 3
I also tested this by running ecryptfs-setup-swap (from the source tree) on a system with an NVMe drive that previously hadn't had encrypted swap or encrypted home directory setup. With my change, ecryptfs-setup-swap now correctly marks the GPT swap partition as non-auto-mounting.