[ 
https://issues.apache.org/jira/browse/SSHD-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17286891#comment-17286891
 ] 

Lyor Goldstein commented on SSHD-1129:
--------------------------------------

Not clear from your description whether the peer is MINA SSHD or some other 
server. In any case, please note that in SFTP V3 (which is the most widely used 
version), there is not standard way to provide owner/group name - only UID/GID 
(integers) - see 
[https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt] section 5
{quote}
    uint32   uid            present only if flag SSH_FILEXFER_ATTR_UIDGID
    uint32   gid            present only if flag SSH_FILEXFER_ATTR_UIDGID
{quote}
The +names+ of the user/group are only available for V4 and on - very rare.... 
If you are communicating with a V3 server (which is most likely) we cannot 
provide a name for the {{UserPrincipal/GroupPrincipal}} since V3 does not 
provide them. Please note that the {{SftpFileSystemProvider}} is a +best 
effort+ approximation and some features might not be available due to the SFTP 
protocol limitations.

> Posix file owner and group always null
> --------------------------------------
>
>                 Key: SSHD-1129
>                 URL: https://issues.apache.org/jira/browse/SSHD-1129
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 2.6.0
>            Reporter: Logan
>            Priority: Major
>
> Unable to read remote path owner and group details when connected through 
> sftp. Below is code snippet.
>  
> {code:java}
> public void singlePath() throws IOException {
>   try (SshClient client = SshClient.setUpDefaultClient()) {
>     client.start();
>       try (ClientSession session = client.connect("user", "host", 
> 22).verify(SFTP_SESSION_TIME_OUT_MILLIS).getSession()) {
>         session.addPasswordIdentity("xxxx");
>         session.auth().verify(SFTP_SESSION_TIME_OUT_MILLIS);
>        SftpFileSystemProvider provider = new SftpFileSystemProvider(client);
>        String[] paths = new String[] { "/tmp" };
>        try (FileSystem fs = provider.newFileSystem(session)) {
>           boolean posix = fs.supportedFileAttributeViews().contains("posix");
>          for (String path : paths) {
>             System.out.println(path + ":");
>             Path remotePath = fs.getPath(path);
>             if (posix) {
>                 PosixFileAttributes posixAttrs = Files
>  .getFileAttributeView(remotePath, PosixFileAttributeView.class)
>  .readAttributes();
>                 Set<PosixFilePermission> perms = posixAttrs.permissions();
>                 System.out.println(PosixFilePermissions.toString(perms));
>                 UserPrincipal user = posixAttrs.owner();
>                 System.out.println(user == null ? "NULL" : user.getName());
>                 GroupPrincipal group = posixAttrs.group();
>                 System.out.println(group == null ? "NULL" : group.getName());
>              }
>           }
>        }
>      }
>   }
>  }
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to