Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Avoid POLA, make PACKAGESITE/MIRROR_TYPE/PUBKEY in pkg.conf fatal
Bryan Drewery committed 11 years ago
commit 2f55baa35e522983c361ea3afd7f97cf0a1d4351
parent ccde3d4
1 file changed +19 -0
modified libpkg/pkg_config.c
@@ -698,6 +698,7 @@ pkg_init(const char *path, const char *reposdir)
	ucl_object_t *obj = NULL, *o, *ncfg;
	ucl_object_iter_t it = NULL;
	struct sbuf *ukey = NULL;
+
	bool fatal_errors = false;

	k = NULL;
	o = NULL;
@@ -804,6 +805,18 @@ pkg_init(const char *path, const char *reposdir)
			sbuf_putc(ukey, toupper(key[i]));
		sbuf_done(ukey);
		object = ucl_object_find_keyl(config, sbuf_data(ukey), sbuf_len(ukey));
+

+
		if (strncasecmp(sbuf_data(ukey), "PACKAGESITE", sbuf_len(ukey))
+
		    == 0 || strncasecmp(sbuf_data(ukey), "PUBKEY",
+
		    sbuf_len(ukey)) == 0 || strncasecmp(sbuf_data(ukey),
+
		    "MIRROR_TYPE", sbuf_len(ukey)) == 0) {
+
			pkg_emit_error("%s in pkg.conf is no longer "
+
			    "supported.  Convert to the new repository style."
+
			    "  See pkg.conf(5)", sbuf_data(ukey));
+
			fatal_errors = true;
+
			continue;
+
		}
+

		/* ignore unknown keys */
		if (object == NULL)
			continue;
@@ -818,6 +831,12 @@ pkg_init(const char *path, const char *reposdir)
		ucl_object_insert_key(ncfg, ucl_object_copy(cur), sbuf_data(ukey), sbuf_len(ukey), true);
	}

+
	if (fatal_errors) {
+
		ucl_object_unref(ncfg);
+
		ucl_parser_free(p);
+
		return (EPKG_FATAL);
+
	}
+

	if (ncfg != NULL) {
		it = NULL;
		while (( cur = ucl_iterate_object(ncfg, &it, true))) {