Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Error checking for the RSA key argument for 'pkg repo'. Also, don't require it to create the repo.
Will Andrews committed 14 years ago
commit e679293e12440ebc92f06923474aa38f4af27e27
parent 047a0b3
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);
}