aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r--src/testing/testing.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 75eab1a06..a24c1feae 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -385,6 +385,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
385 return; 385 return;
386 } 386 }
387 d->hostkeybuf[103] = '\0'; 387 d->hostkeybuf[103] = '\0';
388
388 if ((bytes_read < 0) || 389 if ((bytes_read < 0) ||
389 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, 390 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (d->hostkeybuf,
390 &d->id.hashPubKey))) 391 &d->id.hashPubKey)))
@@ -789,6 +790,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
789 * (use NULL for localhost). 790 * (use NULL for localhost).
790 * @param ssh_username ssh username to use when connecting to hostname 791 * @param ssh_username ssh username to use when connecting to hostname
791 * @param sshport port to pass to ssh process when connecting to hostname 792 * @param sshport port to pass to ssh process when connecting to hostname
793 * @param hostkey pointer to a hostkey to be written to disk (instead of being generated)
792 * @param hostkey_callback function to call once the hostkey has been 794 * @param hostkey_callback function to call once the hostkey has been
793 * generated for this peer, but it hasn't yet been started 795 * generated for this peer, but it hasn't yet been started
794 * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start) 796 * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start)
@@ -803,6 +805,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
803 const char *hostname, 805 const char *hostname,
804 const char *ssh_username, 806 const char *ssh_username,
805 uint16_t sshport, 807 uint16_t sshport,
808 const char *hostkey,
806 GNUNET_TESTING_NotifyHostkeyCreated 809 GNUNET_TESTING_NotifyHostkeyCreated
807 hostkey_callback, void *hostkey_cls, 810 hostkey_callback, void *hostkey_cls,
808 GNUNET_TESTING_NotifyDaemonRunning cb, 811 GNUNET_TESTING_NotifyDaemonRunning cb,
@@ -811,6 +814,9 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
811 struct GNUNET_TESTING_Daemon *ret; 814 struct GNUNET_TESTING_Daemon *ret;
812 char *arg; 815 char *arg;
813 char *username; 816 char *username;
817 char *servicehome;
818 char *hostkeyfile;
819 struct GNUNET_DISK_FileHandle *fn;
814 820
815 ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon)); 821 ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon));
816 ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); 822 ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname);
@@ -842,6 +848,28 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
842 GNUNET_CONFIGURATION_set_value_string (ret->cfg, 848 GNUNET_CONFIGURATION_set_value_string (ret->cfg,
843 "PATHS", 849 "PATHS",
844 "DEFAULTCONFIG", ret->cfgfile); 850 "DEFAULTCONFIG", ret->cfgfile);
851 if (hostkey != NULL)
852 {
853 GNUNET_assert(GNUNET_OK ==
854 GNUNET_CONFIGURATION_get_value_string (ret->cfg,
855 "PATHS",
856 "SERVICEHOME",
857 &servicehome));
858 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_create (servicehome));
859 GNUNET_asprintf(&hostkeyfile, "%s/.hostkey", servicehome);
860 fn =
861 GNUNET_DISK_file_open (hostkeyfile,
862 GNUNET_DISK_OPEN_READWRITE
863 | GNUNET_DISK_OPEN_CREATE,
864 GNUNET_DISK_PERM_USER_READ |
865 GNUNET_DISK_PERM_USER_WRITE);
866 GNUNET_assert(fn != NULL);
867 GNUNET_assert(HOSTKEYFILESIZE == GNUNET_DISK_file_write(fn, hostkey, HOSTKEYFILESIZE));
868 GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fn));
869 GNUNET_free(servicehome);
870 GNUNET_free(hostkeyfile);
871 }
872
845 /* 1) write configuration to temporary file */ 873 /* 1) write configuration to temporary file */
846 if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile)) 874 if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile))
847 { 875 {