Esempio n. 1
0
int
pkg_repo_verify(const char *path, unsigned char *sig, unsigned int sig_len)
{
	char sha256[SHA256_DIGEST_LENGTH *2 +1];
	char errbuf[1024];
	RSA *rsa = NULL;

	sha256_file(path, sha256);

	SSL_load_error_strings();
	OpenSSL_add_all_algorithms();
	OpenSSL_add_all_ciphers();

	rsa = load_rsa_public_key(pkg_config("PUBKEY"));
	if (rsa == NULL)
		return(EPKG_FATAL);

	if (RSA_verify(NID_sha1, sha256, sizeof(sha256), sig, sig_len, rsa) == 0) {
		pkg_emit_error("%s: %s", pkg_config("PUBKEY"),
					   ERR_error_string(ERR_get_error(), errbuf));
		return (EPKG_FATAL);
	}

	RSA_free(rsa);
	ERR_free_strings();

	return (EPKG_OK);
}
Esempio n. 2
0
static const gchar *
get_runtime_prefix (gchar slash)
{
#ifdef G_OS_WIN32

  /* Don't use the developer package prefix, but deduce the
   * installation-time prefix from where gimp-x.y.exe can be found.
   */

  gchar *path;
  gchar *p, *r;

  path = g_find_program_in_path ("gimp-" GIMP_APP_VERSION ".exe");

  if (path == NULL)
    path = g_find_program_in_path ("gimp.exe");

  if (path != NULL)
    {
      r = strrchr (path, G_DIR_SEPARATOR);
      if (r != NULL)
	{
	  *r = '\0';
	  if (strlen (path) >= 4 &&
	      g_ascii_strcasecmp (r - 4, G_DIR_SEPARATOR_S "bin") == 0)
	    {
	      r[-4] = '\0';
	      prefix = path;
	      if (slash == '/')
		{
		  /* Use forward slashes, less quoting trouble in Makefiles */
		  while ((p = strchr (prefix, '\\')) != NULL)
		    *p = '/';
		}
	      return prefix;
	    }
	}
    }

  g_printerr ("Cannot determine GIMP " GIMP_APP_VERSION " installation location\n");

  exit (EXIT_FAILURE);
#else
  /* On Unix assume the executable package is in the same prefix as the developer stuff */
  return pkg_config ("--variable=prefix gimp-2.0");
#endif
}
Esempio n. 3
0
int
pkg_repo_fetch(struct pkg *pkg)
{
	char dest[MAXPATHLEN + 1];
	char url[MAXPATHLEN + 1];
	int fetched = 0;
	char cksum[SHA256_DIGEST_LENGTH * 2 +1];
	char *path = NULL;
	const char *packagesite = NULL;
	int retcode = EPKG_OK;

	assert((pkg->type & PKG_REMOTE) == PKG_REMOTE);

	if ((packagesite = pkg_config("PACKAGESITE")) == NULL) {
		pkg_emit_error("pkg_repo_fetch(): %s", "PACKAGESITE is not defined");
		return (EPKG_FATAL);
	}

	snprintf(dest, sizeof(dest), "%s/%s", pkg_config("PKG_CACHEDIR"),
			 pkg_get(pkg, PKG_REPOPATH));

	/* If it is already in the local cachedir, dont bother to download it */
	if (access(dest, F_OK) == 0)
		goto checksum;

	/* Create the dirs in cachedir */
	if ((path = dirname(dest)) == NULL) {
		pkg_emit_errno("dirname", dest);
		retcode = EPKG_FATAL;
		goto cleanup;
	}

	if ((retcode = mkdirs(path)) != 0)
		goto cleanup;

	if (packagesite[strlen(packagesite) - 1] == '/')
		snprintf(url, sizeof(url), "%s%s", packagesite,
				pkg_get(pkg, PKG_REPOPATH));
	else
		snprintf(url, sizeof(url), "%s/%s", packagesite,
				pkg_get(pkg, PKG_REPOPATH));

	retcode = pkg_fetch_file(url, dest);
	fetched = 1;

	if (retcode != EPKG_OK)
		goto cleanup;

	checksum:
	retcode = sha256_file(dest, cksum);
	if (retcode == EPKG_OK)
		if (strcmp(cksum, pkg_get(pkg, PKG_CKSUM))) {
			if (fetched == 1) {
				pkg_emit_error("%s-%s failed checksum from repository",
						pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION));
				retcode = EPKG_FATAL;
			} else {
				pkg_emit_error("cached package %s-%s: checksum mismatch, fetching from remote",
						pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION));
				unlink(dest);
				return (pkg_repo_fetch(pkg));
			}
		}

	cleanup:
	if (retcode != EPKG_OK)
		unlink(dest);

	return (retcode);
}
Esempio n. 4
0
static gchar *
get_libs_nogimpui (void)
{
  return pkg_config ("--libs gimp-2.0 gtk+-2.0");
}
Esempio n. 5
0
static gchar *
get_libs (void)
{
  return pkg_config ("--libs gimpui-2.0");
}
Esempio n. 6
0
static gchar *
get_cflags_nogimpui (void)
{
  return pkg_config ("--cflags gimp-2.0 gtk+-2.0");
}
Esempio n. 7
0
static gchar *
get_cflags (void)
{
  return pkg_config ("--cflags gimpui-2.0");
}
Esempio n. 8
0
static gchar *
get_includedir (void)
{
  return pkg_config ("--variable=includedir gimp-2.0");
}
Esempio n. 9
0
File: pkgdb.c Progetto: flz/pkgng
int
pkgdb_open(struct pkgdb **db, pkgdb_t remote, int mode)
{
	int retcode;
	struct stat st;
	char *errmsg;
	char localpath[MAXPATHLEN];
	char remotepath[MAXPATHLEN];
	char sql[BUFSIZ];
	const char *dbdir;

	/* First check to make sure PKG_DBDIR exists before trying to use it */
	dbdir = pkg_config("PKG_DBDIR");
	if (eaccess(dbdir, mode) == -1)
		return (pkg_error_set(EPKG_FATAL, "Package database directory "
		    "%s error: %s", dbdir, strerror(errno)));

	snprintf(localpath, sizeof(localpath), "%s/local.sqlite", dbdir);

	if ((*db = calloc(1, sizeof(struct pkgdb))) == NULL)
		return (pkg_error_set(EPKG_FATAL, "calloc(): %s", strerror(errno)));

	(*db)->remote = remote;

	retcode = stat(localpath, &st);
	if (retcode == -1 && errno != ENOENT)
		return (pkg_error_set(EPKG_FATAL, "can not stat %s: %s", localpath,
							  strerror(errno)));

	if (remote == PKGDB_REMOTE) {
		snprintf(remotepath, sizeof(localpath), "%s/repo.sqlite", dbdir);
		retcode = stat(remotepath, &st);
		if (retcode == -1 && errno != ENOENT)
			return (pkg_error_set(EPKG_FATAL, "can not stat %s: %s", remotepath,
						strerror(errno)));
	}

	if (sqlite3_open(localpath, &(*db)->sqlite) != SQLITE_OK)
		return (ERROR_SQLITE((*db)->sqlite));

	if (remote == PKGDB_REMOTE) {
		sqlite3_snprintf(BUFSIZ, sql, "ATTACH \"%s\" as remote;", remotepath);

		if (sqlite3_exec((*db)->sqlite, sql, NULL, NULL, &errmsg) != SQLITE_OK){
			sqlite3_free(errmsg);
			return ERROR_SQLITE((*db)->sqlite);
		}
	}

	/* If the database is missing we have to initialize it */
	if (retcode == -1)
		if ((retcode = pkgdb_init((*db)->sqlite)) != EPKG_OK)
			return (ERROR_SQLITE((*db)->sqlite));

	sqlite3_create_function((*db)->sqlite, "regexp", 2, SQLITE_ANY, NULL,
							pkgdb_regex_basic, NULL, NULL);
	sqlite3_create_function((*db)->sqlite, "eregexp", 2, SQLITE_ANY, NULL,
							pkgdb_regex_extended, NULL, NULL);
	sqlite3_create_function((*db)->sqlite, "pkglt", 2, SQLITE_ANY, NULL,
			pkgdb_pkglt, NULL, NULL);
	sqlite3_create_function((*db)->sqlite, "pkggt", 2, SQLITE_ANY, NULL,
			pkgdb_pkggt, NULL, NULL);

	/*
	 * allow forign key option which will allow to have clean support for
	 * reinstalling
	 */
	if (sqlite3_exec((*db)->sqlite, "PRAGMA foreign_keys = ON;", NULL, NULL,
		&errmsg) != SQLITE_OK) {
		pkg_error_set(EPKG_FATAL, "sqlite: %s", errmsg);
		sqlite3_free(errmsg);
		return (EPKG_FATAL);
	}

	return (EPKG_OK);
}