Download raw body.
make gotd reject sha2 repos earlier
Gotd currently errors when a sha2 repository is found while
handling a client request.
It would be better to error out at startup if a sha2 repostiory is
present in the configuration file so that the admin becomes aware
of the problem when the service fails to start up.
ok?
-----------------------------------------------
make gotd(8) reject sha256 repositories at startup for now
M gotd/gotd.c | 21+ 0-
M lib/read_gitconfig.c | 15+ 22-
M regress/gotd/prepare_test_repo.sh | 1+ 1-
3 files changed, 37 insertions(+), 23 deletions(-)
diff 11f34534de34dc3b24c47b54c86b1fd8aaf8699d ac686c0b234848c2daf18708ae84dd3c7c81eee1
commit - 11f34534de34dc3b24c47b54c86b1fd8aaf8699d
commit + ac686c0b234848c2daf18708ae84dd3c7c81eee1
blob - e087575f78236937985aeb124917d2ff9962a9de
blob + 5187b871340d649b17625e640cde2a36647502a4
--- gotd/gotd.c
+++ gotd/gotd.c
@@ -2093,6 +2093,27 @@ main(int argc, char **argv)
if (pw->pw_uid == 0)
fatalx("cannot run %s as the superuser", getprogname());
+ /*
+ * SHA2 repositories cannot be used with gotd until Git protocol v2
+ * support is added. Reject them at startup for now.
+ */
+ TAILQ_FOREACH(repo, &gotd.repos, entry) {
+ struct got_repository *r;
+
+ error = got_repo_open(&r, repo->path, NULL, NULL);
+ if (error)
+ fatalx("%s: %s", repo->path, error->msg);
+
+ if (got_repo_get_object_format(r) != GOT_HASH_SHA1) {
+ error = got_error_msg(GOT_ERR_NOT_IMPL,
+ "sha256 object IDs unsupported in network "
+ "protocol");
+ fatalx("%s: %s", repo->path, error->msg);
+ }
+
+ got_repo_close(r);
+ }
+
if (noaction) {
fprintf(stderr, "configuration OK\n");
return 0;
blob - 10b2b156100b2de5d6fa3f09483b5ac4658b3074
blob + 9f370db70d268838b93dbe6d96b498def97df472
--- lib/read_gitconfig.c
+++ lib/read_gitconfig.c
@@ -111,13 +111,8 @@ got_repo_read_gitconfig(int *gitconfig_repository_form
tags = got_gitconfig_get_tag_list(gitconfig, "extensions");
if (extnames && extvals && nextensions && tags) {
size_t numext = 0;
- TAILQ_FOREACH(node, &tags->fields, link) {
- char *ext = node->field;
- char *val = got_gitconfig_get_str(gitconfig,
- "extensions", ext);
- if (get_boolean_val(val))
- numext++;
- }
+ TAILQ_FOREACH(node, &tags->fields, link)
+ numext++;
*extnames = calloc(numext, sizeof(char *));
if (*extnames == NULL) {
err = got_error_from_errno("calloc");
@@ -132,23 +127,21 @@ got_repo_read_gitconfig(int *gitconfig_repository_form
char *ext = node->field;
char *val = got_gitconfig_get_str(gitconfig,
"extensions", ext);
- if (get_boolean_val(val)) {
- char *extstr = NULL, *valstr = NULL;
+ char *extstr = NULL, *valstr = NULL;
- extstr = strdup(ext);
- if (extstr == NULL) {
- err = got_error_from_errno("strdup");
- goto done;
- }
- valstr = strdup(val);
- if (valstr == NULL) {
- err = got_error_from_errno("strdup");
- goto done;
- }
- (*extnames)[(*nextensions)] = extstr;
- (*extvals)[(*nextensions)] = valstr;
- (*nextensions)++;
+ extstr = strdup(ext);
+ if (extstr == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
}
+ valstr = strdup(val);
+ if (valstr == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
+ }
+ (*extnames)[(*nextensions)] = extstr;
+ (*extvals)[(*nextensions)] = valstr;
+ (*nextensions)++;
}
}
blob - 8e364cdc52ed8662ae2562398c885d5a21c3061b
blob + 688ca609f943549450332e25c6e5531c66a3b239
--- regress/gotd/prepare_test_repo.sh
+++ regress/gotd/prepare_test_repo.sh
@@ -21,7 +21,7 @@ make_repo()
local repo_path="$1"
local no_tree="$2"
- gotadmin init "${repo_path}"
+ gotadmin init -A "$GOT_TEST_ALGO" "${repo_path}"
if [ -n "$no_tree" ]; then
return
make gotd reject sha2 repos earlier