static void setup (TestCase *tc, gconstpointer data) { GPtrArray *ptr = g_ptr_array_new (); const TestFixture *fix = data; const gchar *old_val = g_getenv ("XDG_CONFIG_DIRS"); gint i; g_setenv ("XDG_CONFIG_DIRS", config_dir, TRUE); tc->cert_dir = g_build_filename (config_dir, "cockpit", "ws-certs.d", NULL); /* make sure we start clean */ delete_all(tc); g_ptr_array_add (ptr, "certificate"); g_ptr_array_add (ptr, "--user"); g_ptr_array_add (ptr, (gchar *) g_get_user_name ()); g_ptr_array_add (ptr, "--group"); g_ptr_array_add (ptr, (gchar *) g_get_user_name ()); for (i = 0; fix->files[i] != NULL; i++) g_ptr_array_add (ptr, (gchar *) fix->files[i]); if (fix->expected_message) cockpit_expect_message (fix->expected_message); tc->ret = cockpit_remotectl_certificate (ptr->len, (gchar **) ptr->pdata); g_ptr_array_free (ptr, TRUE); if (old_val) g_setenv ("XDG_CONFIG_DIRS", old_val, TRUE); else g_unsetenv ("XDG_CONFIG_DIRS"); }
static void setup (TestCase *tc, gconstpointer data) { GPtrArray *ptr = g_ptr_array_new (); const TestFixture *fix = data; const gchar *old_val = g_getenv ("XDG_CONFIG_DIRS"); gint i; struct group *gr = NULL; g_setenv ("XDG_CONFIG_DIRS", config_dir, TRUE); tc->cert_dir = g_build_filename (config_dir, "cockpit", "ws-certs.d", NULL); /* make sure we start clean */ delete_all(tc); if (fix->readonly_dir) { g_assert (g_mkdir_with_parents (tc->cert_dir, 0755) == 0); g_assert (g_chmod (tc->cert_dir, 0555) == 0); } g_ptr_array_add (ptr, "certificate"); if (fix->ensure) { cockpit_expect_info ("Generating temporary certificate*"); cockpit_expect_info ("Error generating temporary dummy cert using sscg, falling back to openssl*"); g_ptr_array_add (ptr, "--ensure"); } g_ptr_array_add (ptr, "--user"); g_ptr_array_add (ptr, (gchar *) g_get_user_name ()); gr = getgrnam (g_get_user_name ()); if (gr != NULL) { g_ptr_array_add (ptr, "--group"); g_ptr_array_add (ptr, (gchar *) g_get_user_name ()); } for (i = 0; fix->files[i] != NULL; i++) g_ptr_array_add (ptr, (gchar *) fix->files[i]); if (fix->expected_message) cockpit_expect_message (fix->expected_message); tc->ret = cockpit_remotectl_certificate (ptr->len, (gchar **) ptr->pdata); g_ptr_array_free (ptr, TRUE); if (old_val) g_setenv ("XDG_CONFIG_DIRS", old_val, TRUE); else g_unsetenv ("XDG_CONFIG_DIRS"); }