Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Error checking for the RSA key argument for 'pkg repo'. Also, don't require it to create the repo.
Will Andrews committed 15 years ago
commit cda9b809cdb575975a88378426408c1be3b1289b
parent 9053b85357d5cd64b56a947308bcaf3ae3be815f
2 files changed +7 -4
modified libpkg/pkg_create_repo.c
@@ -262,6 +262,9 @@ pkg_finish_repo(char *path, pem_password_cb *password_cb, char *rsa_key_path)

	packing_init(&pack, repo_archive, TXZ);
	if (rsa_key_path != NULL) {
+
		if (access(rsa_key_path, R_OK) == -1)
+
			return pkg_error_set(EPKG_FATAL, "RSA key invalid: %s", strerror(errno));
+

		SSL_load_error_strings();

		OpenSSL_add_all_algorithms();
modified pkg/repo.c
@@ -64,11 +64,10 @@ int
exec_repo(int argc, char **argv)
{
	int ret;
-

	int pos = 0;
+
	char *rsa_key;

-

-
	if (argc != 3 ) {
+
	if (argc < 2 || argc > 3) {
		usage_repo();
		return (EX_USAGE);
	}
@@ -81,7 +80,8 @@ exec_repo(int argc, char **argv)
	else
		printf("\bDone!\n");

-
	pkg_finish_repo(argv[1], password_cb, argv[2]);
+
	rsa_key = (argc == 3) ? argv[2] : NULL;
+
	pkg_finish_repo(argv[1], password_cb, rsa_key);

	return (ret);
}