}
+/**
+ * Obtain the host's hostname.
+ *
+ * @param host handle to the host, NULL means 'localhost'
+ * @return hostname of the host
+ */
+const char *
+GNUNET_TESTBED_host_get_hostname (const struct GNUNET_TESTBED_Host *host)
+{
+ return GNUNET_TESTBED_host_get_hostname_ (host);
+}
+
+
/**
* Obtain the host's username
*
int ret;
unsigned int offset;
unsigned int count;
-
+
GNUNET_assert (NULL != filename);
if (GNUNET_YES != GNUNET_DISK_file_test (filename))
LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
return 0;
}
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
fs = 0;
if (0 == fs)
LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s has no data\n"), filename);
return 0;
}
- data = GNUNET_malloc (fs);
+ data = GNUNET_malloc (fs);
if (fs != GNUNET_DISK_fn_read (filename, data, fs))
{
GNUNET_free (data);
buf = &data[offset + 1];
}
else if ((data[offset] == '\n') || (data[offset] == '\0'))
- buf = &data[offset + 1];
+ buf = &data[offset + 1];
}
GNUNET_free (data);
if (NULL == starting_host)
- return 0;
+ return 0;
*hosts = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * count);
memcpy (*hosts,
&host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
}
rc = GNUNET_malloc (sizeof (struct RegisteredController));
rc->controller = controller;
- //host->controller = controller;
GNUNET_CONTAINER_DLL_insert_tail (host->rc_head, host->rc_tail, rc);
}
* 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;
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);
remote_args[argp++] = "-o";
remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
remote_args[argp++] = ssh_addr;
- 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)
{
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;
}