I'm using Jsch 0.1.44 for SFTP and have run into some interesting behavior.

I believe there is an issue with the handling of unix socket files by JSCH.  
When doing a listing of a directory that contains a socket file, the file comes 
back as a directory rather than a file.  I'm not sure this is entirely 
inaccurate because the socket file is technically both a file and a directory 
when looking at the permission flags set on the file.

root@red-linux:/var/run/mysqld# ls -l
total 0
drwxrwxrwx 2 mysql mysql 40 2012-09-07 14:54 directory
-rwxrwxrwx 1 mysql mysql  0 2012-09-07 14:54 file
srwxrwxrwx 1 mysql mysql  0 2012-03-01 15:19 mysqld.sock
root@red-linux:/var/run/mysqld#

If you have mysql installed on a linux box (I'm using Ubuntu), you can navigate 
to /var/run/mysqld directory and find a socket file, represented by an 's' in 
the first permission place. I created a directory and a file in that folder and 
ran a list with the jsch code on that directory.  By debugging, I found that 
the following permissions were returned back for each file type in that 
directory.

File Type     Unix Perm     Int Perm      Octal Perm    Binary Perm
---------     ---------     --------      ----------    -----------
directory     drwxrwxrwx    16895         040777        0100000111111111
file          -rwxrwxrwx    33279         100777        1000000111111111
socket file   srwxrwxrwx    49663         140777        1100000111111111

Notice how the socket file has both the file and directory bits set.  JSCH has 
the SftpATTRS.isDir() check which checks ((permissions & S_IFDIR) == S_IFDIR).  
This is returning true but I believe this should be returning false for this 
particular file type.  I'm not the expert in SFTP nor Unix file types, so I 
wanted to send this out for discussion.  The issue would come up for certain 
application that need to recursively traverse directories.  The applications 
using JSCH will run into an issue when a socket file is encountered, as it will 
see the file as a directory and try to navigate into that file, which fails.  
I've done some comparisons with FileZilla and it represents the object as a 
file.

I'm curious if anyone has run into this before and whether or not an 
enhancement can be made to return this file type as a file, not a directory?

Regards,

E R I C K   L I C H T A S
Linoma Software
Senior Software Engineer
p. 402.944.4242 x714
f. 402.944.4243
www.LinomaSoftware.com<http://www.linomasoftware.com/>
www.GoAnywhereMFT.com<http://www.goanywheremft.com/>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to