File CVE-2016-6224.patch of Package ecryptfs-utils.6434

Index: src/utils/ecryptfs-setup-swap
===================================================================
--- src/utils/ecryptfs-setup-swap.orig
+++ src/utils/ecryptfs-setup-swap
@@ -162,8 +162,14 @@ for swap in $swaps; do
 	# If this is a GPT partition, mark it as no-auto mounting, to avoid
 	# auto-activating it on boot
 	if [ "$(blkid -p -s PART_ENTRY_SCHEME -o value "$swap")" = "gpt" ]; then
-		drive="${swap%[0-9]*}"
-		partno="${swap#$drive}"
+		# Correctly handle NVMe/MMC drives, as well as any similar physical
+		# block device that follow the "/dev/foo0p1" pattern (LP: #1597154)
+		if echo "$swap" | grep -qE "^/dev/.+[0-9]+p[0-9]+$"; then
+			drive=$(echo "$swap" | sed "s:\(.\+[0-9]\)p[0-9]\+:\1:")
+		else
+			drive=$(echo "$swap" | sed "s:\(.\+[^0-9]\)[0-9]\+:\1:")
+		fi
+		partno=$(echo "$swap" | sed "s:.\+[^0-9]\([0-9]\+\):\1:")
 		if [ -b "$drive" ]; then
 			if printf "x\np\n" | fdisk "$drive" | grep -q "^$swap .* GUID:.*\b63\b"; then
 				echo "$swap is already marked as no-auto"
openSUSE Build Service is sponsored by