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
1=== modified file 'src/plugins/ssh/ssh.c'
2--- src/plugins/ssh/ssh.c 2014-07-31 19:30:25 +0000
3+++ src/plugins/ssh/ssh.c 2014-09-22 22:10:52 +0000
4@@ -17,6 +17,7 @@
5 #include <sys/stat.h>
6 #include <utmp.h>
7 #include <crypt.h>
8+#include <errno.h>
9
10 #include "../../ldm.h"
11 #include "../../ldmutils.h"
12@@ -321,8 +322,9 @@
13 FD_SET(fd, &set);
14 st = select(FD_SETSIZE, &set, NULL, NULL, &timeout);
15
16- if (child_exited) {
17- break; /* someone died on us */
18+ if (st == -1 && errno == EINTR)
19+ {
20+ continue; /* interrupted by signal -> retry */
21 }
22
23 if (st < 0) { /* bad thing */
24@@ -348,6 +350,10 @@
25 total += size;
26 }
27
28+ if (child_exited) {
29+ break; /* someone died on us */
30+ }
31+
32 for (i = 0; i < expects->len; i++) {
33 if (strstr(p, g_ptr_array_index(expects, i))) {
34 loopend = TRUE;
35@@ -358,22 +364,24 @@
36 if (loopend) {
37 break;
38 }
39-
40- if (timeout.tv_sec == 0) {
41- break;
42- }
43 }
44
45 log_entry("ldm", 7, "expect saw: %s", p);
46
47- if (size < 0 || st < 0 || child_exited) {
48+ if (size < 0 || st < 0) {
49 return ERROR; /* error occured */
50 }
51 if (loopcount == 0) {
52 return TIMED_OUT; /* timed out */
53- } else {
54- return i; /* which expect did we see? */
55- }
56+ }
57+ /* Sleep a bit to make sure we notice if ssh died in the meantime */
58+ usleep(100000);
59+ if (child_exited)
60+ {
61+ return ERROR;
62+ }
63+
64+ return i; /* which expect did we see? */
65 }
66
67 void
68@@ -399,11 +407,14 @@
69 end of the line */
70 if (seen == 0) {
71 return;
72- } else if (seen == 1) {
73- int i;
74- g_strdelimit(lastseen, "\r\n\t", ' ');
75- g_strchomp(lastseen);
76- i = strlen(lastseen);
77+ }
78+
79+ int i;
80+ g_strdelimit(lastseen, "\r\n\t", ' ');
81+ g_strchomp(lastseen);
82+ i = strlen(lastseen);
83+
84+ if (seen == 1) {
85 /* If it's not the first time through, or the :'s not at the
86 * end of a line (password expiry or error), set the message */
87 if ((!first_time) || (lastseen[i - 1] != ':')) {
88@@ -417,7 +428,13 @@
89 }
90 first_time = 0;
91 } else if (seen < 0) {
92- set_message(_("No response from server, restarting..."));
93+ if (i > 0) {
94+ log_entry("ssh", 3, "ssh returned: %s", lastseen);
95+ set_message(lastseen);
96+ }
97+ else {
98+ set_message(_("No response from server, restarting..."));
99+ }
100 sleep(5);
101 close_greeter();
102 die("ssh", "no response, restarting");
103@@ -454,12 +471,17 @@
104 command = g_strjoin(" ", "ssh", "-Y", "-t", "-M",
105 "-S", sshinfo->ctl_socket,
106 "-o", "NumberOfPasswordPrompts=1",
107+ /* ConnectTimeout should be less than the timeout ssh_chat
108+ * passes to expect, so we get the error message from ssh
109+ * before expect gives up
110+ */
111+ "-o", "ConnectTimeout=10",
112 "-l", sshinfo->username,
113 port ? port : "",
114 sshinfo->sshoptions ? sshinfo->sshoptions : "",
115 sshinfo->server,
116 "echo " SENTINEL "; exec /bin/sh -", NULL);
117- log_entry("ssh", 7, "ssh_session: %s", command);
118+ log_entry("ssh", 6, "ssh_session: %s", command);
119
120 sshinfo->sshpid = ldm_spawn(command, NULL, NULL, ssh_tty_init);
121
122@@ -487,7 +509,7 @@
123 command =
124 g_strjoin(" ", "ssh", "-S", sshinfo->ctl_socket, "-O", "exit",
125 sshinfo->server, NULL);
126- log_entry("ssh", 7, "closing ssh session: %s"), command;
127+ log_entry("ssh", 6, "closing ssh session: %s"), command;
128 pid = ldm_spawn(command, NULL, NULL, NULL);
129 ldm_wait(pid);
130 close(sshinfo->sshfd);

Subscribers

People subscribed via source and target branches