From issues-return-66442-archive-asf-public=cust-asf.ponee.io@commons.apache.org Wed Feb 14 00:30:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 15D7A180656 for ; Wed, 14 Feb 2018 00:30:04 +0100 (CET) Received: (qmail 35103 invoked by uid 500); 13 Feb 2018 23:30:04 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 35090 invoked by uid 99); 13 Feb 2018 23:30:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Feb 2018 23:30:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 68C48C0110 for ; Tue, 13 Feb 2018 23:30:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id mrndSiFc4bZ1 for ; Tue, 13 Feb 2018 23:30:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 745535F478 for ; Tue, 13 Feb 2018 23:30:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B2E9CE01AA for ; Tue, 13 Feb 2018 23:30:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 62FA921E84 for ; Tue, 13 Feb 2018 23:30:00 +0000 (UTC) Date: Tue, 13 Feb 2018 23:30:00 +0000 (UTC) From: "Otto Fowler (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (VFS-651) SftpFileSystem Should not switch to root directory when not absolutely needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/VFS-651?page=3Dcom.atlassian.ji= ra.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1636322= 5#comment-16363225 ]=20 Otto Fowler commented on VFS-651: --------------------------------- Are we sure that this is not working correctly? Can you post a small snippet of code or a description of how you configure = can connect? =C2=A0And what you are trying to do that does not work if you = set it to true? > SftpFileSystem Should not switch to root directory when not absolutely ne= eded > -------------------------------------------------------------------------= ---- > > Key: VFS-651 > URL: https://issues.apache.org/jira/browse/VFS-651 > Project: Commons VFS > Issue Type: Bug > Affects Versions: 2.0 > Reporter: Syed Aqeel Ashiq > Priority: Major > Fix For: 2.3 > > > Consider a user X only has read/write access to let's say /sftp and /sftp= /abc directory on a sftp server. And=C2=A0default directory for user is /sf= tp > In this case, we have to set userDirIsRoot to false, and thus vfs will tr= y to switch to root directory, which will fail due to lack of read permissi= on. > This is the underlying code responsible in > {code:java} > org.apache.commons.vfs.provider.sftp.SftpFileSystem > {code} > : > {code:java} > Boolean userDirIsRoot =3D SftpFileSystemConfigBuilder.getInstance().getUs= erDirIsRoot(getFileSystemOptions()); > String workingDirectory =3D getRootName().getPath(); > if (workingDirectory !=3D null && (userDirIsRoot =3D=3D null || !userDirI= sRoot.booleanValue())) { > try { > channel.cd(workingDirectory);=20 > } catch (SftpException e) { > throw new FileSystemException("vfs.provider.sftp/change-work-dire= ctory.error", workingDirectory); > } > }{code} > It purposelessly switches to root directory of filesystem. There is a fai= r use-case that root directory doesn't have read access. > *Possible Fix:* It should not switch to root directory, rather it should = switch to actual final directory. This approach would be the safest. E.g. i= f the needed directory is '/sftp/abc' then it can switch to that directory = in above code, rather than switching to root. > Please also see related SO question: > https://stackoverflow.com/questions/48709971/why-apache-vfs-sftp-tries-to= -switch-to-root-directory-even-when-not-needed -- This message was sent by Atlassian JIRA (v7.6.3#76005)