[jira] [Commented] (SSHD-1209) Write to error stream for custom exception is appending a extra word at the beginning

2022-01-20 Thread Lyor Goldstein (Jira)


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

Lyor Goldstein commented on SSHD-1209:
--

[~twolf] Enlightening as usual - thanks for the clear explanation.

> Write to error stream for custom exception is appending a extra word at the 
> beginning
> -
>
> Key: SSHD-1209
> URL: https://issues.apache.org/jira/browse/SSHD-1209
> Project: MINA SSHD
>  Issue Type: Bug
>Affects Versions: 2.7.0
>Reporter: Susmit Sarkar
>Priority: Major
> Attachments: image-2021-08-19-12-50-01-922.png, 
> image-2022-01-18-14-19-31-614.png, image-2022-01-18-14-23-38-696.png
>
>
> Hello Team,
>  
> We have a class as below
>  
> {code:java}
> DetailedSftpErrorStatusDataHandler implements SftpErrorStatusDataHandler, 
> ChannelSessionAware, DetailedSftpErrorStatusDataHandler implements 
> SftpErrorStatusDataHandler, ChannelSessionAware, 
> AsyncCommandErrorStreamAware, CommandDirectErrorStreamAware {
> {code}
> and we have overridden the :
>  
> resolveErrorMessage and setIoErrorStream(IoOutputStream errStream) 
> {code:java}
>  @Override
>  public void setIoErrorStream(IoOutputStream errStream) { 
>  this.errStream = errStream;
>  }
> {code}
> finally we are writing to the error stream:
> {code:java}
> private void writeMsgToErrorStream(String refinedUserExitMessage) {
> ByteArrayBuffer buf = new ByteArrayBuffer();
> buf.putString(refinedUserExitMessage + 
> System.getProperty("line.separator")); 
> try { if (errStream != null) { 
> errStream.writeBuffer(buf); 
>   }
> } catch (Exception e) { 
> }
>  }
> {code}
> Once the data is written to error stream we are gettig proper message to the 
> console:
> !image-2021-08-19-12-50-01-922.png!
> But there is an extra charater getting appended at the first character *<* 
> Utils.java 
> I have no idea from where this *<* is coming from, and that changes with the 
> first character like if it is P it would be *>, when starting with S it gets 
> appended with Z*
> Any help will be appreciated.
> Thanks,
> Susmit
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

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



Re: MINA 2.1 vs MINA 2.2 API differences

2022-01-20 Thread Emmanuel Lécharny




On 20/01/2022 13:25, Jonathan Valliere wrote:
The old method was unsafe from a concurrency standpoint.  This switching 
logic should be in a filter.


Agreed. StartTLS is by itself very intrusive and I think it deserves to 
be made a MINA filter, instead of expecting MINA to be twisted in a way 
that is not natural.


Actually, with such a filter, we wouldn't even require the flag you have 
added as a substitute for the session attribute.


Thanks Jonathan !

--
*Emmanuel Lécharny - CTO* 205 Promenade des Anglais – 06200 NICE
T. +33 (0)4 89 97 36 50
P. +33 (0)6 08 33 32 61
emmanuel.lecha...@busit.com https://www.busit.com/

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



Re: MINA 2.1 vs MINA 2.2 API differences

2022-01-20 Thread Jonathan Valliere
The old method was unsafe from a concurrency standpoint.  This switching
logic should be in a filter.

On Thu, Jan 20, 2022 at 1:40 AM Emmanuel Lécharny 
wrote:

>
>
> On 18/01/2022 14:06, Jonathan Valliere wrote:
> > Yes, I added that specifically for anyone who needed that attribute I
> > removed. Unlike that attribute of disable once, this is completely safe
> > to use.
>
> But sadly, it can't be used from the outside.
>
> The typical use from an application PoV is :
>
>  session.getIoSession().write( message );
>
> and it ends with:
>
>  public WriteFuture write(Object message, SocketAddress remoteAddress)
> {
>  ...
>  // Now, we can write the message. First, create a future
>  WriteFuture writeFuture = new DefaultWriteFuture(this);
>  WriteRequest writeRequest = new DefaultWriteRequest(message,
> writeFuture, remoteAddress);
>
>
> That means we should bypass this part, which would require some
> modification in this method.
>
>
>
> >
> > On Tue, Jan 18, 2022 at 3:12 AM Emmanuel Lécharny  > > wrote:
> >
> >
> >
> > On 18/01/2022 05:04, Jonathan Valliere wrote:
> >  > Doesn't the DisableEncryptionWriteRequest get you where you need
> > to go?
> >  > Just wrap the startTLS message and pass upstream into the
> SSLFilter.
> >
> >
> > You mean DisableEncryptWriteRequest, I guess. Yes, that should do the
> > trick !
> >
> > Will test it and tell you...
> >
> > Thanks !
> >
> > --
> > Emmanuel Lécharny
> >
>
> --
> *Emmanuel Lécharny - CTO* 205 Promenade des Anglais – 06200 NICE
> T. +33 (0)4 89 97 36 50
> P. +33 (0)6 08 33 32 61
> emmanuel.lecha...@busit.com https://www.busit.com/
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
> For additional commands, e-mail: dev-h...@mina.apache.org
>
>


[jira] [Commented] (SSHD-1209) Write to error stream for custom exception is appending a extra word at the beginning

2022-01-20 Thread Thomas Wolf (Jira)


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

Thomas Wolf commented on SSHD-1209:
---

I suppose it works this way because of 
[https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-3.1]
 : "Data sent on stderr by the server SHOULD be considered free format debug or 
supplemental error information".

The original code sent an SSH encoded string (length, text bytes), so the 
client got (SSH_MSG_CHANNEL_EXTENDED_DATA, channelId, SSH_EXTENDED_DATA_STDERR, 
length of data, data=(length, text bytes)). Apparently "free form" means one is 
supposed to send just (SSH_MSG_CHANNEL_EXTENDED_DATA, channelId, 
SSH_EXTENDED_DATA_STDERR, length of data, data=text bytes).

This also explains the extra characters. "SFTP User Exit error: 
stat.throwExcpetion was set to true" is 58 characters (and bytes, since it's 
7-bit ASCII). With buffer.putString(), this is prefixed by the length, so it 
sends the bytes 0x00 0x00 0x00 0x3A and the the text bytes. ASCII code 0x3A 
(decimal 58) is ":".

Same for "Utils.java from admin File name should be syncsort.txt Only": that's 
60 characters, and ASCII code 60 is "<".

"free form" doesn't say it had to be text, though. RFC 4254 defines 
SSH_EXTENDED_DATA_STDERR for "stderr data", and stderr is typically assumed to 
be text, but that's it. It doesn't say what line separator is used, if it's 
text, nor what character encoding would be used.

 

> Write to error stream for custom exception is appending a extra word at the 
> beginning
> -
>
> Key: SSHD-1209
> URL: https://issues.apache.org/jira/browse/SSHD-1209
> Project: MINA SSHD
>  Issue Type: Bug
>Affects Versions: 2.7.0
>Reporter: Susmit Sarkar
>Priority: Major
> Attachments: image-2021-08-19-12-50-01-922.png, 
> image-2022-01-18-14-19-31-614.png, image-2022-01-18-14-23-38-696.png
>
>
> Hello Team,
>  
> We have a class as below
>  
> {code:java}
> DetailedSftpErrorStatusDataHandler implements SftpErrorStatusDataHandler, 
> ChannelSessionAware, DetailedSftpErrorStatusDataHandler implements 
> SftpErrorStatusDataHandler, ChannelSessionAware, 
> AsyncCommandErrorStreamAware, CommandDirectErrorStreamAware {
> {code}
> and we have overridden the :
>  
> resolveErrorMessage and setIoErrorStream(IoOutputStream errStream) 
> {code:java}
>  @Override
>  public void setIoErrorStream(IoOutputStream errStream) { 
>  this.errStream = errStream;
>  }
> {code}
> finally we are writing to the error stream:
> {code:java}
> private void writeMsgToErrorStream(String refinedUserExitMessage) {
> ByteArrayBuffer buf = new ByteArrayBuffer();
> buf.putString(refinedUserExitMessage + 
> System.getProperty("line.separator")); 
> try { if (errStream != null) { 
> errStream.writeBuffer(buf); 
>   }
> } catch (Exception e) { 
> }
>  }
> {code}
> Once the data is written to error stream we are gettig proper message to the 
> console:
> !image-2021-08-19-12-50-01-922.png!
> But there is an extra charater getting appended at the first character *<* 
> Utils.java 
> I have no idea from where this *<* is coming from, and that changes with the 
> first character like if it is P it would be *>, when starting with S it gets 
> appended with Z*
> Any help will be appreciated.
> Thanks,
> Susmit
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

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