Issue Details (XML | Word | Printable)

Key: NET-95
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Mario Ivankovits
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Net

UnixFTPEntryParser failed if permissions are other than rwx

Created: 23/Mar/04 05:17 AM   Updated: 20/Sep/07 05:31 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File unix.patch 2004-03-25 04:17 PM Mario Ivankovits 4 kB
Environment:
Operating System: other
Platform: Other

Bugzilla Id: 27858


 Description  « Hide
I am currently in the process of setting up a test server for the vfs project,
and guess what.
I have found a but in the NET library.

The Regex-String contains the following line
"(((r|)(w|)(x|))((r|)(w|)(x|))((r|)(w|)(x|-)))
s+"

But this will fail (maybe depends on the used ftpd server?) if the file has
other permissions set (e.g. setuid bit, sticky, ....)
Using listFiles will return a null value for every entry where this regexp wont
match.

I could send a patch if one tells me what you would like to see as patch.

1) extend FTPFile to handle these special modes.
2) ignore any other mode than "rwx". At least the regexp has to be expanded.
3) same as 2 except "s" is mapped to "x".
s: set user or group ID on execution

The possible values for the permissions are: rwxSst (for what i have seen for
now, maybe there are some other)



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Steve Cohen added a comment - 24/Mar/04 09:00 PM
Good catch, Mr. Ivankovits!

for (int access = 0; access < 3; access++, g += 4)

{ // Use != '-' to avoid having to check for suid and sticky bits file.setPermission(access, FTPFile.READ_PERMISSION, (!group(g).equals("-"))); file.setPermission(access, FTPFile.WRITE_PERMISSION, (!group(g + 1).equals("-"))); file.setPermission(access, FTPFile.EXECUTE_PERMISSION, (!group(g + 2).equals("-"))); }

As you can see by the above code snippet from UnixFTPEntryParser the ignoring of suid and
sticky bits is by design. However, you are correct that the regex must handle these or the
entry will fail to parse. While this will not cause a NullPointerException, the parsing engine will
remove the unparsed entry from the listing and that's not good. Fixing the regex will prevent
this from happening. And since the current code checks for inequality to "-" no special
mappings are needed.

So I would say the patch should be the following:
1) fix the regex as you have indicated
2) add lines to the JUnit test for this class testing the new functionality.


Mario Ivankovits added a comment - 25/Mar/04 04:17 PM
Created an attachment (id=10992)
Patch against UNIXFtpEntryParser and corresponding TestCase