Bugs item #311821, was changed at 2009-07-11 17:04 by Freddy Vulto
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311821&group_id=100114

>Status: Closed
Priority: 3
Submitted By: Sung Pae (guns-guest)
Assigned to: Nobody (None)
Summary: _known_hosts_real completing both known hosts and hostnames is 
excessive 
Distribution: None
Originally reported in: None
Milestone: None
Status: None
Original bug number: 


Initial Comment:
Hello,

The new _known_hosts_real function now completes hostnames from /etc/hosts, in 
addition to any hosts from the global and user known_hosts files. This differs 
from the old function, which completed EITHER hosts from the known_hosts files 
OR from /etc/hosts.

The new behaviour is much less useful for me for two reasons:

1) I have dozens of custom entries in /etc/hosts for local web development.

e.g:
127.0.0.1       example.dev
127.0.0.1       anotherexample.dev

Since I use the convention of replacing the real domain's TLD with 'dev' for 
local development, ssh completion for the real server always faces a collision 
with its local '*.dev' sibling. I have local host entries for almost every 
server I ssh into, so this gets irritating.

I am looking to use a local BIND server in the near future, but I know plenty 
of web programmers use the hosts file in the same fashion that I do.

2) I have thousands of entries in /etc/hosts for ad-blocking

A popular, and mostly effective, method for blocking ads and malware is to add 
entries directing thousands of domains to 127.0.0.1. Whether or not this is an 
abuse of the hosts file, it is a relatively popular use of it. It does, 
however, render standard hostname completion useless.

--

For these reasons, please consider changing the standard behaviour of 
_known_hosts_real as before, completing hosts from the _known_hosts file OR 
from /etc/hosts if no known_hosts files are found.


----------------------------------------------------------------------

>Comment By: Freddy Vulto (fvu-guest)
Date: 2009-08-12 22:32

Message:
Adding hosts from HOSTFILE variable actually was a fix of Debian Bug #400380, 
see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400380, so I'll leave the 
current behaviour as is.

However, I've added an additional environment variable
`COMP_KNOWN_HOSTS_WITH_HOSTFILE' as of git commit 2e87bd4c.  Now
`_known_hosts_real' will add results of normal hostname completion (compgen -A 
hostname), unless `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.

The comment for _known_hosts_real() has been modified to reflect the current 
behaviour.

Regards, Freddy

----------------------------------------------------------------------

Comment By: Sung Pae (guns-guest)
Date: 2009-07-17 00:02

Message:
> Theoretically, adding hosts from /etc/hosts is the right behaviour since ssh 
> 'knows' these hosts as well

I guess I would submit that it is surprising behaviour given the following 
comments for _known_hosts_real():

# Helper function for completing _known_hosts.
# This function performs host completion based on ssh's known_hosts files,
# __defaulting__ to standard host completion if they don't exist.

(my emphasis)

>    COMPLEMENT_KNOWN_HOSTS_WITH_HOSTFILE
>        1 if known_hosts completion must complement hostnames from ssh's
>        known_hosts_files with hostnames taken from the file specified by the
>        HOSTFILE shell variable (compgen -A hostname), 0 if not
> 
> with either 0 or 1 becoming the default.

That would be great! Thank you for considering the change.


----------------------------------------------------------------------

Comment By: Freddy Vulto (fvu-guest)
Date: 2009-07-13 13:23

Message:
I've been able to track the change to this git commit:

    54f5544b6b2b213  Merged changes from Debian.
    Author: David Paleino <[email protected]>  2008-05-01 22:59:32
    ...
    @@ -2533,10 +2554,13 @@ _known_hosts()
    +       # Now add results of normal hostname completion
    +       COMPREPLY=( ${comprep...@]} $( compgen -A hostname -- $ocur ) )
    ...

It has been released already in bash-completion_20060301-4 and
bash_completion-20080705 so I'm not sure if removing this functionality is ok
for Debian, or what's considered default behaviour now... (David?)

Theoretically, adding hosts from /etc/hosts is the right behaviour since ssh
'knows' these hosts as well, but I can see your objections.  Perhaps a solution
would be to leave it up to the user and add a configuration option to
bash_completion:

   COMPLEMENT_KNOWN_HOSTS_WITH_HOSTFILE
       1 if known_hosts completion must complement hostnames from ssh's
       known_hosts_files with hostnames taken from the file specified by the
       HOSTFILE shell variable (compgen -A hostname), 0 if not

with either 0 or 1 becoming the default.

Regards, Freddy

----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311821&group_id=100114

_______________________________________________
Bash-completion-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/bash-completion-devel

Reply via email to