mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
simple server mode now correctly opens and populates keyring
with any identities with blank pins.
This commit is contained in:
parent
6f93d7a48d
commit
3e920c8dfa
11
keyring.c
11
keyring.c
@ -1122,20 +1122,21 @@ int keyring_seed(keyring_file *k)
|
||||
if (!k) return WHY("keyring is null");
|
||||
|
||||
/* nothing to do if there is already an identity */
|
||||
if (k->contexts[0]->identity_count) return 0;
|
||||
if (k->contexts[0]->identity_count)
|
||||
return 0;
|
||||
|
||||
int i;
|
||||
char did[65];
|
||||
unsigned char did[65];
|
||||
/* Securely generate random telephone number */
|
||||
urandombytes((unsigned char *)did,10);
|
||||
/* Make DID start with 2 through 9, as 1 is special in many number spaces. */
|
||||
did[0]='2'+did[0]%8;
|
||||
did[0]='2'+(did[0]%8);
|
||||
/* Then add 10 more digits, which is what we do in the mobile phone software */
|
||||
for(i=1;i<11;i++) did[i]='0'+did[i]%10; did[11]=0;
|
||||
for(i=1;i<11;i++) did[i]='0'+(did[i]%10); did[11]=0;
|
||||
|
||||
keyring_identity *id=keyring_create_identity(k,k->contexts[0],"");
|
||||
if (!id) return WHY("Could not create new identity");
|
||||
if (keyring_set_did(id,did)) return WHY("Could not set DID of new identity");
|
||||
if (keyring_set_did(id,(char *)did)) return WHY("Could not set DID of new identity");
|
||||
if (keyring_commit(k)) return WHY("Could not commit new identity to keyring file");
|
||||
return 0;
|
||||
}
|
||||
|
7
server.c
7
server.c
@ -150,10 +150,11 @@ int getKeyring(char *backing_file)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keyring) {
|
||||
if (keyring)
|
||||
exit(WHY("Keyring being opened twice"));
|
||||
keyring=keyring_open(backing_file);
|
||||
}
|
||||
keyring=keyring_open(backing_file);
|
||||
/* unlock all entries with blank pins */
|
||||
keyring_enter_pins(keyring,"");
|
||||
}
|
||||
keyring_seed(keyring);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user