9471b77
diff -up ecryptfs-utils-108/src/utils/ecryptfs-setup-private.sudokeyring ecryptfs-utils-108/src/utils/ecryptfs-setup-private
9471b77
--- ecryptfs-utils-108/src/utils/ecryptfs-setup-private.sudokeyring	2015-08-11 14:44:05.213807245 +0200
9471b77
+++ ecryptfs-utils-108/src/utils/ecryptfs-setup-private	2015-08-11 14:44:05.231807198 +0200
c0230a2
@@ -427,8 +427,16 @@ if [ "$BOOTSTRAP" = "1" ]; then
c0230a2
 	else
c0230a2
 		sig_opt="ecryptfs_sig=$sig"
c0230a2
 	fi
c0230a2
+	# If we are running under sudo, the session keyring may not link
c0230a2
+	# to root's user keyring, where the auth tok is stored
c0230a2
+	# Need to join root's keyring, otherwise the mount will fail
c0230a2
+	if [ "$(keyctl describe @s | awk '{ print $3; }')" -ne 0 ]; then
c0230a2
+		_KEK_="keyctl session _uid.0"
c0230a2
+	else
c0230a2
+		_KEK_=
c0230a2
+	fi
c0230a2
 	# Do the mount, and provide some helpful symlinks
c0230a2
-	mount -i -t ecryptfs -o "rw,$sig_opt,ecryptfs_cipher=$CIPHER,ecryptfs_key_bytes=$KEYBYTES" "$CRYPTDIR" "$MOUNTPOINT" || error "Could not mount"
c0230a2
+	$_KEK_ mount -i -t ecryptfs -o "rw,$sig_opt,ecryptfs_cipher=$CIPHER,ecryptfs_key_bytes=$KEYBYTES" "$CRYPTDIR" "$MOUNTPOINT" || error "Could not mount"
c0230a2
 	ln -sf $ECRYPTFS_DIR/$USER/.ecryptfs $MOUNTPOINT/.ecryptfs
c0230a2
 	ln -sf $ECRYPTFS_DIR/$USER/.$PRIVATE_DIR $MOUNTPOINT/.$PRIVATE_DIR
c0230a2
 	chown -R $USER:$GROUP $ECRYPTFS_DIR/$USER