diff --git a/commandline.c b/commandline.c index 07cde19a..877314f7 100644 --- a/commandline.c +++ b/commandline.c @@ -1362,7 +1362,10 @@ int app_rhizome_add_file(const struct cli_parsed *parsed, struct cli_context *co if ((!journal) && m->journalTail>=0) return WHY("Existing manifest is a journal"); - if (rhizome_fill_manifest(m, filepath, *authorSidHex?&authorSid:NULL, bskhex?&bsk:NULL)){ + if (rhizome_manifest_get(m, "service", NULL, 0) == NULL) + rhizome_manifest_set(m, "service", RHIZOME_SERVICE_FILE); + + if (rhizome_fill_manifest(m, filepath, *authorSidHex ? &authorSid : NULL, bskhex ? &bsk : NULL)){ rhizome_manifest_free(m); return -1; } diff --git a/meshms.c b/meshms.c index 87a25073..6b5f1d8f 100644 --- a/meshms.c +++ b/meshms.c @@ -83,9 +83,15 @@ static int get_my_conversation_bundle(const sid_t *my_sidp, rhizome_manifest *m) return -1; // always consider the content encrypted, we don't need to rely on the manifest itself. - m->payloadEncryption=1; - if (m->haveSecret==NEW_BUNDLE_ID){ - rhizome_fill_manifest(m, NULL, NULL, NULL); + m->payloadEncryption = 1; + if (m->haveSecret == NEW_BUNDLE_ID) { + rhizome_manifest_set(m, "service", RHIZOME_SERVICE_FILE); + if (rhizome_fill_manifest(m, NULL, NULL, NULL) == -1) + return WHY("Invalid manifest"); + } else { + const char *service = rhizome_manifest_get(m, "service", NULL, 0); + if (strcmp(service, RHIZOME_SERVICE_FILE) != 0) + return WHYF("Invalid manifest, service=%s but should be %s", service, RHIZOME_SERVICE_MESHMS2); } return 0; } diff --git a/rhizome_bundle.c b/rhizome_bundle.c index c942e971..3eedbab3 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -725,13 +725,10 @@ int rhizome_fill_manifest(rhizome_manifest *m, const char *filepath, const sid_t - if service is file, then use the payload file's basename for "name" */ const char *service = rhizome_manifest_get(m, "service", NULL, 0); - if (service == NULL) { - rhizome_manifest_set(m, "service", (service = RHIZOME_SERVICE_FILE)); - if (config.debug.rhizome) DEBUGF("missing 'service', set default service=%s", service); - } else { - if (config.debug.rhizome) DEBUGF("manifest contains service=%s", service); - } - + if (service == NULL) + return WHYF("missing 'service'"); + if (config.debug.rhizome) + DEBUGF("manifest service=%s", service); if (rhizome_manifest_get(m, "date", NULL, 0) == NULL) { rhizome_manifest_set_ll(m, "date", (int64_t) gettime_ms()); if (config.debug.rhizome) DEBUGF("missing 'date', set default date=%s", rhizome_manifest_get(m, "date", NULL, 0)); diff --git a/rhizome_direct_http.c b/rhizome_direct_http.c index c44ea7fb..72229568 100644 --- a/rhizome_direct_http.c +++ b/rhizome_direct_http.c @@ -227,7 +227,7 @@ int rhizome_direct_form_received(rhizome_http_request *r) if (rhizome_read_manifest_file(m, manifestTemplate, 0) == -1) { rhizome_manifest_free(m); rhizome_direct_clear_temporary_files(r); - return rhizome_server_simple_http_response(r,500,"rhizome.api.addfile.manifesttemplate can't be read as a manifest."); + return rhizome_server_simple_http_response(r,500,"rhizome.api.addfile.manifest_template_file can't be read as a manifest."); } if (rhizome_stat_file(m, filepath)){ @@ -235,14 +235,17 @@ int rhizome_direct_form_received(rhizome_http_request *r) rhizome_direct_clear_temporary_files(r); return rhizome_server_simple_http_response(r,500,"Could not store file"); } - + + if (rhizome_manifest_get(m, "service", NULL, 0) == NULL) + rhizome_manifest_set(m, "service", RHIZOME_SERVICE_FILE); + sid_t *author=NULL; if (!is_sid_t_any(config.rhizome.api.addfile.default_author)) author = &config.rhizome.api.addfile.default_author; rhizome_bk_t bsk; memcpy(bsk.binary, config.rhizome.api.addfile.bundle_secret_key.binary, RHIZOME_BUNDLE_KEY_BYTES); - + if (rhizome_fill_manifest(m, r->data_file_name, author, &bsk)){ rhizome_manifest_free(m); m = NULL;