Merge lp:~alberto-o/ecryptfs/swapfile-fix into lp:ecryptfs

Proposed by Alberto Pianon on 2017-03-06
Status: Needs review
Proposed branch: lp:~alberto-o/ecryptfs/swapfile-fix
Merge into: lp:ecryptfs
Diff against target: 60 lines (+15/-6)
2 files modified
debian/changelog (+6/-2)
src/utils/ecryptfs-setup-swap (+9/-4)
To merge this branch: bzr merge lp:~alberto-o/ecryptfs/swapfile-fix
Reviewer Review Type Date Requested Status
eCryptfs 2017-03-06 Pending
Review via email: mp+319130@code.launchpad.net

Description of the change

This fixes a small but very important bug (at least for Ubuntu): since Zesty uses swapfiles by default, because of this bug if you choose "encrypt home folder" during installation (which forces also swap encryption), after installation the system hangs a lot on every boot because it cannot activate swap.
Ecryptfs-setup-swap did not handle swapfiles correctly, and put a UUID in crypyttab as if the swapfile were a partition (see https://bugs.launchpad.net/ubuntu/+source/ecryptfs-utils/+bug/1670336)
Moreover, it called the wrong script to start the encrypted swap.

To post a comment you must log in.

Unmerged revisions

886. By Alberto Pianon on 2017-03-06

[ Alberto Pianon ]
src/utils/ecryptfs-setup-swap: Fix to make the script work with swapfiles
and to use the right script to start encrypted swap (LP: #1670336)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-07-15 00:14:41 +0000
3+++ debian/changelog 2017-03-06 20:21:05 +0000
4@@ -1,4 +1,4 @@
5-ecryptfs-utils (112) UNRELEASED; urgency=medium
6+ecryptfs-utils (112ubuntu1) UNRELEASED; urgency=medium
7
8 [ Dustin Kirkland ]
9 * UNRELEASED
10@@ -25,7 +25,11 @@
11 modify the swap partitions on systems that ecryptfs-setup-swap has been
12 used on. (LP: #1447282, LP: #1597154)
13
14- -- Dustin Kirkland <kirkland@ubuntu.com> Fri, 26 Feb 2016 18:00:18 -0600
15+ [ Alberto Pianon ]
16+ * src/utils/ecryptfs-setup-swap: Fix to make the script work with swapfiles
17+ and to use the right script to start encrypted swap (LP: #1670336)
18+
19+ -- Alberto Pianon <alberto@pianon.eu> Mon, 06 Mar 2017 21:04:47 +0100
20
21 ecryptfs-utils (111) xenial; urgency=medium
22
23
24=== modified file 'src/utils/ecryptfs-setup-swap'
25--- src/utils/ecryptfs-setup-swap 2016-07-13 05:02:30 +0000
26+++ src/utils/ecryptfs-setup-swap 2017-03-06 20:21:05 +0000
27@@ -150,7 +150,7 @@
28 info `gettext "Setting up swap:"` "[$swap]"
29 uuid=$(blkid -o value -s UUID $swap)
30 # /etc/fstab might use a symlink like /dev/mapper/ubuntu--vg-swap_1
31- links=$(for d in $(udevadm info --query=symlink -n $swap); do echo /dev/$d; done)
32+ [ -f $swap ] || links=$(for d in $(udevadm info --query=symlink -n $swap); do echo /dev/$d; done)
33 for target in "UUID=$uuid" $swap $links; do
34 if [ -n "$target" ] && grep -qs "^$target\s\+" /etc/fstab; then
35 sed -i "s:^$target\s\+:\#$target :" /etc/fstab
36@@ -193,8 +193,11 @@
37 # Add crypttab entry
38 # Use /dev/urandom, since this is not a long lived key (generated each boot),
39 # and so that we don't block booting while waiting for entropy
40- echo "cryptswap$i UUID=$uuid /dev/urandom swap,offset=1024,cipher=aes-xts-plain64" >> /etc/crypttab
41-
42+ if [ -f $swap ]; then # swapfile
43+ echo "cryptswap$i $swap /dev/urandom swap,offset=1024,cipher=aes-xts-plain64" >> /etc/crypttab
44+ else # partition
45+ echo "cryptswap$i UUID=$uuid /dev/urandom swap,offset=1024,cipher=aes-xts-plain64" >> /etc/crypttab
46+ fi
47 # Add fstab entry
48 echo "/dev/mapper/cryptswap$i none swap sw 0 0" >> /etc/fstab
49 done
50@@ -204,7 +207,9 @@
51 swapoff -a
52
53 # Restart cryptdisks
54- /etc/init.d/cryptdisks restart
55+ #/etc/init.d/cryptdisks restart
56+ # the above script does nothing, the following is the right command:
57+ systemctl restart cryptsetup.target
58
59 # Turn the swap on
60 swapon -a

Subscribers

People subscribed via source and target branches