Пример #1
0
static gboolean
volume_group_remdev_job_thread (GCancellable *cancellable,
                                gpointer user_data,
                                GError **error)
{
  VolumeGroupRemdevJobData *data = user_data;
  gchar *standard_output;
  gchar *standard_error;
  gint exit_status;
  gboolean ret;

  const gchar *vgreduce[] = { "vgreduce", data->vgname, data->pvname, NULL };

  ret = g_spawn_sync (NULL, (gchar **)vgreduce, NULL,
                      G_SPAWN_SEARCH_PATH, NULL, NULL,
                      &standard_output, &standard_error,
                      &exit_status, error);

  if (ret)
    {
      ret = storage_util_check_status_and_output ("vgreduce",
                                                  exit_status, standard_output,
                                                  standard_error, error);
    }

  g_free (standard_output);
  g_free (standard_error);

  if (ret && data->wipe)
    {
      const gchar *wipefs[] = { "wipefs", "-a", data->pvname, NULL };

      ret = g_spawn_sync (NULL, (gchar **)wipefs, NULL,
                          G_SPAWN_SEARCH_PATH, NULL, NULL,
                          &standard_output, &standard_error,
                          &exit_status, error);

      if (ret)
        {
          ret = storage_util_check_status_and_output ("wipefs",
                                                      exit_status, standard_output,
                                                      standard_error, error);
        }

      g_free (standard_output);
      g_free (standard_error);
    }

  return ret;
}
Пример #2
0
static gboolean
cra_plugin_nm_app (CraApp *app, const gchar *filename, GError **error)
{
	gboolean ret;
	_cleanup_free_ gchar *data_err = NULL;
	_cleanup_free_ gchar *data_out = NULL;
	const gchar *argv[] = { "/usr/bin/nm",
				"--dynamic",
				"--no-sort",
				"--undefined-only",
				filename,
				NULL };

	ret = g_spawn_sync (NULL, (gchar **) argv, NULL,
#if GLIB_CHECK_VERSION(2,40,0)
			    G_SPAWN_CLOEXEC_PIPES,
#else
			    G_SPAWN_DEFAULT,
#endif
			    NULL, NULL,
			    &data_out,
			    &data_err,
			    NULL, error);
	if (!ret)
		return FALSE;
	if (g_strstr_len (data_out, -1, "gtk_application_new") != NULL)
		as_app_add_metadata (AS_APP (app), "X-Kudo-GTK3", "", -1);
	if (g_strstr_len (data_out, -1, "gtk_application_set_app_menu") != NULL)
		as_app_add_metadata (AS_APP (app), "X-Kudo-UsesAppMenu", "", -1);
	return TRUE;
}
Пример #3
0
int chkForInitialConfig(const gchar *cfgdir, const gchar *cfgfile) {
  if(g_file_test(cfgdir, G_FILE_TEST_IS_DIR) == FALSE) {
    if(g_mkdir_with_parents (cfgdir, S_IRWXU)) return(1);
  }

  dump_config(cfgdir, "apt-dater.xml", (gchar *)apt_dater_xml, apt_dater_xml_len);

  /* Convert legacy hosts.conf to new hosts.xml using external helper script. */
  gchar *fnold = g_strdup_printf("%s/%s", cfgdir, "hosts.conf");
  gchar *fnnew = g_strdup_printf("%s/%s", cfgdir, "hosts.xml");
  if((g_file_test(fnnew, G_FILE_TEST_IS_REGULAR|G_FILE_TEST_EXISTS) == FALSE) &&
     (g_file_test(fnold, G_FILE_TEST_IS_REGULAR|G_FILE_TEST_EXISTS) == TRUE)) {

    gchar *argv[3] = {PKGLIBDIR"/hosts2xml", "hosts2xml", NULL};
    GError *error = NULL;
    if(g_spawn_sync(g_getenv ("HOME"), argv, NULL, G_SPAWN_CHILD_INHERITS_STDIN, NULL, NULL, NULL, NULL, NULL, &error) == FALSE) {
      g_warning("%s", error->message);
      g_clear_error (&error);
    }
  }

  dump_config(cfgdir, "hosts.xml", (gchar *)hosts_xml, hosts_xml_len);
#ifdef FEAT_TMUX
  dump_config(cfgdir, "tmux.conf", (gchar *)tmux_conf, tmux_conf_len);
#else
  dump_config(cfgdir, "screenrc", (gchar *)screenrc, screenrc_len);
#endif

 return(0);
}
Пример #4
0
static gboolean root_folder_setup(char *root, char *root_setup)
{
	int status;
	char *argv[3] = { root_setup, root, NULL };

	if (is_dir(root))
		return TRUE;

	if (root_setup == NULL)
		return FALSE;

	DBG("Setting up %s using %s", root, root_setup);

	if (!g_spawn_sync(NULL, argv, NULL, 0, NULL, NULL, NULL, NULL,
							&status, NULL)) {
		error("Unable to execute %s", root_setup);
		return FALSE;
	}

	if (WEXITSTATUS(status) != EXIT_SUCCESS) {
		error("%s exited with status %d", root_setup,
							WEXITSTATUS(status));
		return FALSE;
	}

	return is_dir(root);
}
Пример #5
0
static void _execute_php(Console * console, char * text)
{
	const unsigned int flags = G_SPAWN_FILE_AND_ARGV_ZERO;
	char * argv[] = { BINDIR "/" PROGNAME_PHP, PROGNAME_PHP, "-r", NULL,
		NULL };
	gchar * output = NULL;
	int status;
	GError * error = NULL;
	GtkTextBuffer * tbuf;
	GtkTextIter end;

	argv[3] = text;
	/* FIXME implement asynchronously */
	if(g_spawn_sync(NULL, argv, NULL, flags, NULL, NULL, &output, NULL,
				&status, &error) == FALSE)
	{
		fprintf(stderr, "%s: %s (status: %d)\n", PROGNAME_CONSOLE,
				error->message, status);
		g_error_free(error);
		return;
	}
	/* append the output */
	tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->console));
	gtk_text_buffer_get_end_iter(tbuf, &end);
	gtk_text_buffer_insert(tbuf, &end, output, -1);
	g_free(output);
}
Пример #6
0
static gboolean
collect_locales_from_localebin (void)
{
        gboolean found_locales = FALSE;
        const gchar *argv[] = { "locale", "-a", NULL };
        gchar **linep;
        g_auto (GStrv) lines = NULL;
        g_autofree gchar *output = NULL;

        if (g_spawn_sync (NULL, (gchar **) argv, NULL,
                          G_SPAWN_SEARCH_PATH|G_SPAWN_STDERR_TO_DEV_NULL,
                          NULL, NULL, &output, NULL, NULL, NULL) == FALSE)
                return FALSE;

        g_return_val_if_fail (output != NULL, FALSE);

        lines = g_strsplit (output, "\n", 0);
        if (lines) {
                linep = lines;
                while (*linep) {
                        if (*linep[0] && add_locale (*linep, TRUE))
                                found_locales = TRUE;
                        linep++;
                }
        }

        return found_locales;
}
Пример #7
0
gboolean
tmux_attach(HostNode *n, const SessNode *s, const gboolean shared) {
 gboolean r;
 GError *error = NULL;
 gchar **argv = tmux_attach_cmd(n, s, shared);

 g_assert(n);

 r = g_spawn_sync(g_getenv ("HOME"), argv, NULL, 
		  G_SPAWN_CHILD_INHERITS_STDIN, NULL, NULL,
		  NULL, NULL, NULL, &error);

 if(r == FALSE) {
  g_warning("%s", error->message);
  g_clear_error (&error);
 }

 g_strfreev(argv);

#ifdef FEAT_HISTORY
 if(n->parse_result && !tmux_get_sessions(n)) {
    n->parse_result = FALSE;
    return history_ts_failed(cfg, n);
 }
#endif

 return FALSE;
}
Пример #8
0
gboolean
start_webserver()
{

	hildon_banner_show_information(
			GTK_WIDGET(appdata->window),
			NULL,
			"Starting Webserver");

	gchar *arg[4] = {config->web_server_script, "start", settings->server_port, NULL};
	gboolean retval;

	retval = g_spawn_sync (config->app_dir,
							arg, NULL,
			                G_SPAWN_STDERR_TO_DEV_NULL,
			                NULL, NULL, NULL, NULL, NULL, NULL);
	sleep(1);

	if (retval != TRUE)
		return FALSE;
	else
		return TRUE;


}
Пример #9
0
static void
ToolsCoreWorkAroundLoop(ToolsServiceState *state,
                        gboolean before)
{
#ifdef __APPLE__
   if (state->mainService) {
      char *libDir = GuestApp_GetInstallPath();
      char *argv[] = {
         NULL,
         before ? "--startInternal" : "--stopInternal",
         NULL,
      };

      if (!libDir) {
         g_error("Failed to retrieve libDir.\n");
      }

      argv[0] = g_strdup_printf("%s/services.sh", libDir);
      free(libDir);
      if (!argv[0]) {
         g_error("Failed to construct argv[0].\n");
      }

      g_spawn_sync(NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
      free(argv[0]);
   }
#endif
}
Пример #10
0
static void
attach_process_update (AttachProcess * ap)
{
	gchar *tmp, *tmp1, *cmd;
	gchar *shell;
	gchar *argv[4];
	GError *err = NULL;
	GtkTreeStore *store;
	gboolean result;

	g_return_if_fail (ap);
	store = GTK_TREE_STORE (gtk_tree_view_get_model
							(GTK_TREE_VIEW (ap->treeview)));
	g_return_if_fail (store);
	
	if (anjuta_util_prog_is_installed ("ps", TRUE) == FALSE)
		return;

	tmp = anjuta_util_get_a_tmp_file ();
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
	cmd = g_strconcat ("ps axw -o pid,user,lstart,args > ", tmp, NULL);
#else
	cmd = g_strconcat ("ps axw -H -o pid,user,start_time,args > ", tmp, NULL);
#endif
	shell = anjuta_util_user_shell ();
	argv[0] = shell;
	argv[1] = "-c";
	argv[2] = cmd;
	argv[3] = NULL;
	if (!g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, &err))
	{
		anjuta_util_dialog_error (NULL, _("Unable to execute: \"%s\". "
		                                  "The returned error was: \"%s\"."), cmd, err->message);
		g_error_free (err);
		g_free (tmp);
		g_free (cmd);
		return;
	}

	g_free (cmd);

	result = g_file_get_contents (tmp, &tmp1, NULL, NULL);
	remove (tmp);
	g_free (tmp);
	if (! result)
	{
		anjuta_util_dialog_error_system (NULL, errno,
										 _("Unable to open the file: %s\n"),
										 tmp);
		return;
	}

	attach_process_clear (ap, CLEAR_UPDATE);
	ap->ps_output = anjuta_util_convert_to_utf8 (tmp1);
	g_free (tmp1);
	if (ap->ps_output)
	{
		attach_process_review (ap);
	}
}
Пример #11
0
	UT_Error _runConversion(const UT_String& pdf_on_disk, const UT_String& output_on_disk, size_t which)
	{
		UT_Error rval = UT_ERROR;

		const char * pdftoabw_argv[4];
		
		int argc = 0;
		pdftoabw_argv[argc++] = pdf_conversion_programs[which].conversion_program;
		pdftoabw_argv[argc++] = pdf_on_disk.c_str ();
		pdftoabw_argv[argc++] = output_on_disk.c_str ();
		pdftoabw_argv[argc++] = NULL;
		
		// run conversion
		if (g_spawn_sync (NULL,
						  (gchar **)pdftoabw_argv,
						  NULL,
						  (GSpawnFlags)(G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL),
						  NULL,
						  NULL,
						  NULL,
						  NULL,
						  NULL,
						  NULL))
			{
				char * uri = UT_go_filename_to_uri (output_on_disk.c_str ());
				if (uri)
					{
						// import the document
						rval = IE_Imp::loadFile (getDoc (), uri, IE_Imp::fileTypeForSuffix (pdf_conversion_programs[which].extension));
						g_free (uri);
					}
			}

		return rval;
	}
Пример #12
0
static gboolean
asb_plugin_nm_app (AsbApp *app, const gchar *filename, GError **error)
{
	gboolean ret;
	_cleanup_free_ gchar *data_err = NULL;
	_cleanup_free_ gchar *data_out = NULL;
	const gchar *argv[] = { "/usr/bin/nm",
				"--dynamic",
				"--no-sort",
				"--undefined-only",
				filename,
				NULL };

	ret = g_spawn_sync (NULL, (gchar **) argv, NULL,
#if GLIB_CHECK_VERSION(2,40,0)
			    G_SPAWN_CLOEXEC_PIPES,
#else
			    G_SPAWN_DEFAULT,
#endif
			    NULL, NULL,
			    &data_out,
			    &data_err,
			    NULL, error);
	if (!ret)
		return FALSE;
	if (g_strstr_len (data_out, -1, "gtk_application_new") != NULL)
		as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_MODERN_TOOLKIT);
	if (g_strstr_len (data_out, -1, "gtk_application_set_app_menu") != NULL)
		as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU);
	return TRUE;
}
Пример #13
0
gboolean
spawn_with_login_uid (GDBusMethodInvocation  *context,
                      const gchar            *argv[],
                      GError                **error)
{
        GError *local_error;
        gchar loginuid[20];
        gchar *std_err;
        gint status;

        get_caller_loginuid (context, loginuid, 20);

        local_error = NULL;
        std_err = NULL;

        if (!g_spawn_sync (NULL, (gchar**)argv, NULL, 0, setup_loginuid, loginuid, NULL, &std_err, &status, &local_error)) {
                g_propagate_error (error, local_error);
                g_free (std_err);
                return FALSE;
        }

        if (WEXITSTATUS (status) != 0) {
                g_set_error (error,
                             G_SPAWN_ERROR,
                             G_SPAWN_ERROR_FAILED,
                             "%s returned an error (%d): %s",
                             argv[0], WEXITSTATUS(status), std_err);
                g_free (std_err);
                return FALSE;
        }

        g_free (std_err);

        return TRUE;
}
Пример #14
0
bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData& result)
{
    CString binaryPath = fileSystemRepresentation(executablePathOfPluginProcess());
    CString pluginPathCString = fileSystemRepresentation(pluginPath);
    char* argv[4];
    argv[0] = const_cast<char*>(binaryPath.data());
    argv[1] = const_cast<char*>("-scanPlugin");
    argv[2] = const_cast<char*>(pluginPathCString.data());
    argv[3] = 0;

    gint status;
    gchar* stdOut;
    if (!g_spawn_sync(0, argv, 0, G_SPAWN_STDERR_TO_DEV_NULL, 0, 0, &stdOut, 0, &status, 0))
        return false;
    if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS)
        return false;

    const unsigned kNumLinesExpected = 3;
    String lines[kNumLinesExpected];
    unsigned lineIndex = 0;
    const UChar* current = reinterpret_cast<const UChar*>(stdOut);
    while (lineIndex < kNumLinesExpected) {
        const UChar* start = current;
        while (*current++ != UChar('\n')) { }
        lines[lineIndex++] = String(start, current - start - 1);
    }

    result.name.swap(lines[0]);
    result.description.swap(lines[1]);
    result.mimeDescription.swap(lines[2]);
    return !result.mimeDescription.isEmpty();
}
static gboolean
smartctl_sensors_interface_run (const char *command,
				const char *device,
				char **output)
{
  char *argv[4];
  GSpawnFlags flags = G_SPAWN_STDERR_TO_DEV_NULL;
  char *_output = NULL;
  int exit_status;

  g_return_val_if_fail(command != NULL, FALSE);
  g_return_val_if_fail(device != NULL, FALSE);

  argv[0] = SMARTCTL_HELPER;
  argv[1] = (char *) command;
  argv[2] = (char *) device;
  argv[3] = NULL;

  if (! output)
    flags |= G_SPAWN_STDOUT_TO_DEV_NULL;

  if (g_spawn_sync(NULL, argv, NULL, flags, NULL, NULL, output ? &_output : NULL, NULL, &exit_status, NULL))
    {
      if (exit_status == 0)
	{
	  if (output)
	    *output = _output;

	  return TRUE;
	}
      g_free(_output);
    }

  return FALSE;
}
Пример #16
0
static gboolean lookup_container_ip(const char* name, struct in_addr* addr)
{
    char* stdout_s, *name_s;
    int exit_status;
    gboolean success = FALSE;

    /* remove the suffix */
    name_s = g_strdup(name);
    *strrchr(name_s, '.') = '\0';

    char* argv[] = { "/usr/bin/dockerip", name_s, NULL, };

    if (!g_spawn_sync(NULL, argv, NULL,
                      G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_SEARCH_PATH, NULL,
                      NULL, &stdout_s, NULL, &exit_status, NULL)) {
        goto finally;
    }

    if (exit_status != 0) {
        goto finally;
    }

    stdout_s = g_strstrip(stdout_s);
    success = inet_aton(stdout_s, addr);

finally:

    g_free(name_s);
    g_free(stdout_s);

    return success;
}
Пример #17
0
/* This function hovers in a quantum superposition of horrifying and
 * beautiful.  Future generations may interpret it as modern art.
 */
gboolean
ot_test_run_libtest (const char *cmd, GError **error)
{
  gboolean ret = FALSE;
  const char *srcdir = g_getenv ("G_TEST_SRCDIR");
  int estatus;
  g_autoptr(GPtrArray) argv = g_ptr_array_new ();
  g_autoptr(GString) cmdstr = g_string_new ("");

  g_ptr_array_add (argv, "bash");
  g_ptr_array_add (argv, "-c");

  g_string_append (cmdstr, "set -xeuo pipefail; . ");
  g_string_append (cmdstr, srcdir);
  g_string_append (cmdstr, "/tests/libtest.sh; ");
  g_string_append (cmdstr, cmd);

  g_ptr_array_add (argv, cmdstr->str);
  g_ptr_array_add (argv, NULL);

  if (!g_spawn_sync (NULL, (char**)argv->pdata, NULL, G_SPAWN_SEARCH_PATH,
                     NULL, NULL, NULL, NULL, &estatus, error))
    goto out;

  if (!g_spawn_check_exit_status (estatus, error))
    goto out;

  ret = TRUE;
 out:
  return ret;
}
static gboolean
asb_plugin_gresource_app (AsbApp *app, const gchar *filename, GError **error)
{
	gboolean ret;
	g_autofree gchar *data_err = NULL;
	g_autofree gchar *data_out = NULL;
	const gchar *argv[] = { "/usr/bin/gresource",
				"list",
				filename,
				NULL };

	ret = g_spawn_sync (NULL, (gchar **) argv, NULL,
#if GLIB_CHECK_VERSION(2,40,0)
			    G_SPAWN_CLOEXEC_PIPES,
#else
			    G_SPAWN_DEFAULT,
#endif
			    NULL, NULL,
			    &data_out,
			    &data_err,
			    NULL, error);
	if (!ret)
		return FALSE;
	if (g_strstr_len (data_out, -1, "gtk/menus.ui") != NULL) {
		asb_package_log (asb_app_get_package (app),
				 ASB_PACKAGE_LOG_LEVEL_DEBUG,
				 "Auto-adding kudo AppMenu for %s",
				 as_app_get_id (AS_APP (app)));
		as_app_add_kudo_kind (AS_APP (app), AS_KUDO_KIND_APP_MENU);
	}
	return TRUE;
}
gchar *
get_package_name_from_desktop_item (MateDesktopItem * desktop_item)
{
	gchar *argv[6];
	gchar *package_name;
	gint retval;
	GError *error;

	argv[0] = "rpm";
	argv[1] = "-qf";
	argv[2] = "--qf";
	argv[3] = "%{NAME}";
	argv[4] = g_filename_from_uri (mate_desktop_item_get_location (desktop_item), NULL, NULL);
	argv[5] = NULL;

	error = NULL;

	if (!g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &package_name, NULL,
			&retval, &error))
	{
		g_warning ("error: [%s]\n", error->message);
		g_error_free (error);
		retval = -1;
	}

	g_free (argv[4]);

	if (!retval)
		return package_name;
	else
		return NULL;
}
Пример #20
0
static gpointer cloexec_thread(const gpointer prog) {
  GHashTable *seen = g_hash_table_new_full(g_str_hash, g_str_equal,
        g_free, NULL);
  gchar *argv[] = {prog, "--leak-check--", NULL};

  while (g_atomic_int_get(&leak_test_running)) {
    gchar *out;
    if (!g_spawn_sync(NULL, argv, NULL, G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
          G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL,
          &out, NULL, NULL, NULL)) {
      g_assert_not_reached();
    }

    gchar **lines = g_strsplit(out, "\n", 0);
    for (gchar **line = lines; *line != NULL; line++) {
      if (**line == 0) {
        continue;
      }
      if (g_hash_table_lookup(seen, *line) == NULL) {
        fprintf(stderr, "Exec child received leaked fd to %s\n", *line);
        g_hash_table_insert(seen, g_strdup(*line), (void *) 1);
      }
    }
    g_strfreev(lines);
    g_free(out);
  }

  g_hash_table_destroy(seen);
  return NULL;
}
Пример #21
0
static gint
extract_files (TrackerVerbosity  verbosity,
               char             *output_format)
{
	char **p;
	char *tracker_extract_path;
	char verbosity_str[2];
	GError *error = NULL;

	snprintf (verbosity_str, 2, "%i", verbosity);

	tracker_extract_path = g_build_filename(LIBEXECDIR, "tracker-extract", NULL);

	for (p = filenames; *p; p++) {
		char *argv[] = {tracker_extract_path,
		                "--output-format", output_format,
		                "--verbosity", verbosity_str,
		                "--file", *p, NULL };

		g_spawn_sync(NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, NULL, NULL, NULL, &error);

		if (error) {
			g_printerr ("%s: %s\n",
			            _("Could not run tracker-extract: "),
			            error->message);
			g_error_free (error);
			g_free (tracker_extract_path);
			return EXIT_FAILURE;
		}
	}

	g_free (tracker_extract_path);
	return EXIT_SUCCESS;
}
Пример #22
0
/*
 * set validation state according to zvm command line options
 * note: updates nap->validation_state
 */
static void ValidateNexe(struct NaClApp *nap)
{
  char *args[3] = {VALIDATOR_NAME, NULL, NULL};
  GError *error = NULL;
  int exit_status = 0;
  enum ValidationState {
    NotValidated,
    ValidationOK,
    ValidationFailed
  };

  assert(nap != NULL);
  assert(nap->system_manifest != NULL);

  /* skip validation? */
  nap->validation_state = NotValidated;
  if(nap->skip_validator != 0) return;

  /* prepare command line and run it */
  args[1] = nap->system_manifest->nexe;
  ZLOGFAIL(g_spawn_sync(NULL, args, NULL, G_SPAWN_SEARCH_PATH |
      G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL,
      NULL, NULL, &exit_status, &error) == 0, EPERM, "cannot start validator");

  /* check the result */
  nap->validation_state = exit_status == 0 ? ValidationOK : ValidationFailed;
  ZLOGFAIL(nap->validation_state != ValidationOK, ENOEXEC, "validation failed");
}
Пример #23
0
static void
fusermount_cleanup (const char *mountpoint)
{
  g_autoptr(GError) tmp_error = NULL;
  const char *fusermount_argv[] = { "fusermount", "-u", mountpoint, NULL};
  int estatus;

  if (!g_spawn_sync (NULL, (char**)fusermount_argv, NULL, G_SPAWN_SEARCH_PATH,
                     NULL, NULL, NULL, NULL, &estatus, &tmp_error))
    {
      g_prefix_error (&tmp_error, "Executing fusermount: ");
      goto out;
    }
  if (!g_spawn_check_exit_status (estatus, &tmp_error))
    {
      g_prefix_error (&tmp_error, "Executing fusermount: ");
      goto out;
    }

 out:
  /* We don't want a failure to unmount to be fatal, so all we do here
   * is log.  Though in practice what we *really* want is for the
   * fusermount to be in the bwrap namespace, and hence tied by the
   * kernel to the lifecycle of the container.  This would require
   * special casing for somehow doing FUSE mounts in bwrap.  Which
   * would be hard because NO_NEW_PRIVS turns off the setuid bits for
   * fuse.
   */
  if (tmp_error)
    sd_journal_print (LOG_WARNING, "%s", tmp_error->message);
}
static void
command_done (CommandData *cdata)
{
	if (cdata == NULL)
		return;

	if ((cdata->temp_dir != NULL) && path_is_dir (cdata->temp_dir)) {
		char *argv[4];

		argv[0] = "rm";
		argv[1] = "-rf";
		argv[2] = cdata->temp_dir;
		argv[3] = NULL;
		g_spawn_sync (g_get_tmp_dir (), argv, NULL,
			      G_SPAWN_SEARCH_PATH,
			      NULL, NULL,
			      NULL, NULL, NULL,
			      NULL);
	}

	g_free (cdata->command);
	if (cdata->app != NULL)
		g_object_unref (cdata->app);
	path_list_free (cdata->file_list);
	g_free (cdata->temp_dir);
	if (cdata->process != NULL)
		g_object_unref (cdata->process);

	CommandList = g_list_remove (CommandList, cdata);
	g_free (cdata);
}
Пример #25
0
/// Function to enable listening to a particular ethernet multicast address.
/// This is a highly non-portable function.
/// I wonder how you do this on BSD or Slowlaris?
FSTATIC gboolean
_enable_mcast_address(const char * addrstring	///<[in] multicast MAC address string suitable for giving to 'ip'
                      ,		     const char * dev		///<[in] ethernet device
                      ,		     gboolean enable)		///<[in] TRUE to enable, FALSE to disable
{
    GSpawnFlags	flags =  G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_SEARCH_PATH;
    gint		exit_status;
    const gchar*	constargv [] =
    {"ip", "maddress", (enable ? "add" : "delete"), addrstring, "dev", dev, NULL};
    gchar*		argv[DIMOF(constargv)];
    unsigned	j;


    if (NULL == addrstring) {
        return FALSE;
    }

    // This is really stupid and annoying - they have the wrong function prototype for g_spawn_sync...
    for (j=0; j < DIMOF(argv); ++j) {
        argv[j] = g_strdup(constargv[j]);
    }

    DEBUGMSG1("Running IP command %s %s %s %s %s %s", argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
    if (!g_spawn_sync(NULL, argv, NULL, flags, NULL, NULL, NULL, NULL, &exit_status, NULL)) {
        exit_status = 300;
    }
    for (j=0; j < DIMOF(argv); ++j) {
        g_free(argv[j]);
        argv[j] = NULL;
    }
    DEBUGMSG1("Previous IP command returned %d", exit_status);
    return exit_status == 0;
}
Пример #26
0
static void
nm_l2tp_stop_ipsec(void)
{
	const char *ipsec_binary;
	char session_name[128];
	GPtrArray *whack_argv;

	if (!(ipsec_binary=nm_find_ipsec())) return;

	sprintf(session_name, "nm-ipsec-l2tpd-%d", getpid());
	whack_argv = g_ptr_array_new ();
	g_ptr_array_add (whack_argv, (gpointer) g_strdup (ipsec_binary));
	g_ptr_array_add (whack_argv, (gpointer) g_strdup ("whack"));
	g_ptr_array_add (whack_argv, (gpointer) g_strdup ("--delete"));
	g_ptr_array_add (whack_argv, (gpointer) g_strdup ("--name"));
	g_ptr_array_add (whack_argv, (gpointer) g_strdup (session_name));
	g_ptr_array_add (whack_argv, NULL);

	if (!g_spawn_sync (NULL, (char **) whack_argv->pdata, NULL,
	                    0, NULL, NULL,
			    NULL,NULL,
			    NULL, NULL)) {
		free_args (whack_argv);
		return;
	}

	g_message("ipsec shut down");
}
Пример #27
0
static gboolean
apache_cmd (const char *cmd)
{
	const char *argv[8];
	char *cwd, *conf;
	int status;
	gboolean ok;

	cwd = g_get_current_dir ();
	conf = g_build_filename (cwd, "httpd.conf", NULL);

	argv[0] = APACHE_HTTPD;
	argv[1] = "-d";
	argv[2] = cwd;
	argv[3] = "-f";
	argv[4] = conf;
	argv[5] = "-k";
	argv[6] = cmd;
	argv[7] = NULL;

	ok = g_spawn_sync (cwd, (char **)argv, NULL, 0, NULL, NULL,
			   NULL, NULL, &status, NULL);
	if (ok)
		ok = (status == 0);

	g_free (cwd);
	g_free (conf);

	return ok;
}
Пример #28
0
void
rpmostreed_reboot (GCancellable *cancellable, GError **error)
{
  const char *child_argv[] = { "systemctl", "reboot", NULL };
  (void) g_spawn_sync (NULL, (char**)child_argv, NULL, G_SPAWN_CHILD_INHERITS_STDIN | G_SPAWN_SEARCH_PATH,
                       NULL, NULL, NULL, NULL, NULL, NULL);
}
Пример #29
0
int main( int argc, char *argv[] )
{
	char * args[] = {"mokoipawnc","--xmloutput", "-O./","test.mps", NULL};
	char *output = NULL;
	char *error = NULL;
	GError * err = NULL;

	args[0] = g_build_filename(g_path_get_dirname(argv[0] ), "mokoipawnc3", NULL);
	if ( g_spawn_sync( NULL, //working_directory
		args, //gchar **argv,
		NULL, //gchar **envp,
		G_SPAWN_SEARCH_PATH, //GSpawnFlags flags,
		NULL, //GSpawnChildSetupFunc child_setup,
		NULL, //gpointer user_data,
		&output, //gchar **standard_output,
		&error, //gchar **standard_error,
		NULL, //gint *exit_status,
		&err //GError **error
	))
	{
		g_print("output: %s\n", output);
		g_print("error: %s\n", error);
	}
	else
	{
		g_print("error: %s\n", err->message);
		g_error_free(err);
	}
	return 0;
}
Пример #30
0
static gboolean
setup_rofiles_usr (RpmOstreeBwrap *bwrap,
                   GError **error)
{
  gboolean ret = FALSE;
  int estatus;
  const char *rofiles_argv[] = { "rofiles-fuse", "./usr", NULL, NULL};
  gboolean mntpoint_created = FALSE;

  bwrap->rofiles_mnt = g_strdup ("/tmp/rofiles-fuse.XXXXXX");
  rofiles_argv[2] = bwrap->rofiles_mnt;

  if (!glnx_mkdtempat (AT_FDCWD, bwrap->rofiles_mnt, 0700, error))
    goto out;
  mntpoint_created = TRUE;

  if (!g_spawn_sync (NULL, (char**)rofiles_argv, NULL, G_SPAWN_SEARCH_PATH,
                     child_setup_fchdir, GINT_TO_POINTER (bwrap->rootfs_fd),
                     NULL, NULL, &estatus, error))
    goto out;
  if (!g_spawn_check_exit_status (estatus, error))
    goto out;

  rpmostree_bwrap_append_bwrap_argv (bwrap, "--bind", bwrap->rofiles_mnt, "/usr", NULL);

  ret = TRUE;
 out:
  if (!ret && mntpoint_created)
    (void) unlinkat (AT_FDCWD, bwrap->rofiles_mnt, AT_REMOVEDIR);
  return ret;
}