Bug 1792

Summary: Unable to "ls" within a directory with special characters "[" or "]"
Product: Portable OpenSSH Reporter: sftpbug
Component: sftpAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: normal CC: djm, dtucker
Priority: P2    
Version: 5.5p1   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 1803    

Description sftpbug 2010-07-10 07:42:10 AEST
Unable to "ls" within a directory with special characters "[" or "]"

Issue appears as follows once connected to remote SFTP server:
sftp> pwd
Remote working directory: /foo
sftp> ls
directory [one]
sftp> cd directory\ [one]
sftp> pwd
Remote working directory: /foo/directory [one]
sftp> ls
Can't ls: "/foo/directory [one]" not found

However, the client is freely able to list the directory contents when outside the directory that contains the special characters: "[" and/or "]" 
sftp> ls "/foo/directory [one]" 
Successful.
Comment 1 Darren Tucker 2010-07-19 13:55:53 AEST
What platform is this?  I can't reproduce the problem on either OpenBSD or Fedora.

$ cd /tmp
$ mkdir directory\ [one]
$ cd directory\ \[one\]/
$ touch bar
$ sftp localhost
Connected to localhost.
sftp> cd /tmp/directory\ [one]/
sftp> pwd
Remote working directory: /tmp/directory [one]
sftp> ls
bar  
sftp> 

A couple of things you can try:

./configure --with-cflags=-DBROKEN_REALPATH

./configure --with-cflags=-DBROKEN_GLOB

and see if either of these makes the problem go away.
Comment 2 sftpbug 2010-07-22 10:16:44 AEST
OS-X Snow Leopard 10.6.4

SSH Version Info:
OpenSSH_5.5p1, OpenSSL 0.9.8l 5 Nov 2009

Issue persists with re-compiling using ./configure flags.

(In reply to comment #1)
> What platform is this?  I can't reproduce the problem on either OpenBSD
> or Fedora.
> 
> $ cd /tmp
> $ mkdir directory\ [one]
> $ cd directory\ \[one\]/
> $ touch bar
> $ sftp localhost
> Connected to localhost.
> sftp> cd /tmp/directory\ [one]/
> sftp> pwd
> Remote working directory: /tmp/directory [one]
> sftp> ls
> bar  
> sftp> 
> 
> A couple of things you can try:
> 
> ./configure --with-cflags=-DBROKEN_REALPATH
> 
> ./configure --with-cflags=-DBROKEN_GLOB
> 
> and see if either of these makes the problem go away.
Comment 3 Darren Tucker 2010-07-22 15:38:39 AEST
(In reply to comment #2)
> OS-X Snow Leopard 10.6.4

OK, I can reproduce it with 5.5p1, but I think it's since been fixed (bug #1655).

Please try a snapshot http://www.mindrot.org/openssh_snap/
Comment 4 Damien Miller 2010-11-05 10:55:07 AEDT
I can't elicit this in -current.
Comment 5 Damien Miller 2011-01-24 12:34:03 AEDT
Move resolved bugs to CLOSED after 5.7 release