aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-10-31 09:15:05 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-10-31 09:15:05 +0000
commitf2ac1a162054f0f7646b35d3a03d623c58a24c20 (patch)
tree55b60da9bd2080693e6ac4d138bfc7c491fec645 /src
parent0a0036407218d7f9588d2b6b796b2a6f779bf700 (diff)
locate helpers in libexec
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_testbed_service.h4
-rw-r--r--src/mesh/gnunet-regex-profiler.c2
-rw-r--r--src/testbed/gnunet-testbed-profiler.c2
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c59
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c59
-rw-r--r--src/testbed/testbed.conf.in2
-rw-r--r--src/testbed/testbed_api.c16
-rw-r--r--src/testbed/testbed_api.h7
-rw-r--r--src/testbed/testbed_api_hosts.c20
9 files changed, 54 insertions, 117 deletions
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
index c2c6812f49..d9aa6dd4ac 100644
--- a/src/include/gnunet_testbed_service.h
+++ b/src/include/gnunet_testbed_service.h
@@ -136,11 +136,13 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
* Checks whether a host can be used to start testbed service
*
* @param host the host to check
+ * @param config the configuration handle to lookup the path of the testbed helper
* @return GNUNET_YES if testbed service can be started on the given host
* remotely; GNUNET_NO if not
*/
int
-GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host);
+GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_CONFIGURATION_Handle *config);
/**
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c
index 7d1ad10354..0e7b7391ae 100644
--- a/src/mesh/gnunet-regex-profiler.c
+++ b/src/mesh/gnunet-regex-profiler.c
@@ -1676,7 +1676,7 @@ run (void *cls, char *const *args, const char *cfgfile,
}
for (nhost = 0; nhost < num_hosts; nhost++)
{
- if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost]))
+ if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], config))
{
fprintf (stderr, _("Host %s cannot start testbed\n"),
GNUNET_TESTBED_host_get_hostname (hosts[nhost]));
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c
index 0d9143a863..6a5b3cf717 100644
--- a/src/testbed/gnunet-testbed-profiler.c
+++ b/src/testbed/gnunet-testbed-profiler.c
@@ -718,7 +718,7 @@ run (void *cls, char *const *args, const char *cfgfile,
}
for (nhost = 0; nhost < num_hosts; nhost++)
{
- if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost]))
+ if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], config))
{
fprintf (stderr, _("Host %s cannot start testbed\n"),
GNUNET_TESTBED_host_get_hostname_ (hosts[nhost]));
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index 206944ae8f..f670422969 100644
--- a/src/testbed/test_testbed_api_3peers_3controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -680,6 +680,16 @@ run (void *cls, char *const *args, const char *cfgfile,
{
host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
GNUNET_assert (NULL != host);
+ if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (host, config))
+ {
+ GNUNET_TESTBED_host_destroy (host);
+ host = NULL;
+ (void) PRINTF ("%s",
+ "Unable to run the test as this system is not configured "
+ "to use password less SSH logins to localhost.\n"
+ "Marking test as successful\n");
+ return;
+ }
cfg = GNUNET_CONFIGURATION_dup (config);
cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
NULL);
@@ -691,46 +701,6 @@ run (void *cls, char *const *args, const char *cfgfile,
/**
- * Function to check if
- * 1. Password-less SSH logins to given ip work
- * 2. gnunet-helper-testbed is found on the PATH on the remote side
- *
- * @param host_str numeric representation of the host's ip
- * @return GNUNET_YES if password-less SSH login to the given host works;
- * GNUNET_NO if not
- */
-static int
-check_ssh (char *host_str)
-{
- char *const remote_args[] = {
- "ssh", "-o", "BatchMode=yes", "-o", "CheckHostIP=no",
- "-o", "NoHostAuthenticationForLocalhost=yes", "-q",
- host_str, "which", "gnunet-helper-testbed", NULL
- };
- // FIXME: the above no longer works with libexec/-installation!
- struct GNUNET_OS_Process *auxp;
- enum GNUNET_OS_ProcessStatusType type;
- unsigned long code;
- int ret;
-
- auxp =
- GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
- NULL, "ssh", remote_args);
- GNUNET_assert (NULL != auxp);
- do
- {
- ret = GNUNET_OS_process_status (auxp, &type, &code);
- GNUNET_assert (GNUNET_SYSERR != ret);
- (void) usleep (300);
- }
- while (GNUNET_NO == ret);
- (void) GNUNET_OS_process_wait (auxp);
- GNUNET_OS_process_destroy (auxp);
- return (0 != code) ? GNUNET_NO : GNUNET_YES;
-}
-
-
-/**
* Main function
*/
int
@@ -745,8 +715,6 @@ main (int argc, char **argv)
};
int ret;
- if (GNUNET_YES != check_ssh ("127.0.0.1"))
- goto error_exit;
result = INIT;
ret =
GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
@@ -755,13 +723,6 @@ main (int argc, char **argv)
if ((GNUNET_OK != ret) || (SUCCESS != result))
return 1;
return 0;
-
- error_exit:
- (void) PRINTF ("%s",
- "Unable to run the test as this system is not configured "
- "to use password less SSH logins to localhost.\n"
- "Marking test as successful\n");
- return 0;
}
/* end of test_testbed_api_3peers_3controllers.c */
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index abde651664..471fb8630d 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -633,6 +633,16 @@ run (void *cls, char *const *args, const char *cfgfile,
{
host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
GNUNET_assert (NULL != host);
+ if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (host, config))
+ {
+ GNUNET_TESTBED_host_destroy (host);
+ host = NULL;
+ (void) PRINTF ("%s",
+ "Unable to run the test as this system is not configured "
+ "to use password less SSH logins to localhost.\n"
+ "Marking test as successful\n");
+ return;
+ }
cfg = GNUNET_CONFIGURATION_dup (config);
cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
NULL);
@@ -644,46 +654,6 @@ run (void *cls, char *const *args, const char *cfgfile,
/**
- * Function to check if
- * 1. Password-less SSH logins to given ip work
- * 2. gnunet-helper-testbed is found on the PATH on the remote side
- *
- * @param host_str numeric representation of the host's ip
- * @return GNUNET_YES if password-less SSH login to the given host works;
- * GNUNET_NO if not
- */
-static int
-check_ssh (char *host_str)
-{
- char *const remote_args[] = {
- "ssh", "-o", "BatchMode=yes", "-o", "CheckHostIP=no",
- "-o", "NoHostAuthenticationForLocalhost=yes", "-q",
- host_str, "which", "gnunet-helper-testbed", NULL
- };
- // FIXME: the above no longer works with libexec/-installation!
- struct GNUNET_OS_Process *auxp;
- enum GNUNET_OS_ProcessStatusType type;
- unsigned long code;
- int ret;
-
- auxp =
- GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
- NULL, "ssh", remote_args);
- GNUNET_assert (NULL != auxp);
- do
- {
- ret = GNUNET_OS_process_status (auxp, &type, &code);
- GNUNET_assert (GNUNET_SYSERR != ret);
- (void) usleep (300);
- }
- while (GNUNET_NO == ret);
- (void) GNUNET_OS_process_wait (auxp);
- GNUNET_OS_process_destroy (auxp);
- return (0 != code) ? GNUNET_NO : GNUNET_YES;
-}
-
-
-/**
* Main function
*/
int
@@ -698,8 +668,6 @@ main (int argc, char **argv)
};
int ret;
- if (GNUNET_YES != check_ssh ("127.0.0.1"))
- goto error_exit;
result = INIT;
ret =
GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
@@ -708,13 +676,6 @@ main (int argc, char **argv)
if ((GNUNET_OK != ret) || (SLAVE3_LINK_SUCCESS != result))
return 1;
return 0;
-
- error_exit:
- (void) PRINTF ("%s",
- "Unable to run the test as this system is not configured "
- "to use password less SSH logins to localhost.\n"
- "Marking test as successful\n");
- return 0;
}
/* end of test_testbed_api_controllerlink.c */
diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in
index 418f11cd3a..0da161c670 100644
--- a/src/testbed/testbed.conf.in
+++ b/src/testbed/testbed.conf.in
@@ -4,6 +4,8 @@ AUTOSTART = NO
HOSTNAME = localhost
HOME = $SERVICEHOME
BINARY = gnunet-service-testbed
+# Set this to the path where the testbed helper is installed
+# HELPER_BINARY_PATH = @prefix@/lib/gnunet/libexec/gnunet-helper-testbed
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
UNIXPATH = /tmp/gnunet-service-testbed.sock
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 9696785f3e..5bba87c199 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -68,13 +68,6 @@
/**
- * Testbed Helper binary name
- */
-#define HELPER_TESTBED_BINARY "gnunet-helper-testbed"
-#define HELPER_TESTBED_BINARY_SSH ". ~/.bashrc; gnunet-helper-testbed"
-
-
-/**
* Handle for controller process
*/
struct GNUNET_TESTBED_ControllerProc
@@ -1464,6 +1457,7 @@ GNUNET_TESTBED_controller_start (const char *controller_ip,
}
else
{
+ char *helper_binary_path;
char *remote_args[10];
unsigned int argp;
const char *username;
@@ -1485,13 +1479,17 @@ GNUNET_TESTBED_controller_start (const char *controller_ip,
remote_args[argp++] = "-o";
remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
remote_args[argp++] = cp->dst;
- // FIXME: lib/gnunet/libexec/-prefix missing here!!!
- remote_args[argp++] = HELPER_TESTBED_BINARY_SSH;
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
+ "HELPER_BINARY_PATH",
+ &helper_binary_path))
+ helper_binary_path = GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
+ remote_args[argp++] = helper_binary_path;
remote_args[argp++] = NULL;
GNUNET_assert (argp == 10);
cp->helper =
GNUNET_HELPER_start (GNUNET_NO, "ssh", remote_args, &helper_mst,
&helper_exp_cb, cp);
+ GNUNET_free (helper_binary_path);
}
if (NULL == cp->helper)
{
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index ba9ee0dcf8..f492133e21 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -30,6 +30,13 @@
#include "gnunet_testbed_service.h"
#include "testbed.h"
+
+/**
+ * Testbed Helper binary name
+ */
+#define HELPER_TESTBED_BINARY "gnunet-helper-testbed"
+
+
/**
* Enumeration of operations
*/
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 387da99e0b..42b8e38649 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -485,13 +485,16 @@ GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
* Checks whether a host can be used to start testbed service
*
* @param host the host to check
+ * @param config the configuration handle to lookup the path of the testbed helper
* @return GNUNET_YES if testbed service can be started on the given host
* remotely; GNUNET_NO if not
*/
int
-GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
+GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_CONFIGURATION_Handle *config)
{
char *remote_args[11];
+ char *helper_binary_path;
char *portstr;
char *ssh_addr;
const char *hostname;
@@ -508,6 +511,10 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
ssh_addr = GNUNET_strdup (hostname);
else
GNUNET_asprintf (&ssh_addr, "%s@%s", host->username, hostname);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (config, "testbed",
+ "HELPER_BINARY_PATH",
+ &helper_binary_path))
+ helper_binary_path = GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
argp = 0;
remote_args[argp++] = "ssh";
GNUNET_asprintf (&portstr, "%u", host->port);
@@ -518,13 +525,12 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
remote_args[argp++] = "-o";
remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
remote_args[argp++] = ssh_addr;
- // FIXME: this no longer works with 'libexec/' paths!
- remote_args[argp++] = "which";
- remote_args[argp++] = "gnunet-helper-testbed";
+ remote_args[argp++] = "stat";
+ remote_args[argp++] = helper_binary_path;
remote_args[argp++] = NULL;
GNUNET_assert (argp == 11);
auxp =
- GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
+ GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, NULL,
NULL, "ssh", remote_args);
if (NULL == auxp)
{
@@ -538,11 +544,11 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
GNUNET_assert (GNUNET_SYSERR != ret);
(void) usleep (300);
}
- while (GNUNET_NO == ret);
- //(void) GNUNET_OS_process_wait (auxp);
+ while (GNUNET_NO == ret);
GNUNET_OS_process_destroy (auxp);
GNUNET_free (ssh_addr);
GNUNET_free (portstr);
+ GNUNET_free (helper_binary_path);
return (0 != code) ? GNUNET_NO : GNUNET_YES;
}