Hi guys, Background: I am trying to fix bug #1002 completely; there appear to be multiple underlying bugs. One of them is that unless I start x2goclient from a cygwin shell, cygwin sshd doesn't actually listen its port. Anyway, at the moment I am trying to make x2goclient start sshd with debug logging when x2goclient is launched with --debug, but I am unable to do so. Every time I launch x2goclient, sshd_config is regenerated without the debug line. I've tried 2 different approaches, you can see them below. Ignore the x2goDebug line. diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..a1d92a8 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -10292,6 +10292,8 @@ void ONMainWindow::generateEtcFiles() /* This may need some sanitization, i.e., appDir could potentially include whitespace. */ <<appDir<<"/sftp-server\n"; #endif + x2goDebug<<"LogLevel DEBUG1"; + out<<"LogLevel DEBUG1"; file.close(); x2goDebug<<etcDir +"/sshd_config created."; } ---------------- diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..928da70 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -10293,6 +10293,13 @@ void ONMainWindow::generateEtcFiles() <<appDir<<"/sftp-server\n"; #endif file.close(); + if (debugging) + { + QTextStream out2 ( &file ); + x2goDebug<<"LogLevel DEBUG1"; + out2<<"LogLevel DEBUG1"; + file.close(); + } x2goDebug<<etcDir +"/sshd_config created."; }
Anyone? On May 23, 2016 8:14 AM, "Mike DePaulo" <mikedep333@gmail.com> wrote:
Hi guys,
Background: I am trying to fix bug #1002 completely; there appear to be multiple underlying bugs. One of them is that unless I start x2goclient from a cygwin shell, cygwin sshd doesn't actually listen its port.
Anyway, at the moment I am trying to make x2goclient start sshd with debug logging when x2goclient is launched with --debug, but I am unable to do so. Every time I launch x2goclient, sshd_config is regenerated without the debug line.
I've tried 2 different approaches, you can see them below. Ignore the x2goDebug line.
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..a1d92a8 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -10292,6 +10292,8 @@ void ONMainWindow::generateEtcFiles() /* This may need some sanitization, i.e., appDir could potentially include whitespace. */ <<appDir<<"/sftp-server\n"; #endif
- x2goDebug<<"LogLevel DEBUG1";
- out<<"LogLevel DEBUG1"; file.close(); x2goDebug<<etcDir +"/sshd_config created."; }
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..928da70 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -10293,6 +10293,13 @@ void ONMainWindow::generateEtcFiles() <<appDir<<"/sftp-server\n"; #endif file.close();
- if (debugging)
- {
QTextStream out2 ( &file );
x2goDebug<<"LogLevel DEBUG1";
out2<<"LogLevel DEBUG1";
file.close();
- } x2goDebug<<etcDir +"/sshd_config created."; }
Hi Mike,
I didn't dig deeply into your problem (as it requires heavyweight Qt building environment) but here are my $0.02: line-terminating character, not a separator. Btw, it's also sometimes
a buffer-flushing character, so I won't be surprised if your line stays unflushed inside QTextStream (and it's obvious that file.close() doesn't know about QTextStream objects that refer to its QFile and cannot forcibly grab data from them, so one have to output newlines or use some flush method).
I've tried to google("QTextStream buffering") and the second returned page looks like the proof of my idea: http://stackoverflow.com/questions/10370630/qtextstream-is-not-outputting-an...
On 05/29/2016 03:57 PM, Mike DePaulo wrote:
Anyone?
On May 23, 2016 8:14 AM, "Mike DePaulo" <mikedep333@gmail.com <mailto:mikedep333@gmail.com>> wrote:
Hi guys, Background: I am trying to fix bug #1002 completely; there appear to be multiple underlying bugs. One of them is that unless I start x2goclient from a cygwin shell, cygwin sshd doesn't actually listen its port.
A shoot in the dark:
Working on something unrelated, I faced a similar problem yesterday and found the problem to be that sshd can't be started directly from native Windows programs because then it fails to find some dlls.
My solution was to invoke it through a login shell so that the environment is properly set:
C:\cygwin\bin\bash --login -c "/usr/sbin/sshd ..."
On 23.05.2016 02:14 PM, Mike DePaulo wrote:
[...] I've tried 2 different approaches, you can see them below. Ignore the x2goDebug line.
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..a1d92a8 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -10292,6 +10292,8 @@ void ONMainWindow::generateEtcFiles() /* This may need some sanitization, i.e., appDir could potentially include whitespace. */ <<appDir<<"/sftp-server\n"; #endif
- x2goDebug<<"LogLevel DEBUG1";
Force a flush of the current line by appending a newline, like so: out << "LogLevel DEBUG1\n"; Otherwise, the stream might wait for more input to come for the current line (but as it never comes, the line isn't written at all.)
- out<<"LogLevel DEBUG1"; file.close(); x2goDebug<<etcDir +"/sshd_config created."; }
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..928da70 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -10293,6 +10293,13 @@ void ONMainWindow::generateEtcFiles() <<appDir<<"/sftp-server\n"; #endif file.close();
This attempt is definitely wrong. The file is being closed here. Afterwards, you cannot write to it anymore. (Or well, you do, but it lands who knows where exactly. Most likely not in the selected file/the file previously associated with the FD.)
- if (debugging)
- {
QTextStream out2 ( &file );
x2goDebug<<"LogLevel DEBUG1";
out2<<"LogLevel DEBUG1";
file.close();
- } x2goDebug<<etcDir +"/sshd_config created."; }
Mihai
On Sun, May 29, 2016 at 11:03 PM, Mihai Moldovan <ionic@ionic.de> wrote:
On 23.05.2016 02:14 PM, Mike DePaulo wrote:
[...] I've tried 2 different approaches, you can see them below. Ignore the x2goDebug line.
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 925085b..a1d92a8 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -10292,6 +10292,8 @@ void ONMainWindow::generateEtcFiles() /* This may need some sanitization, i.e., appDir could potentially include whitespace. */ <<appDir<<"/sftp-server\n"; #endif
- x2goDebug<<"LogLevel DEBUG1";
Force a flush of the current line by appending a newline, like so: out << "LogLevel DEBUG1\n";
Thanks Nable and Mihai; I fixed it and pushed the commit. I think the problem was that the prior line, which you cannot see due to the #ifdef, lacked a newline. I still added the newline to this new line though. And Salvador, I'll try your advice out. -Mike