Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 601194 - app-shells/bash-completion - bash-completion-2.1-escape-characters.patch: unneeded tilde expansion
Summary: app-shells/bash-completion - bash-completion-2.1-escape-characters.patch: unn...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2016-11-29 11:21 UTC by Roland Hopferwieser
Modified: 2016-11-29 12:37 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Hopferwieser 2016-11-29 11:21:09 UTC
The patch bash-completion-2.1-escape-characters.patch has unneeded tilde expansion. Every time 'quote_readline' is called, '~' will be expanded using the databases set in nsswitch.conf. If an external database like ldap is used and it is unavailable, this will freeze your shell.

Solution:
The tilde characters in the patch must be escaped
-    elif [[ $1 == ~* ]]; then
+    elif [[ $1 == \~* ]]; then
         # avoid escaping first ~
-        printf -v $2 ~%q "${1:1}"
+        printf -v $2 \~%q "${1:1}"

See also:
* https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1390061
* http://unix.stackexchange.com/a/185960

Reproducible: Always

Steps to Reproduce:
strace -e connect bash -c  ". /usr/share/bash-completion/bash_completion; quote_readline '/var'; echo"
Actual Results:  
If nscd *is not* running, something like:

connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("XXX.XXX.XXX.XXX")}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(389), sin_addr=inet_addr("XXX.XXX.XXX.XXX")}, 16) = -1 EINPROGRESS (Operation now in progress)

If nscd *is* running, something like:

connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = 0
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = 0

Expected Results:  
There should be no connection syscall at all.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-11-29 11:53:35 UTC
Thanks for the suggestion. However, before applying it I need to check if the tilde expansion discrepancy doesn't apply here. I recall that tilde expansion wasn't done in some old bash versions, and I need if that 'old' isn't 4.3.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-11-29 12:23:50 UTC
Ok, it seems 4.3-clean.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-11-29 12:37:20 UTC
commit 3c7ff5b0a5a073956e153ce8a3eb8e1d80a1d44d
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: Tue Nov 29 13:27:05 2016
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: Tue Nov 29 13:37:01 2016

    app-shells/bash-completion: Fix unquoted ~ in readline patch, #601194