Merge lp:~jakobunt/ltsp/ldm-log-v2 into lp:~ltsp-upstream/ltsp/ldm-trunk

Proposed by Jakob Unterwurzacher
Status: Merged
Merge reported by: Vagrant Cascadian
Merged at revision: not available
Proposed branch: lp:~jakobunt/ltsp/ldm-log-v2
Merge into: lp:~ltsp-upstream/ltsp/ldm-trunk
Diff against target: 130 lines (+40/-18)
1 file modified
src/plugins/ssh/ssh.c (+40/-18)
To merge this branch: bzr merge lp:~jakobunt/ltsp/ldm-log-v2
Reviewer Review Type Date Requested Status
Vagrant Cascadian Pending
Review via email: mp+235541@code.launchpad.net

Commit message

Bye bye "No response from server" - add ssh error logging

ldm now reads the full output from ssh to show a proper error message
to the user (and also write it to the log).

Description of the change

v2 of the "Bye bye No response from server" patch splits up the change into eight small chunks.
It also tries to be as little intrusive as possible.

Each patch has been individually tested (compile, successful login, incorrect password).

Thanks,
Jakob

To post a comment you must log in.
Revision history for this message
Vagrant Cascadian (vagrantc) wrote :

Thanks for the reworked patches!

Having tested this patchset, it does work to resolve the incorrect loging or password issue with feedback. It does seem to introduce a little noise on a successful login that flashes by too fast to read...

Overall, I think this is better than what we've had before.

Revision history for this message
Jakob Unterwurzacher (jakobunt) wrote :

Thanks for the quick feedback & merge!

Regarding the flashing text issue:

If you add LDM_LOGLEVEL=7 to lts.conf (watch out, this also logs passwords!), every change of the displayed text is logged like this:

Sep 22 05:08:10: [gtkgreet] DEBUG: Got command: msg <b>Verifying password. Please wait.</b>

I don't see changes after that one, but maybe your ssh output is different - the log should tell us what is going on.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/plugins/ssh/ssh.c'
--- src/plugins/ssh/ssh.c 2014-07-31 19:30:25 +0000
+++ src/plugins/ssh/ssh.c 2014-09-22 22:10:52 +0000
@@ -17,6 +17,7 @@
17#include <sys/stat.h>17#include <sys/stat.h>
18#include <utmp.h>18#include <utmp.h>
19#include <crypt.h>19#include <crypt.h>
20#include <errno.h>
2021
21#include "../../ldm.h"22#include "../../ldm.h"
22#include "../../ldmutils.h"23#include "../../ldmutils.h"
@@ -321,8 +322,9 @@
321 FD_SET(fd, &set);322 FD_SET(fd, &set);
322 st = select(FD_SETSIZE, &set, NULL, NULL, &timeout);323 st = select(FD_SETSIZE, &set, NULL, NULL, &timeout);
323324
324 if (child_exited) {325 if (st == -1 && errno == EINTR)
325 break; /* someone died on us */326 {
327 continue; /* interrupted by signal -> retry */
326 }328 }
327329
328 if (st < 0) { /* bad thing */330 if (st < 0) { /* bad thing */
@@ -348,6 +350,10 @@
348 total += size;350 total += size;
349 }351 }
350352
353 if (child_exited) {
354 break; /* someone died on us */
355 }
356
351 for (i = 0; i < expects->len; i++) {357 for (i = 0; i < expects->len; i++) {
352 if (strstr(p, g_ptr_array_index(expects, i))) {358 if (strstr(p, g_ptr_array_index(expects, i))) {
353 loopend = TRUE;359 loopend = TRUE;
@@ -358,22 +364,24 @@
358 if (loopend) {364 if (loopend) {
359 break;365 break;
360 }366 }
361
362 if (timeout.tv_sec == 0) {
363 break;
364 }
365 }367 }
366368
367 log_entry("ldm", 7, "expect saw: %s", p);369 log_entry("ldm", 7, "expect saw: %s", p);
368370
369 if (size < 0 || st < 0 || child_exited) {371 if (size < 0 || st < 0) {
370 return ERROR; /* error occured */372 return ERROR; /* error occured */
371 }373 }
372 if (loopcount == 0) {374 if (loopcount == 0) {
373 return TIMED_OUT; /* timed out */375 return TIMED_OUT; /* timed out */
374 } else {376 }
375 return i; /* which expect did we see? */377 /* Sleep a bit to make sure we notice if ssh died in the meantime */
376 }378 usleep(100000);
379 if (child_exited)
380 {
381 return ERROR;
382 }
383
384 return i; /* which expect did we see? */
377}385}
378386
379void387void
@@ -399,11 +407,14 @@
399 end of the line */407 end of the line */
400 if (seen == 0) {408 if (seen == 0) {
401 return;409 return;
402 } else if (seen == 1) {410 }
403 int i;411
404 g_strdelimit(lastseen, "\r\n\t", ' ');412 int i;
405 g_strchomp(lastseen);413 g_strdelimit(lastseen, "\r\n\t", ' ');
406 i = strlen(lastseen);414 g_strchomp(lastseen);
415 i = strlen(lastseen);
416
417 if (seen == 1) {
407 /* If it's not the first time through, or the :'s not at the418 /* If it's not the first time through, or the :'s not at the
408 * end of a line (password expiry or error), set the message */419 * end of a line (password expiry or error), set the message */
409 if ((!first_time) || (lastseen[i - 1] != ':')) {420 if ((!first_time) || (lastseen[i - 1] != ':')) {
@@ -417,7 +428,13 @@
417 }428 }
418 first_time = 0;429 first_time = 0;
419 } else if (seen < 0) {430 } else if (seen < 0) {
420 set_message(_("No response from server, restarting..."));431 if (i > 0) {
432 log_entry("ssh", 3, "ssh returned: %s", lastseen);
433 set_message(lastseen);
434 }
435 else {
436 set_message(_("No response from server, restarting..."));
437 }
421 sleep(5);438 sleep(5);
422 close_greeter();439 close_greeter();
423 die("ssh", "no response, restarting");440 die("ssh", "no response, restarting");
@@ -454,12 +471,17 @@
454 command = g_strjoin(" ", "ssh", "-Y", "-t", "-M",471 command = g_strjoin(" ", "ssh", "-Y", "-t", "-M",
455 "-S", sshinfo->ctl_socket,472 "-S", sshinfo->ctl_socket,
456 "-o", "NumberOfPasswordPrompts=1",473 "-o", "NumberOfPasswordPrompts=1",
474 /* ConnectTimeout should be less than the timeout ssh_chat
475 * passes to expect, so we get the error message from ssh
476 * before expect gives up
477 */
478 "-o", "ConnectTimeout=10",
457 "-l", sshinfo->username,479 "-l", sshinfo->username,
458 port ? port : "",480 port ? port : "",
459 sshinfo->sshoptions ? sshinfo->sshoptions : "",481 sshinfo->sshoptions ? sshinfo->sshoptions : "",
460 sshinfo->server,482 sshinfo->server,
461 "echo " SENTINEL "; exec /bin/sh -", NULL);483 "echo " SENTINEL "; exec /bin/sh -", NULL);
462 log_entry("ssh", 7, "ssh_session: %s", command);484 log_entry("ssh", 6, "ssh_session: %s", command);
463485
464 sshinfo->sshpid = ldm_spawn(command, NULL, NULL, ssh_tty_init);486 sshinfo->sshpid = ldm_spawn(command, NULL, NULL, ssh_tty_init);
465487
@@ -487,7 +509,7 @@
487 command =509 command =
488 g_strjoin(" ", "ssh", "-S", sshinfo->ctl_socket, "-O", "exit",510 g_strjoin(" ", "ssh", "-S", sshinfo->ctl_socket, "-O", "exit",
489 sshinfo->server, NULL);511 sshinfo->server, NULL);
490 log_entry("ssh", 7, "closing ssh session: %s"), command;512 log_entry("ssh", 6, "closing ssh session: %s"), command;
491 pid = ldm_spawn(command, NULL, NULL, NULL);513 pid = ldm_spawn(command, NULL, NULL, NULL);
492 ldm_wait(pid);514 ldm_wait(pid);
493 close(sshinfo->sshfd);515 close(sshinfo->sshfd);

Subscribers

People subscribed via source and target branches