Exemple #1
0
int main(int argc, char **argv)
{
  TestSharedState *shared_state = g_new0(TestSharedState, 1);
  const gchar *display = g_getenv("DISPLAY");

  if (!display || *display == '\0')
    {
      g_print("No DISPLAY found. Unable to run the test suite without X11.");
      return EXIT_SUCCESS;
    }

  g_test_init(&argc, &argv, NULL);

  SeedEngine *eng = seed_init(NULL, NULL);

  shared_state->argc_addr = &argc;
  shared_state->argv_addr = &argv;
  shared_state->eng = eng;

  TEST_SIMPLE("/", basic);
  TEST_SIMPLE("/", closures);
  TEST_SIMPLE("/types/", basic_types);
  TEST_SIMPLE("/js-signal-from-c/", js_signal_from_c);

  return g_test_run();
}
Exemple #2
0
int random_int() {
	static int left = 0;
	if (left <= 0) {
		seed_init();
		left = rand() % 20 + 2;
	}
	left -= 1;
	return rand();
}
static void
peas_plugin_loader_seed_init (PeasPluginLoaderSeed *sloader)
{
  /* This is somewhat buggy as the seed engine cannot be reinitialized
   * and is shared among instances (esp wrt module paths), but apparently there
   * is no way to avoid having it shared... */
  if (!seed)
    seed = seed_init (NULL, NULL);

  sloader->loaded_plugins = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                                   NULL,
                                                   (GDestroyNotify) destroy_seed_info);
}
static void
peas_plugin_loader_seed_init (PeasPluginLoaderSeed *sloader)
{
  /* This is somewhat buggy as the seed engine cannot be reinitialized
   * and is shared among instances (esp wrt module paths), but apparently there
   * is no way to avoid having it shared... */
  if (!seed)
    {
      seed = seed_init (NULL, NULL);

      /* Reverse the log handle Seed uses.
       * The one place that Seed uses this shouldn't make a
       * difference.
       */
      g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_WARNING,
                         g_log_default_handler, 0);
    }

  sloader->loaded_plugins = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                                   NULL,
                                                   (GDestroyNotify) destroy_seed_info);
}
Exemple #5
0
int main(int argc, const char **argv)
{
    struct seed_ctx *sctx = NULL;
    struct user_ctx *input_uctx = NULL;
    int ret = EOK;

    /* initialize seed context and parse options */
    ret = seed_init(sctx, argc, argv, &sctx);
    if (ret != EOK) {
        DEBUG(SSSDBG_OP_FAILURE,("Seed init failed [%d][%s]\n",
                                 ret, strerror(ret)));
        goto done;
    }

    /* set up confdb,sysdb and domain */
    ret = seed_init_db(sctx, sctx->uctx->domain_name, &sctx->confdb,
                       &sctx->domain, &sctx->sysdb);
    if (ret != EOK) {
        DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to initialize db and domain\n"));
        goto done;
    }

    /* get user info from domain */
    ret = seed_domain_user_info(sctx->uctx->name, sctx->uctx->domain_name,
                                sctx->sysdb, sctx->domain, &sctx->user_cached);
    if (ret != EOK) {
        DEBUG(SSSDBG_OP_FAILURE, ("Failed lookup of user [%s] in domain [%s]\n",
                                  sctx->uctx->name, sctx->uctx->domain_name));
    }

    /* interactive mode to fill in user information */
    if (sctx->interact == true) {
        if (sctx->user_cached == true) {
            ERROR(_("User entry already exists in the cache.\n"));
            ret = EEXIST;
            goto done;
        } else {
            ret = seed_interactive_input(sctx, sctx->uctx, &input_uctx);
            if (ret != EOK) {
                DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to get seed input.\n"));
                ret = EINVAL;
                goto done;
            }
            talloc_zfree(sctx->uctx);
            sctx->uctx = input_uctx;
        }
    }

    if (sctx->user_cached == false) {
        if (sctx->uctx->uid == 0 || sctx->uctx->gid == 0) {
            /* require username, UID, and GID to continue */
            DEBUG(SSSDBG_MINOR_FAILURE, ("Not enough information provided\n"));
            ERROR("UID and primary GID not provided.\n");
            ret = EINVAL;
            goto done;
        }
    }

    /* password input */
    if (sctx->password_method == PASS_FILE) {
        ret = seed_password_input_file(sctx->uctx, sctx->password_file,
                                       &sctx->uctx->password);
        if (ret != EOK) {
            DEBUG(SSSDBG_CRIT_FAILURE, ("Password input failure\n"));
            goto done;
        }
    } else {
        ret = seed_password_input_prompt(sctx->uctx, &sctx->uctx->password);
        if (ret != EOK) {
            DEBUG(SSSDBG_CRIT_FAILURE, ("Password input failure\n"));
            goto done;
        }
    }

    /* Add user info and password to sysdb cache */
    ret = seed_cache_user(sctx);
    if (ret != EOK) {
        DEBUG(SSSDBG_MINOR_FAILURE, ("Failed to modify cache.\n"));
        goto done;
    } else {
        if (sctx->user_cached == false) {
            printf(_("User cache entry created for %1$s\n"), sctx->uctx->name);
        }
        printf(_("Temporary password added to cache entry for %1$s\n"),
                 sctx->uctx->name);
    }

done:
    talloc_zfree(sctx);
    if (ret != EOK) {
        DEBUG(SSSDBG_TRACE_INTERNAL, ("Exit error: [%d] [%s]\n",
                                      ret, strerror(ret)));
        ret = EXIT_FAILURE;
    } else {
        ret = EXIT_SUCCESS;
    }
    exit(ret);
}