Пример #1
0
int main(int argc, char *argv[])
{
    GError *error = NULL;
    GOptionContext *context;
    GOptionGroup *group_fuse;
    gchar *cryptofs_cfg;
    gchar *cipheralgo, *mdalgo;
    long int fileblocksize;
    long int num_of_salts;

    umask(0);
    g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);

    help_fuse_argv[0] = argv[0];

    context = g_option_context_new ("[FUSE OPTIONS...]");
    g_option_context_set_ignore_unknown_options(context, TRUE);
    g_option_context_add_main_entries (context, entries, NULL);
    group_fuse = g_option_group_new("fuse", "x", SHOW_FUSE_OPTIONS, NULL, NULL);
    g_option_group_add_entries(group_fuse, entries_fuse);
    g_option_group_set_translate_func(group_fuse, help_fuse, NULL, NULL);
    g_option_context_add_group(context, group_fuse);
    g_option_context_parse (context, &argc, &argv, &error);
    g_option_context_free(context);

    if (rootpath == NULL) {
	fprintf(stderr, "No path for encrypted directory specified (see --help)\n");
	exit(1);
    }

    if (!g_path_is_absolute(rootpath)) {
	gchar *oldpath = rootpath;
	gchar *curpath = g_get_current_dir();

	rootpath = g_strconcat(curpath, G_DIR_SEPARATOR_S, rootpath, NULL);
	g_free(curpath);
	g_free(oldpath);
    }

    cryptofs_cfg = g_strconcat(rootpath, G_DIR_SEPARATOR_S, CONFIGFILE, NULL);
    if (!read_config(cryptofs_cfg, &cipheralgo, &mdalgo, &fileblocksize, &num_of_salts)) {
	fprintf(stderr, "Could not read config for encrypted directory\n"
			"Check that %s/" CONFIGFILE " is available and correct\n", rootpath);
	exit(1);
    }
    g_free(cryptofs_cfg);

    fs_init(rootpath, crypto_create_global_ctx_default(cipheralgo, mdalgo, fileblocksize, num_of_salts));

    return fuse_main(argc, argv, fs_get_fuse_operations(), NULL);
}
Пример #2
0
int main (int argc, char **argv)
{
    DBusGConnection *bus;
    DBusGProxy *bus_proxy;
    GError *error = NULL;
    char *obj;
    GMainLoop *mainloop;
    guint request_name_result;
    GIOChannel *chan;

#ifdef SMSS_DEBUG
    g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
#endif
    g_type_init ();

    //dbus_g_object_type_install_info (GSM_SMS_TYPE, &	dbus_glib_gsm_sms_object_info);

    mainloop = g_main_loop_new (NULL, FALSE);

    bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
    if (!bus)
        lose_gerror ("Couldn't connect to system bus", error);

    bus_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.DBus",
        "/", "org.freedesktop.DBus");

    if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error,
        G_TYPE_STRING, "org.freesmartphone.ogsmd",
        G_TYPE_UINT, 0,
        G_TYPE_INVALID,
        G_TYPE_UINT, &request_name_result,
        G_TYPE_INVALID))
        lose_gerror ("Failed to acquire org.freesmartphone.ogsmd", error);

    obj = g_object_new (G_TYPE_STRING, NULL);
    dbus_g_connection_register_g_object (bus, "/org/freesmartphone/GSM/Device", G_OBJECT (obj));

    printf ("service is running/n");
    chan = g_io_channel_unix_new(0);
    g_io_add_watch(chan, G_IO_IN, channel_cb, obj);
    g_main_loop_run (mainloop);

    exit (0);
}
Пример #3
0
static __inline__ void
nmp_mss_running_env_init( void )
{
#ifndef G_THREADS_ENABLED
	nmp_error("<main> CMS compiled without 'G_THREADS_ENABLED' defined!");
	FATAL_ERROR_EXIT;
#endif

	if (getenv("BYPASS_GLIB_MPOOL") != NULL)
    	g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);   
    g_thread_init(NULL);
    g_type_init();

	nmp_sysctl_init();
    nmp_mss_set_timezone((gchar*)nmp_get_sysctl_value(SC_TIMEZONE));
    nmp_mss_log_facility_init();
    nmp_mss_setup_signals();
/*    nmp_mss_open_core_facility(); */
}
Пример #4
0
int
main (int   argc,
      char *argv[])
{
  guint64 block_size = 512, area_size = 1024 * 1024, n_blocks, repeats = 1000000;

  if (argc > 1)
    block_size = parse_memsize (argv[1]);
  else
    {
      usage();
      block_size = 512;
    }
  if (argc > 2)
    area_size = parse_memsize (argv[2]);
  if (argc > 3)
    repeats = parse_memsize (argv[3]);
  if (argc > 4)
    g_slice_set_config (G_SLICE_CONFIG_COLOR_INCREMENT, parse_memsize (argv[4]));

  /* figure number of blocks from block and area size.
   * divide area by 3 because touch_mem() allocates 3 areas
   */
  n_blocks = area_size / 3 / ALIGN (block_size, sizeof (gsize) * 2);

  /* basic sanity checks */
  if (!block_size || !n_blocks || block_size >= area_size)
    {
      g_printerr ("Invalid arguments: block-size=%" G_GUINT64_FORMAT " memory-size=%" G_GUINT64_FORMAT "\n", block_size, area_size);
      usage();
      return 1;
    }

  g_printerr ("Will allocate and touch %" G_GUINT64_FORMAT " blocks of %" G_GUINT64_FORMAT " bytes (= %" G_GUINT64_FORMAT " bytes) %" G_GUINT64_FORMAT " times with color increment: 0x%08" G_GINT64_MODIFIER "x\n",
              n_blocks, block_size, n_blocks * block_size, repeats,
	      (guint64)g_slice_get_config (G_SLICE_CONFIG_COLOR_INCREMENT));

  touch_mem (block_size, n_blocks, repeats);
  
  return 0;
}
Пример #5
0
int main (int argc, char *argv[])
{
	nmp_mds_main_args(argc, argv);

 	if (getenv("BYPASS_GLIB_POOLS") != NULL)
        g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);

    g_thread_init(NULL);
    g_type_init();

	nmp_sysctl_init();
	nmp_mss_set_timezone((gchar*)nmp_get_sysctl_value(SC_TIMEZONE));
	nmp_init_xml_cmd();
	g_scheduler_init(2);	/* todo */
	nmp_scheduler_init();

	nmp_mds_log_facility_init();
	nmp_mds_setup_signals();
	nmp_mds_open_core_facility();
	nmp_mds_server_init();
	nmp_mds_run_server();

	return 0;
}
Пример #6
0
int
main (int   argc,
      char *argv[])
{
  guint seed32, *seedp = NULL;
  gboolean ccounters = FALSE, use_memchunks = FALSE;
  guint n_threads = 1;
  const gchar *mode = "slab allocator + magazine cache", *emode = " ";
  if (argc > 1)
    n_threads = g_ascii_strtoull (argv[1], NULL, 10);
  if (argc > 2)
    {
      guint i, l = strlen (argv[2]);
      for (i = 0; i < l; i++)
        switch (argv[2][i])
          {
          case 'G': /* GLib mode */
            g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, FALSE);
            g_slice_set_config (G_SLICE_CONFIG_BYPASS_MAGAZINES, FALSE);
            mode = "slab allocator + magazine cache";
            break;
          case 'S': /* slab mode */
            g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, FALSE);
            g_slice_set_config (G_SLICE_CONFIG_BYPASS_MAGAZINES, TRUE);
            mode = "slab allocator";
            break;
          case 'M': /* malloc mode */
            g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
            mode = "system malloc";
            break;
          case 'O': /* old memchunks */
            use_memchunks = TRUE;
            mode = "old memchunks";
            break;
          case 'f': /* eager freeing */
            g_slice_set_config (G_SLICE_CONFIG_WORKING_SET_MSECS, 0);
            clean_memchunks = TRUE;
            emode = " with eager freeing";
            break;
          case 'c': /* print contention counters */
            ccounters = TRUE;
            break;
          case '~':
            want_corruption = TRUE; /* force occasional corruption */
            break;
          default:
            usage();
            return 1;
          }
    }
  if (argc > 3)
    prime_size = g_ascii_strtoull (argv[3], NULL, 10);
  if (argc > 4)
    {
      seed32 = g_ascii_strtoull (argv[4], NULL, 10);
      seedp = &seed32;
    }

  if (argc <= 1)
    usage();

  {
    gchar strseed[64] = "<random>";
    GThread **threads;
    guint i;
    
    if (seedp)
      g_snprintf (strseed, 64, "%u", *seedp);
    g_print ("Starting %d threads allocating random blocks <= %u bytes with seed=%s using %s%s\n", n_threads, prime_size, strseed, mode, emode);
  
    threads = g_alloca (sizeof(GThread*) * n_threads);
    if (!use_memchunks)
      for (i = 0; i < n_threads; i++)
        threads[i] = g_thread_create (test_sliced_mem_thread, seedp, TRUE, NULL);
    else
      {
        for (i = 0; i < n_threads; i++)
          threads[i] = g_thread_create (test_memchunk_thread, seedp, TRUE, NULL);
      }
    for (i = 0; i < n_threads; i++)
      g_thread_join (threads[i]);
  
    if (ccounters)
      {
        guint n, n_chunks = g_slice_get_config (G_SLICE_CONFIG_CHUNK_SIZES);
        g_print ("    ChunkSize | MagazineSize | Contention\n");
        for (i = 0; i < n_chunks; i++)
          {
            gint64 *vals = g_slice_get_config_state (G_SLICE_CONFIG_CONTENTION_COUNTER, i, &n);
            g_print ("  %9" G_GINT64_FORMAT "   |  %9" G_GINT64_FORMAT "   |  %9" G_GINT64_FORMAT "\n", vals[0], vals[2], vals[1]);
            g_free (vals);
          }
      }
    else
      g_print ("Done.\n");
    return 0;
  }
}
Пример #7
0
int main (int argc, char* argv[])
{
	static const struct option options[] = {
		{ "action", required_argument, NULL, 'a' },
		{ "device", required_argument, NULL, 'D' },
		{ "user", required_argument, NULL, 'u' },
		{ "debug", no_argument, NULL, 'd' },
		{ "help", no_argument, NULL, 'h' },
		{}
	};
	int action = -1;
	const char *device = NULL;
	bool uid_given = false;
	uid_t uid = 0;
	uid_t uid2 = 0;
	const char* remove_session_id = NULL;
	int rc = 0;

	/* valgrind is more important to us than a slice allocator */
	g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, 1);

	while (1) {
		int option;

		option = getopt_long(argc, argv, "+a:D:u:dh", options, NULL);
		if (option == -1)
			break;

		switch (option) {
		case 'a':
			if (strcmp(optarg, "remove") == 0)
				action = ACTION_REMOVE;
			else
				action = ACTION_ADD;
			break;
		case 'D':
			device = optarg;
			break;
		case 'u':
			uid_given = true;
			uid = strtoul(optarg, NULL, 10);
			break;
		case 'd':
			debug = 1;
			break;
		case 'h':
			printf("Usage: udev-acl --action=ACTION [--device=DEVICEFILE] [--user=UID]\n\n");
			goto out;
		}
	}

	if (action < 0 && device == NULL && !uid_given)
		if (!consolekit_called(argv[optind], &uid, &uid2, &remove_session_id, &action))
			uid_given = true;

	if (action < 0) {
		fprintf(stderr, "missing action\n\n");
		rc = 2;
		goto out;
	}

	if (device != NULL && uid_given) {
		fprintf(stderr, "only one option, --device=DEVICEFILE or --user=UID expected\n\n");
		rc = 3;
		goto out;
	}

	if (uid_given) {
		switch (action) {
		case ACTION_ADD:
			/* Add ACL for given uid to all matching devices. */
			apply_acl_to_devices(uid, 1);
			break;
		case ACTION_REMOVE:
			remove_uid(uid, remove_session_id);
			break;
		case ACTION_CHANGE:
			remove_uid(uid, remove_session_id);
			apply_acl_to_devices(uid2, 1);
			break;
		case ACTION_NONE:
			goto out;
			break;
		default:
			g_assert_not_reached();
			break;
		}
	} else if (device != NULL) {
		/*
		 * Add ACLs for all current session uids to a given device.
		 *
		 * Or remove ACLs for uids which do not have any current local
		 * active session. Remove is not really interesting, because in
		 * most cases the device node is removed anyway.
		 */
		GSList *list;
		GSList *l;

		list = uids_with_local_active_session(NULL);
		for (l = list; l != NULL; l = g_slist_next(l)) {
			uid_t u;

			u = GPOINTER_TO_UINT(l->data);
			if (action == ACTION_ADD || !uid_in_list(list, u))
				set_facl(device, u, action == ACTION_ADD);
		}
		g_slist_free(list);
	} else {
		fprintf(stderr, "--device=DEVICEFILE or --user=UID expected\n\n");
		rc = 3;
	}
out:
	return rc;
}
Пример #8
0
/**
 * @mainpage PCManX GTK+ Documentation
 *
 * @section intro_sec Introduction
 *
 * PCManX is a newly developed GPL'd version of PCMan, a full-featured famous BBS client.
 * It aimed to be an easy-to-use yet full-featured telnet client facilitating BBS browsing with the ability to process double-byte characters.
 * Some handy functions like tabbed-browsing, auto-login and a built-in ANSI editor enabling colored text editing are also provided.
 *
 * - Website
 *   - http://code.google.com/p/pcmanx-gtk2/
 * - Mailing List &amp; Forum
 *   - http://groups.google.com/group/PCManX
 * - Repository
 *   - http://code.google.com/p/pcmanx-gtk2/source/
 *
 */
int main(int argc, char *argv[])
{
	lt_dlinit();
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);

#ifdef USE_DEBUG
	/* glib introduces its own memory management mechanism, which
         * confuses memory debuggers such as valgrind and disable their
         * malloc/free wrapper against the applications.
         *
         * Here, we enforce glib to use malloc instead of original ones
         * for debugging need.
         */
#if !defined(GLIB_VERSION_2_34)
	if (getenv("BYPASS_GLIB_POOLS") != NULL) {
		g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);

	}
#endif
#endif

#if !defined(GLIB_VERSION_2_32)
	if (!g_thread_supported ())
		g_thread_init (NULL);
#endif
	gdk_threads_init();

	/*--- Initialize Gtk+ ---*/
	{
		/* GTK requires a program's argc and argv variables, and
		 * requires that they be valid. Set it up. */
		int fake_argc = 1;
		char *_fake_argv[] = { (char *) "pcmanx", NULL };
		char **fake_argv = _fake_argv;

		gtk_init (&fake_argc, &fake_argv);
	}

	/*--- Initialize Runtime options ---*/
	{
		GError *error = NULL;
		GOptionContext *context;
		context = g_option_context_new ("Runtime options");
		g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
		g_option_context_parse (context, &argc, &argv, &error);
	}

	/*--- prevent GTK+ from catching F10  ---*/
	GtkSettings *gtk_settings;
	gtk_settings = gtk_settings_get_for_screen(gdk_screen_get_default());
	g_object_set(gtk_settings, "gtk-menu-bar-accel", NULL, NULL);

	/*--- Check if multiple-instance is allowed. ---*/
	if (!multiple_instance) {
#ifdef USE_DOCKLET
		/* if we are already running, silently exit */
		if (! detect_get_clipboard())
		{
#ifndef USE_DEBUG
			return 1;
#endif	/* USE_DEBUG */
		}
#endif	/* USE_DOCKLET */
	}

	AppConfig.SetToDefault();
	AppConfig.Load();
	AppConfig.LoadFavorites();
	if (AppConfig.RowsPerPage < 24)
		AppConfig.RowsPerPage = 24;
	if (AppConfig.ColsPerPage < 80)
		AppConfig.ColsPerPage = 80;

	CTelnetCon::Init();
	CTelnetCon::SetSocketTimeout( AppConfig.SocketTimeout );

	CMainFrame* main_frm = new CMainFrame;
	gtk_window_move(GTK_WINDOW(main_frm->m_Widget), AppConfig.MainWndX, AppConfig.MainWndY);
	gtk_window_resize(GTK_WINDOW(main_frm->m_Widget), AppConfig.MainWndW, AppConfig.MainWndH);
	main_frm->Show();
#ifdef USE_DOCKLET
	if( AppConfig.ShowTrayIcon )
		main_frm->ShowTrayIcon();
	else
		main_frm->HideTrayIcon();
#endif

#ifdef USE_NOTIFIER
#ifdef USE_LIBNOTIFY
	if (!notify_is_initted()) {
		notify_init("pcmanx");
	}
#else
	popup_notifier_init(main_frm->GetMainIcon());
	popup_notifier_set_timeout( AppConfig.PopupTimeout );
#endif
#endif

#ifdef USE_SCRIPT
	InitScriptInterface(".");
#endif

	gdk_threads_enter();
	gtk_main ();
	gdk_threads_leave();

#ifdef USE_LIBNOTIFY
	notify_uninit();
#endif
	CTelnetCon::Cleanup();

	AppConfig.SaveFavorites();
	AppConfig.Save();

	lt_dlexit();

	return 0;
}
Пример #9
0
void *cryptofs_init(struct list_head *cfg, struct dir_cache *cache, struct credentials *cred, void **global_ctx)
{
    Ctx *ctx;

    if (!(*global_ctx)) {
	gchar *cryptofs_cfg;
	const char *root;
	const gchar *cipheralgo, *mdalgo;
	long int fileblocksize;
	long int num_of_salts;

        g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);

	root = lu_opt_getchar(cfg, "MOUNT", "root");

	cryptofs_cfg = g_strconcat(root, G_DIR_SEPARATOR_S, CONFIGFILE, NULL);
	if (!read_config(cryptofs_cfg, &cipheralgo, &mdalgo, &fileblocksize, &num_of_salts)) {
	    /* Try old config file */
	    if (lu_opt_loadcfg(cfg, cryptofs_cfg) < 0) {
		printf("cryptofs cfg not found");
	        g_free(cryptofs_cfg);
	        return NULL;
	    }

	    if ((cipheralgo = lu_opt_getchar(cfg, "CRYPTOFS", "cipher")) == NULL) {
    		printf("CRYPTOFS::cipher missing in config file\n");
    	        return NULL;
	    }
	    if ((mdalgo = lu_opt_getchar(cfg, "CRYPTOFS", "md")) == NULL) {
		printf("CRYPTOFS::md missing in config file\n");
	        return NULL;
	    }
	    if (lu_opt_getint(cfg, "CRYPTOFS", "blocksize", &fileblocksize, 0) < 0) {
		printf("CRYPTOFS::blocksize missing in config file\n");
	        return NULL;
	    }
	    if (lu_opt_getint(cfg, "CRYPTOFS", "salts", &num_of_salts, 0) < 0) {
		printf("CRYPTOFS::salts missing in config file\n");
		return NULL;
	    }
	}
        g_free(cryptofs_cfg);

	*global_ctx = crypto_create_global_ctx_default(cipheralgo, mdalgo, fileblocksize, num_of_salts);
	if (*global_ctx == NULL) {
	    TRACE("creating global context failed");
	    return NULL;
	}
    }

    ctx = g_new0(Ctx, 1);
    ctx->cryptoctx = crypto_create_local_ctx(*global_ctx);
    if (ctx->cryptoctx == NULL) {
        TRACE("creating global context failed");
	g_free(ctx);
	return NULL;
    }
    ctx->root = g_strdup(lu_opt_getchar(cfg, "MOUNT", "root"));
    if (ctx->root[strlen(ctx->root) - 1] == '/')
        ctx->root[strlen(ctx->root) - 1] = '\0';
    return ctx;
}