realpath throws Exc. with id=0 msg=Success

  • Anonymous - 2009-02-26

    I use maven wagon ssh/sftp. When is called with a directory that is not (yet) present on the server, the ChannelSftp._realpath() method throws an exception with id=0, message=Success
    The response header type is SSH_FXP_STATUS.
    I'm using JSch 0.1.41
    I'm not quite sure, if this is adhering to the protocol or a problem on the server side. I do not know which server is used.

    • Anonymous - 2009-02-27

      The supplied patch interprets the 0/Success according to the general rfc section:
      "When the operation is successful, and no data needs to be returned, the SSH_FXP_STATUS response with SSH_FX_OK status is appropriate."
      .. and just returns the path passed to the method - afterwards, the cd methods makes a stat on the path anyway so this can't do much harm.

      --- ./    2009-02-27 00:19:48.000000000 +0100
      +++ ./    2009-02-27 02:10:52.000000000 +0100
      @@ -1804,7 +1804,8 @@

         private byte[] _realpath(String path) throws SftpException, IOException, Exception{
      -    sendREALPATH(Util.str2byte(path, fEncoding));
      +    byte[] pathByte = Util.str2byte(path, fEncoding);
      +    sendREALPATH(pathByte);

           Header header=new Header();
           header=header(buf, header);
      @@ -1819,7 +1820,11 @@
           int i;
      -      throwStatusError(buf, i);
      +      if(i==SSH_FX_OK){
      +          return pathByte;
      +      } else {
      +          throwStatusError(buf, i);
      +      }
           i=buf.getInt();   // count


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks