aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_socks.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-09-29 08:39:15 +0000
committerChristian Grothoff <christian@grothoff.org>2015-09-29 08:39:15 +0000
commitc353b355490cde6586db87691de6865a5f807098 (patch)
treeea37c10879e63d5fb272dc9bd8c6b6645dcd19bc /src/util/test_socks.c
parentcffbdaf5b9053fcf4266423b2167227523b082c4 (diff)
downloadgnunet-c353b355490cde6586db87691de6865a5f807098.tar.gz
gnunet-c353b355490cde6586db87691de6865a5f807098.zip
stop crashing if sshd is not running on loopback
Diffstat (limited to 'src/util/test_socks.c')
-rw-r--r--src/util/test_socks.c59
1 files changed, 48 insertions, 11 deletions
diff --git a/src/util/test_socks.c b/src/util/test_socks.c
index a1ebb9af8..5ca086ee1 100644
--- a/src/util/test_socks.c
+++ b/src/util/test_socks.c
@@ -99,7 +99,8 @@ recv_bounce (void *cls, const struct GNUNET_MessageHeader *got)
99 struct GNUNET_MessageHeader msg; 99 struct GNUNET_MessageHeader msg;
100 100
101 GNUNET_assert (got != NULL); /* timeout */ 101 GNUNET_assert (got != NULL); /* timeout */
102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving bounce, checking content\n"); 102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
103 "Receiving bounce, checking content\n");
103 msg.type = htons (MY_TYPE); 104 msg.type = htons (MY_TYPE);
104 msg.size = htons (sizeof (struct GNUNET_MessageHeader)); 105 msg.size = htons (sizeof (struct GNUNET_MessageHeader));
105 GNUNET_assert (0 == memcmp (got, &msg, sizeof (struct GNUNET_MessageHeader))); 106 GNUNET_assert (0 == memcmp (got, &msg, sizeof (struct GNUNET_MessageHeader)));
@@ -173,18 +174,25 @@ int
173main (int argc, char *argv[]) 174main (int argc, char *argv[])
174{ 175{
175 int ok; 176 int ok;
176 char * socksport = "1081"; 177 int status;
178 const char *socksport = "1081";
177 179
178 GNUNET_log_setup ("test_client", 180 GNUNET_log_setup ("test_client",
179 "WARNING", 181 "WARNING",
180 NULL); 182 NULL);
181 183
182 pid_t pid = fork(); 184 pid_t pid = fork();
183 if (pid < 0) 185 GNUNET_assert (pid >= 0);
184 abort(); 186 if (pid == 0)
185 if (pid == 0) { 187 {
186 execlp ("ssh","ssh","-D",socksport,"127.0.0.1","-N",(char*)NULL); 188 execlp ("ssh",
187 perror ("execlp(\"ssh\",\"ssh\",\"-D\",\"1081\",\"127.0.0.1\",\"-N\") "); 189 "ssh",
190 "-D",
191 socksport,
192 "127.0.0.1",
193 "-N",
194 NULL);
195 perror ("execlp (\"ssh\",\"ssh\",\"-D\",\"1081\",\"127.0.0.1\",\"-N\") ");
188 printf ("" 196 printf (""
189"Please ensure you have ssh installed and have sshd installed and running :\n" 197"Please ensure you have ssh installed and have sshd installed and running :\n"
190"\tsudo apt-get install openssh-client openssh-server\n" 198"\tsudo apt-get install openssh-client openssh-server\n"
@@ -195,10 +203,38 @@ main (int argc, char *argv[])
195"\t CheckHostIP no\n" 203"\t CheckHostIP no\n"
196"\t Protocol 2\n" 204"\t Protocol 2\n"
197"\t ProxyCommand nc 127.0.0.1 22\n"); 205"\t ProxyCommand nc 127.0.0.1 22\n");
198 kill (getppid(), SIGTERM); 206 kill (getppid(), SIGALRM);
199 return 1; 207 return 1;
200 } 208 }
201 sleep(1); 209 if (0 != sleep (1))
210 {
211 /* sleep interrupted, likely SIGALRM, failure to
212 launch child, terminate */
213 printf (""
214"Please ensure you have ssh installed and have sshd installed and running :\n"
215"\tsudo apt-get install openssh-client openssh-server\n"
216"If you run Tor as a network proxy then Tor might prevent ssh from connecting\n"
217"to localhost. Please either run make check from an unproxied user, or else\n"
218"add these lines to the beginning of your ~/.ssh/config file :"
219"\tHost 127.0.0.1 localhost\n"
220"\t CheckHostIP no\n"
221"\t Protocol 2\n"
222"\t ProxyCommand nc 127.0.0.1 22\n");
223 return 77;
224 }
225 /* check if child exec()ed but died */
226 if (0 != waitpid (pid, &status, WNOHANG))
227 {
228 printf (""
229"If you run Tor as a network proxy then Tor might prevent ssh from connecting\n"
230"to localhost. Please either run make check from an unproxied user, or else\n"
231"add these lines to the beginning of your ~/.ssh/config file :"
232"\tHost 127.0.0.1 localhost\n"
233"\t CheckHostIP no\n"
234"\t Protocol 2\n"
235"\t ProxyCommand nc 127.0.0.1 22\n");
236 return 77;
237 }
202 238
203 cfg = GNUNET_CONFIGURATION_create (); 239 cfg = GNUNET_CONFIGURATION_create ();
204 GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "SOCKSHOST", "127.0.0.1"); 240 GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "SOCKSHOST", "127.0.0.1");
@@ -209,8 +245,9 @@ main (int argc, char *argv[])
209 GNUNET_SCHEDULER_run (&task, &ok); 245 GNUNET_SCHEDULER_run (&task, &ok);
210 GNUNET_CONFIGURATION_destroy (cfg); 246 GNUNET_CONFIGURATION_destroy (cfg);
211 247
212 kill (pid,SIGTERM); 248 GNUNET_break (0 == kill (pid, SIGTERM));
249 GNUNET_break (pid == waitpid (pid, &status, 0));
213 return ok; 250 return ok;
214} 251}
215 252
216/* end of test_client.c */ 253/* end of test_socks.c */