pkgng

Check-in [66a40f56c3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Introduce a new "fingerprint" type of signature Discussed with: jonathan, des, gavin (@BSDCam)
Timelines: family | ancestors | descendants | both | trunk | multi-repos | stash
Files: files | file ages | folders
SHA1: 66a40f56c37b40c2780c23640e505b22ed5f7d1e
User & Date: bapt@FreeBSD.org 2013-09-10 12:07:23
Context
2013-09-10
15:54
Add a function to compute a sha256 hash out of a buffer check-in: 7e601dec67 user: bapt@FreeBSD.org tags: trunk, multi-repos, stash
12:07
Introduce a new "fingerprint" type of signature Discussed with: jonathan, des, gavin (@BSDCam) check-in: 66a40f56c3 user: bapt@FreeBSD.org tags: trunk, multi-repos, stash
10:12
Deprecate packagesite check-in: 1989d8ba2c user: bapt@FreeBSD.org tags: trunk, multi-repos, stash
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to libpkg/pkg.h.in.

274
275
276
277
278
279
280






281
282
283
284
285
286
287
....
1392
1393
1394
1395
1396
1397
1398


1399
1400
1401
1402
1403
1404
1405

typedef enum {
	SRV,
	HTTP,
	NOMIRROR,
} mirror_t;







/**
 * Determine the type of a pkg_script.
 */
typedef enum {
	PKG_SCRIPT_PRE_INSTALL = 0,
	PKG_SCRIPT_POST_INSTALL,
	PKG_SCRIPT_PRE_DEINSTALL,
................................................................................
int pkg_repos_count(void);
int pkg_repos(struct pkg_repo **);
const char *pkg_repo_url(struct pkg_repo *r);
const char *pkg_repo_ident(struct pkg_repo *r);
const char *pkg_repo_name(struct pkg_repo *r);
const char * pkg_repo_ident_from_name(const char *repo_name);
const char *pkg_repo_key(struct pkg_repo *r);


bool pkg_repo_enabled(struct pkg_repo *r);
mirror_t pkg_repo_mirror_type(struct pkg_repo *r);
struct pkg_repo *pkg_repo_find_ident(const char *ident);
struct pkg_repo *pkg_repo_find_name(const char *name);

/**
 * pkg_printf() and friends.  These parallel the similarly named libc







>
>
>
>
>
>







 







>
>







274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
....
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413

typedef enum {
	SRV,
	HTTP,
	NOMIRROR,
} mirror_t;

typedef enum {
	SIG_PUBKEY,
	SIG_FINGERPRINT,
	SIG_NONE
} signature_t;

/**
 * Determine the type of a pkg_script.
 */
typedef enum {
	PKG_SCRIPT_PRE_INSTALL = 0,
	PKG_SCRIPT_POST_INSTALL,
	PKG_SCRIPT_PRE_DEINSTALL,
................................................................................
int pkg_repos_count(void);
int pkg_repos(struct pkg_repo **);
const char *pkg_repo_url(struct pkg_repo *r);
const char *pkg_repo_ident(struct pkg_repo *r);
const char *pkg_repo_name(struct pkg_repo *r);
const char * pkg_repo_ident_from_name(const char *repo_name);
const char *pkg_repo_key(struct pkg_repo *r);
const char *pkg_repo_fingerprints(struct pkg_repo *r);
signature_t pkg_repo_signature_type(struct pkg_repo *r);
bool pkg_repo_enabled(struct pkg_repo *r);
mirror_t pkg_repo_mirror_type(struct pkg_repo *r);
struct pkg_repo *pkg_repo_find_ident(const char *ident);
struct pkg_repo *pkg_repo_find_name(const char *name);

/**
 * pkg_printf() and friends.  These parallel the similarly named libc

Changes to libpkg/pkg_config.c.

734
735
736
737
738
739
740

741
742
743
744
745
746
747
...
758
759
760
761
762
763
764




765
766
767
768
769
770
771
772
773
774
775
776

777
778
779
780
781
782
783
784










785
786
787
788





789
790
791
792
793
794
795
....
1278
1279
1280
1281
1282
1283
1284












1285
1286
1287
1288
1289
1290
1291
}

static void
add_repo(yaml_document_t *doc, yaml_node_t *repo, yaml_node_t *node, struct pkg_repo *r)
{
	yaml_node_pair_t *pair;
	yaml_char_t *url = NULL, *pubkey = NULL, *enable = NULL, *mirror_type = NULL;


	pair = node->data.mapping.pairs.start;
	while (pair < node->data.mapping.pairs.top) {
		yaml_node_t *key = yaml_document_get_node(doc, pair->key);
		yaml_node_t *val = yaml_document_get_node(doc, pair->value);

		if (key->data.scalar.length <= 0) {
................................................................................
			url = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "pubkey") == 0)
			pubkey = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "enabled") == 0)
			enable = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "mirror_type") == 0)
			mirror_type = val->data.scalar.value;





		++pair;
		continue;
	}

	if (r == NULL && url == NULL)
		return;

	if (r == NULL) {
		r = calloc(1, sizeof(struct pkg_repo));
		r->enable = true;
		r->mirror_type = NOMIRROR;

		asprintf(&r->name, REPO_NAME_PREFIX"%s", repo->data.scalar.value);
		HASH_ADD_KEYPTR(hh, repos, r->name, strlen(r->name), r);
	}

	if (url != NULL) {
		free(r->url);
		r->url = subst_packagesite_str(url);
	}










	if (pubkey != NULL) {
		free(r->pubkey);
		r->pubkey = strdup(pubkey);
	}






	if (enable != NULL &&
	    (strcasecmp(enable, "off") == 0 ||
	     strcasecmp(enable, "no") == 0 ||
	     strcasecmp(enable, "false") == 0 ||
	     enable[0] == '0')) {
		r->enable = false;
................................................................................
}

const char *
pkg_repo_key(struct pkg_repo *r)
{
	return (r->pubkey);
}













bool
pkg_repo_enabled(struct pkg_repo *r)
{
	return (r->enable);
}








>







 







>
>
>
>












>








>
>
>
>
>
>
>
>
>
>




>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>







734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
...
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
....
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
}

static void
add_repo(yaml_document_t *doc, yaml_node_t *repo, yaml_node_t *node, struct pkg_repo *r)
{
	yaml_node_pair_t *pair;
	yaml_char_t *url = NULL, *pubkey = NULL, *enable = NULL, *mirror_type = NULL;
	yaml_char_t *signature_type = NULL, *fingerprints = NULL;

	pair = node->data.mapping.pairs.start;
	while (pair < node->data.mapping.pairs.top) {
		yaml_node_t *key = yaml_document_get_node(doc, pair->key);
		yaml_node_t *val = yaml_document_get_node(doc, pair->value);

		if (key->data.scalar.length <= 0) {
................................................................................
			url = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "pubkey") == 0)
			pubkey = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "enabled") == 0)
			enable = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "mirror_type") == 0)
			mirror_type = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "signature") == 0)
			signature_type = val->data.scalar.value;
		else if (strcasecmp(key->data.scalar.value, "fingerprints") == 0)
			fingerprints = val->data.scalar.value;

		++pair;
		continue;
	}

	if (r == NULL && url == NULL)
		return;

	if (r == NULL) {
		r = calloc(1, sizeof(struct pkg_repo));
		r->enable = true;
		r->mirror_type = NOMIRROR;
		r->signature_type = SIG_NONE;
		asprintf(&r->name, REPO_NAME_PREFIX"%s", repo->data.scalar.value);
		HASH_ADD_KEYPTR(hh, repos, r->name, strlen(r->name), r);
	}

	if (url != NULL) {
		free(r->url);
		r->url = subst_packagesite_str(url);
	}

	if (signature_type != NULL) {
		if (strcasecmp(signature_type, "pubkey") == 0)
			r->signature_type = SIG_PUBKEY;
		else if (strcasecmp(signature_type, "fingerprints") == 0)
			r->signature_type = SIG_FINGERPRINT;
		else
			r->signature_type = SIG_NONE;
	}

	if (pubkey != NULL) {
		free(r->pubkey);
		r->pubkey = strdup(pubkey);
	}

	if (fingerprints != NULL) {
		free(r->fingerprints);
		r->fingerprints = strdup(fingerprints);
	}

	if (enable != NULL &&
	    (strcasecmp(enable, "off") == 0 ||
	     strcasecmp(enable, "no") == 0 ||
	     strcasecmp(enable, "false") == 0 ||
	     enable[0] == '0')) {
		r->enable = false;
................................................................................
}

const char *
pkg_repo_key(struct pkg_repo *r)
{
	return (r->pubkey);
}

const char *
pkg_repo_fingerprints(struct pkg_repo *r)
{
	return (r->fingerprints);
}

signature_t
pkg_repo_signature_type(struct pkg_repo *r)
{
	return (r->signature_type);
}

bool
pkg_repo_enabled(struct pkg_repo *r)
{
	return (r->enable);
}

Changes to libpkg/private/pkg.h.

262
263
264
265
266
267
268


269
270
271
272
273
274
275
	char *url;
	char *pubkey;
	mirror_t mirror_type;
	union {
		struct dns_srvinfo *srv;
		struct http_mirror *http;
	};


	FILE *ssh;
	bool enable;
	UT_hash_handle hh;
};

/* sql helpers */








>
>







262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
	char *url;
	char *pubkey;
	mirror_t mirror_type;
	union {
		struct dns_srvinfo *srv;
		struct http_mirror *http;
	};
	signature_t signature_type;
	char *fingerprints;
	FILE *ssh;
	bool enable;
	UT_hash_handle hh;
};

/* sql helpers */

Changes to pkg/main.c.

403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422














423
424
425
426
427
428

429
430
431

432
433


434
435
436
437
438
439
440
441
442
		}
	}
}

static void
show_repository_info(void)
{
	const char	*buf;
	struct pkg_repo	*repo = NULL;

	printf("\nRepositories:\n");
	while (pkg_repos(&repo) == EPKG_OK) {
		switch (pkg_repo_mirror_type(repo)) {
		case SRV:
			buf = "SRV";
			break;
		case HTTP:
			buf = "HTTP";
			break;
		case NOMIRROR:














			buf = "NONE";
			break;
		default:
			buf = "-unknown-";
			break;
		}

		printf("  %s:\n%16s: %s\n%16s: %s\n%16s: %s\n%16s: %s\n",
		    pkg_repo_ident(repo),
                    "url", pkg_repo_url(repo),

		    "key", pkg_repo_key(repo) == NULL ?
		       "" : pkg_repo_key(repo),


		    "enabled", pkg_repo_enabled(repo) ? "yes" : "no",
		    "mirror_type", buf);
	}
}

static void
show_version_info(int version)
{
	if (version > 1)







|






|


|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
|


|


>
|


>
|
|
>
>

|







403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
		}
	}
}

static void
show_repository_info(void)
{
	const char	*mirror, *sig;
	struct pkg_repo	*repo = NULL;

	printf("\nRepositories:\n");
	while (pkg_repos(&repo) == EPKG_OK) {
		switch (pkg_repo_mirror_type(repo)) {
		case SRV:
			mirror = "SRV";
			break;
		case HTTP:
			mirror = "HTTP";
			break;
		case NOMIRROR:
			mirror = "NONE";
			break;
		default:
			mirror = "-unknown-";
			break;
		}
		switch (pkg_repo_signature_type(repo)) {
		case SIG_PUBKEY:
			sig = "PUBKEY";
			break;
		case SIG_FINGERPRINT:
			sig = "FINGERPRINTS";
			break;
		case SIG_NONE:
			sig = "NONE";
			break;
		default:
			sig = "-unknown-";
			break;
		}

		printf("  %s:\n%16s: %s\n%16s: %s\n%16s: %s\n%16s: %s\n%16s: %s\n%16s: %s\n",
		    pkg_repo_ident(repo),
                    "url", pkg_repo_url(repo),
		    "signature", sig,
		    "pubkey", pkg_repo_key(repo) == NULL ?
		        "" : pkg_repo_key(repo),
		    "fingerprints", pkg_repo_fingerprints(repo) == NULL ?
		        "" : pkg_repo_fingerprints(repo),
		    "enabled", pkg_repo_enabled(repo) ? "yes" : "no",
		    "mirror_type", mirror);
	}
}

static void
show_version_info(int version)
{
	if (version > 1)