Package: util-linux / 2.29.2-1+deb9u1

bash-completion-umount-use-findmnt-escape-a-space-in.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: Karel Zak <kzak@redhat.com>
Date: Thu, 16 Nov 2017 16:27:32 +0100
Subject: bash-completion: (umount) use findmnt, escape a space in paths
Origin: https://github.com/karelzak/util-linux/commit/75f03badd7ed9f1dd951863d75e756883d3acc55
Bug-Debian: https://bugs.debian.org/892179
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2018-7738

 # mount /dev/sdc1 /mnt/test/foo\ bar
 # umount <tab>

has to return "/mnt/test/foo\ bar".

Changes:

 * don't use mount | awk output, we have findmnt
 * force compgen use \n as entries separator

Addresses: https://github.com/karelzak/util-linux/issues/539
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 bash-completion/umount | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/bash-completion/umount b/bash-completion/umount
index d76cb9fff..98c90d61a 100644
--- a/bash-completion/umount
+++ b/bash-completion/umount
@@ -40,9 +40,10 @@ _umount_module()
 			return 0
 			;;
 	esac
-	local DEVS_MPOINTS
-	DEVS_MPOINTS="$(mount | awk '{print $1, $3}')"
-	COMPREPLY=( $(compgen -W "$DEVS_MPOINTS" -- $cur) )
-	return 0
+
+	local oldifs=$IFS
+	IFS=$'\n'
+	COMPREPLY=( $( compgen -W '$(findmnt -lno TARGET | sed "s/\([[:blank:]]\)/\\\\\1/g")' -- "$cur" ) )
+	IFS=$oldifs
 }
 complete -F _umount_module umount
-- 
2.16.2