From 3e920c8dfa0b540e98166a41f3682b7c159ba146 Mon Sep 17 00:00:00 2001 From: gardners Date: Fri, 13 Apr 2012 09:35:22 +0930 Subject: [PATCH] simple server mode now correctly opens and populates keyring with any identities with blank pins. --- keyring.c | 11 ++++++----- server.c | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/keyring.c b/keyring.c index 6d2c8498..dc4a3382 100644 --- a/keyring.c +++ b/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; } diff --git a/server.c b/server.c index 25540311..271c0676 100644 --- a/server.c +++ b/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);