mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 10:46:23 +00:00
Issue #17, fix new 'rhizomeops' test
Was incorrectly supplying bundle secret to "rhizome add" command.
This commit is contained in:
parent
b7201a75b2
commit
eff3e9ec8f
@ -1035,16 +1035,18 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
|
|||||||
/* Bind an ID to the manifest, and also bind the file. Then finalise the manifest.
|
/* Bind an ID to the manifest, and also bind the file. Then finalise the manifest.
|
||||||
But if the manifest already contains an ID, don't override it. */
|
But if the manifest already contains an ID, don't override it. */
|
||||||
if (authorSidHex[0]) {
|
if (authorSidHex[0]) {
|
||||||
if (debug & DEBUG_RHIZOME)
|
if (debug & DEBUG_RHIZOME) DEBUGF("author=%s", authorSidHex);
|
||||||
DEBUGF("author=%s", authorSidHex);
|
|
||||||
memcpy(m->author, authorSid, SID_SIZE);
|
memcpy(m->author, authorSid, SID_SIZE);
|
||||||
}
|
}
|
||||||
if (rhizome_manifest_get(m, "id", NULL, 0) == NULL) {
|
const char *id = rhizome_manifest_get(m, "id", NULL, 0);
|
||||||
|
if (id == NULL) {
|
||||||
|
if (debug & DEBUG_RHIZOME) DEBUG("creating new bundle");
|
||||||
if (rhizome_manifest_bind_id(m) == -1) {
|
if (rhizome_manifest_bind_id(m) == -1) {
|
||||||
rhizome_manifest_free(m);
|
rhizome_manifest_free(m);
|
||||||
return WHY("Could not bind manifest to an ID");
|
return WHY("Could not bind manifest to an ID");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (debug & DEBUG_RHIZOME) DEBUGF("modifying existing bundle bid=%s", id);
|
||||||
// Modifying an existing bundle. If an author SID is supplied, we must ensure that it is valid,
|
// Modifying an existing bundle. If an author SID is supplied, we must ensure that it is valid,
|
||||||
// ie, that identity has permission to alter the bundle. If no author SID is supplied but a BSK
|
// ie, that identity has permission to alter the bundle. If no author SID is supplied but a BSK
|
||||||
// is supplied, then use that to alter the bundle. Otherwise, search the keyring for an
|
// is supplied, then use that to alter the bundle. Otherwise, search the keyring for an
|
||||||
@ -1079,6 +1081,7 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bskhex[0]) {
|
if (bskhex[0]) {
|
||||||
|
if (debug & DEBUG_RHIZOME) DEBUGF("bskhex=%s", bskhex);
|
||||||
if (m->haveSecret) {
|
if (m->haveSecret) {
|
||||||
// If a bundle secret key was supplied that does not match the secret key derived from the
|
// If a bundle secret key was supplied that does not match the secret key derived from the
|
||||||
// author, then warn but carry on using the author's.
|
// author, then warn but carry on using the author's.
|
||||||
@ -1096,6 +1099,7 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
|
|||||||
}
|
}
|
||||||
// If we still don't know the bundle secret or the author, then search for an author.
|
// If we still don't know the bundle secret or the author, then search for an author.
|
||||||
if (!m->haveSecret && is_sid_any(m->author)) {
|
if (!m->haveSecret && is_sid_any(m->author)) {
|
||||||
|
if (debug & DEBUG_RHIZOME) DEBUG("bundle author not specified, searching keyring");
|
||||||
int result = rhizome_find_bundle_author(m);
|
int result = rhizome_find_bundle_author(m);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
rhizome_manifest_free(m);
|
rhizome_manifest_free(m);
|
||||||
|
@ -137,8 +137,10 @@ int rhizome_extract_privatekey(rhizome_manifest *m)
|
|||||||
{
|
{
|
||||||
IN();
|
IN();
|
||||||
char *bk = rhizome_manifest_get(m, "BK", NULL, 0);
|
char *bk = rhizome_manifest_get(m, "BK", NULL, 0);
|
||||||
if (!bk)
|
if (!bk) {
|
||||||
|
if (debug & DEBUG_RHIZOME) DEBUG("bundle contains no BK field");
|
||||||
RETURN(1);
|
RETURN(1);
|
||||||
|
}
|
||||||
unsigned char bkBytes[RHIZOME_BUNDLE_KEY_BYTES];
|
unsigned char bkBytes[RHIZOME_BUNDLE_KEY_BYTES];
|
||||||
if (fromhexstr(bkBytes, bk, RHIZOME_BUNDLE_KEY_BYTES) == -1)
|
if (fromhexstr(bkBytes, bk, RHIZOME_BUNDLE_KEY_BYTES) == -1)
|
||||||
RETURN(WHYF("invalid BK field: %s", bk));
|
RETURN(WHYF("invalid BK field: %s", bk));
|
||||||
@ -150,12 +152,12 @@ int rhizome_extract_privatekey(rhizome_manifest *m)
|
|||||||
if (verified == -1)
|
if (verified == -1)
|
||||||
result = WHY("rhizome_bk_xor() failed");
|
result = WHY("rhizome_bk_xor() failed");
|
||||||
else {
|
else {
|
||||||
if (debug & DEBUG_RHIZOME)
|
if (debug & DEBUG_RHIZOME) DEBUGF("identity sid=%s is not the author of bundle with BK=%s", alloca_tohex_sid(m->author), bk);
|
||||||
DEBUGF("identity sid=%s is not the author of bundle with BK=%s", alloca_tohex_sid(m->author), bk);
|
|
||||||
result = 3;
|
result = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(m->cryptoSignSecret, 0, sizeof m->cryptoSignSecret);
|
memset(m->cryptoSignSecret, 0, sizeof m->cryptoSignSecret);
|
||||||
|
if (debug & DEBUG_RHIZOME) DEBUGF("result=%d", result);
|
||||||
RETURN(result);
|
RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ setup_AddUpdateDiscoverAuthor() {
|
|||||||
}
|
}
|
||||||
test_AddUpdateDiscoverAuthor() {
|
test_AddUpdateDiscoverAuthor() {
|
||||||
tfw_cat -v file1_2.manifest
|
tfw_cat -v file1_2.manifest
|
||||||
executeOk_servald rhizome add file '' '' file1_2 file1_2.manifest "$file1_secret"
|
executeOk_servald rhizome add file '' '' file1_2 file1_2.manifest
|
||||||
tfw_cat --stderr
|
tfw_cat --stderr
|
||||||
# Rhizome store contents have new payload.
|
# Rhizome store contents have new payload.
|
||||||
executeOk_servald rhizome list ''
|
executeOk_servald rhizome list ''
|
||||||
|
Loading…
Reference in New Issue
Block a user