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