Exemplo n.º 1
0
int main(int argc, const char *const *argv) {
  struct dpkg_error err;
  int ret;

  setlocale(LC_NUMERIC, "POSIX");
  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);

  dpkg_set_progname(BACKEND);
  standard_startup();
  myopt(&argv, cmdinfos, printforhelp);

  if (!cipaction) badusage(_("need an action option"));

  if (!compressor_check_params(&compress_params, &err))
    badusage(_("invalid compressor parameters: %s"), err.str);

  unsetenv("GZIP");

  ret = cipaction->action(argv);

  standard_shutdown();

  return ret;
}
Exemplo n.º 2
0
int
main(int argc, const char *const *argv)
{
	int uf;
	const char *badname;
	enum trigdef_updateflags tduf;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	dpkg_set_progname("dpkg-trigger");
	standard_startup();
	myopt(&argv, cmdinfos, printforhelp);

	admindir = dpkg_db_set_dir(admindir);

	setvbuf(stdout, NULL, _IONBF, 0);

	if (f_check) {
		if (*argv)
			badusage(_("--%s takes no arguments"),
			         "check-supported");
		do_check();
	}

	if (!*argv || argv[1])
		badusage(_("takes one argument, the trigger name"));

	badname = parse_awaiter_package();
	if (badname)
		ohshit(_("illegal awaited package name '%.250s': %.250s"),
		       bypackage, badname);

	activate = argv[0];
	badname = trig_name_is_illegal(activate);
	if (badname)
		badusage(_("invalid trigger name `%.250s': %.250s"),
		         activate, badname);

	trigdef_set_methods(&tdm_add);

	tduf = tduf_nolockok;
	if (!f_noact)
		tduf |= tduf_write | tduf_writeifempty;
	uf = trigdef_update_start(tduf);
	if (uf >= 0) {
		trigdef_parse();
		if (!done_trig)
			trigdef_update_printf("%s %s\n", activate, bypackage);
		trigdef_process_done();
	}

	standard_shutdown();

	return 0;
}
Exemplo n.º 3
0
/**
* @brief Initialize dpkg and load packages into memory
*/
void dpkg_setup(struct pkg_array *packages) {
  dpkg_set_progname("osquery");
  push_error_context();

  dpkg_db_set_dir("/var/lib/dpkg/");
  modstatdb_init();
  modstatdb_open(msdbrw_readonly);

  pkg_array_init_from_db(packages);
  pkg_array_sort(packages, pkg_sorter);
}
Exemplo n.º 4
0
static void
test_progname(void)
{
	const char *progname;

	/* Test initially empty progname. */
	progname = dpkg_get_progname();
	/* Handle libtool exectuables. */
	if (strncmp(progname, "lt-", 3) == 0)
		progname += 3;
	test_str(progname, ==, "t-progname");

	/* Test setting a new progname. */
	dpkg_set_progname("newname");
	test_str(dpkg_get_progname(), ==, "newname");

	/* Test setting a new progname with path. */
	dpkg_set_progname("path/newprogname");
	test_str(dpkg_get_progname(), ==, "newprogname");
}