[
https://issues.apache.org/jira/browse/VFS-617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16054136#comment-16054136
]
Len edited comment on VFS-617 at 6/19/17 2:51 PM:
--------------------------------------------------
I had the same issue as L. If the user is only allowed sftp (no exec) this
fails. I also ended up patching SftpFileObject.java as following:
{code:java}
protected PosixPermissions getPermissions(final boolean checkIds) throws
Exception
{
statSelf();
/*boolean isInGroup = false;
if (checkIds)
{
for (final int groupId : getAbstractFileSystem().getGroupsIds())
{
if (groupId == attrs.getGId())
{
isInGroup = true;
break;
}
}
}
final boolean isOwner = checkIds ? attrs.getUId() ==
getAbstractFileSystem().getUId() : false;*/
return new PosixPermissions(attrs.getPermissions(), true, true);
}
{code}
This way neither getGroupsId or getUId, both which use the exec channel are
used.
was (Author: len):
I had the same issue as L. If the user is only allowed sftp (no exec) this
fails. I also ended up patching SftpFileObject.java as following:
{code:java}
protected PosixPermissions getPermissions(final boolean checkIds) throws
Exception
{
statSelf();
/*boolean isInGroup = false;
if (checkIds)
{
for (final int groupId : getAbstractFileSystem().getGroupsIds())
{
if (groupId == attrs.getGId())
{
isInGroup = true;
break;
}
}
}
final boolean isOwner = checkIds ? attrs.getUId() ==
getAbstractFileSystem().getUId() : false;*/
return new PosixPermissions(attrs.getPermissions(), true, true);
}
{code}
> isReadable fails if unable to determine group identity
> ------------------------------------------------------
>
> Key: VFS-617
> URL: https://issues.apache.org/jira/browse/VFS-617
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.1
> Environment: Windows 7 Java 7. Failure occured connecting via SFTP to
> a Synology box running DSM 6.
> Reporter: Tim Nickels
>
> The doIsReadable method of SftpFileObject throws an exception if the system
> cannot identify group/owner permissions.......
> Exception in thread "main" org.apache.commons.vfs2.FileSystemException: Could
> not determine if file "sftp://myURI" is readable.
> at
> org.apache.commons.vfs2.provider.AbstractFileObject.isReadable(AbstractFileObject.java:1761)
> at com.avenca.vfs.VFSUtils.main(VFSUtils.java:41)
> Caused by: com.jcraft.jsch.JSchException: Could not get the groups id of the
> current user (error code: 1)
> at
> org.apache.commons.vfs2.provider.sftp.SftpFileSystem.getGroupsIds(SftpFileSystem.java:263)
> at
> org.apache.commons.vfs2.provider.sftp.SftpFileObject.getPermissions(SftpFileObject.java:317)
> at
> org.apache.commons.vfs2.provider.sftp.SftpFileObject.doIsReadable(SftpFileObject.java:335)
> at
> org.apache.commons.vfs2.provider.AbstractFileObject.isReadable(AbstractFileObject.java:1757)
> The problem is the method is using
> return getPermissions(true).isReadable()
> The folder *is* readable without these permissions, and so should be set to
> return getPermissions(false).isReadable()
> Which correctly allows the system to identify a readable folder without
> adding unnecessary restrictions.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)