Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BLU0-SMTP4483076ED1744B71B526DE2FD130@phx.gbl>
Date: Mon, 7 May 2012 10:42:53 +0200
From: Frank Dittrich <frank_dittrich@...mail.com>
To: john-users@...ts.openwall.com
Subject: Re: file name expansion for --wordlist= and file name
 starting with ~

On 05/07/2012 10:02 AM, Aleksey Cherepanov wrote:
> On Sun, May 06, 2012 at 02:52:47PM -0600, Stephen John Smoogen wrote:
>> On 6 May 2012 13:59, Frank Dittrich <frank_dittrich@...mail.com> wrote:
>>> did anybody else of you notice that for --wordlist=filename, even bash
>>> auto-completion for file names starting with ~/ or ~user works, but john
>>> fails to recognize e.g. --wordlist=~/test.txt?
> 
> It does not work for me too.
> 
> $ bash --version
> GNU bash, version 4.2.20(1)-release (x86_64-pc-linux-gnu)
> ...
> $ apt-cache show john
> Package: john
> Version: 1.7.8-1
> ...
> Filename: pool/main/j/john/john_1.7.8-1_amd64.deb

$ bash --version
GNU bash, version 4.2.24(1)-release (i386-redhat-linux-gnu)

The john version is irrelevant, since this seems to be a bash issue.
(That's why it might be off topic here, but since I started the thread,
I'd like to add some more findings.)

> I do not think that shell should expand this. I think it should expand ~ only
> at the begin of argument:

Yes, the bash documentation suggests the same.
But then, why is it expanding such filenames in GNU options (starting
with --, like --wordlist=) and even in normal option?

Expand ~ on the command line only at the beginning of words is OK.
But then, pressing [tab] shouldn't result in auto-completing the file
name, or auto-completion should replace ~ with the contents of $HOME.

For all these cases
$ vim -d:~/test
$ vim --dummy:~/test
$ vim -d=~/test
$ vim --dummy:~/test
I can press the tab key, and the file name gets expanded to
/home/fd/test.txt

But the same doesn't work for ./john.
It doesn't work for or john /usr/bin/john, either. I just installed
fedora's package to test this.
It doesn't even work for bash --dummy=~/test.
Pressing the tab key expands this to bash --dummy=~/test.txt.
The file name auto-completion replacing ~ with $HOME seems to be a
special auto-completion rule just for vim.

So the issue seems to be that ~/test doesn't get expanded to
/home/fd/test when pressing the tab key.
May be I'll dig into the tab auto-completion logic or file a fedora bug
for bash.

> $ perl -le 'print "@ARGV"' 1 ~ 2 --wordlist=~ 3 ~/x 4 -w=~/x 5
> 1 /home/a 2 --wordlist=~ 3 /home/a/x 4 -w=~/x 5

$ perl -le 'print "@ARGV"' 1 ~ 2 --wordlist=~ 3 ~/x 4 -w=~/x 5
1 /home/fd 2 --wordlist=~ 3 /home/fd/x 4 -w=~/x 5

$ perl -le 'print "@ARGV"' 1 ~ 2 --wordlist:~ 3 ~/x 4 -w:~/x 5
1 /home/fd 2 --wordlist:~ 3 /home/fd/x 4 -w:~/x 5

Probably this is expected behavior.
(For some reason, I expected expansion for --long-opt=..., but not for
--long-opt:..., -o=... or -o:... - I don't know why.)


Frank

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.