@@ -11,8 +11,10 @@ * ? generates passwords * → kpw is unlikely to be portable to non-POSIX * systems, but should run fine on Linux as well * as BSDs with getrandom() support. + * → kpw has the following dependencies: + * - libsodium * ! for getrandom() to work with the version of * libc on my android phone, the getrandom() call * had to be converted to use the syscall() * interface. this is unlikely to cause problems, @@ -464,10 +466,12 @@ const size_t priv_sz = sizeof(key_priv); byte key [db_privkey_len]; /* is the private key loaded into memory? */ +#ifdef _SAVEKEY int shm = shmget(*((key_t*) salt), sizeof(key_priv), 0); if (shm == -1) { +#endif /* no key in memory - read password from stdin instead */ password dbpw; size_t pwlen; bad e = pwread(true, dbpw, &pwlen,_str("database key: ")); if (e != ok) return e; @@ -485,8 +489,9 @@ for (size_t i = 0; i < sz(key); ++i) { priv[i] = priv_enc[i] ^ key[i]; } hexdump(priv, sz(key)); +#ifdef _SAVEKEY } else { /* found a key in memory; loading it into *priv */ alert(a_debug, "using saved key"); key_priv* saved = shmat(shm, 0, 0); @@ -495,8 +500,9 @@ hexdump((byte*)saved, sizeof(key_priv)); memcpy(priv, saved, sizeof(key_priv)); shmdt(saved); } +#endif return ok; } @@ -613,8 +619,9 @@ if (sodium_init() < 0) return bad_lib_sodium_init; switch(op) { +# ifdef _SAVEKEY case logout: case keyin: { if (param != 0) return bad_syntax; @@ -649,8 +656,9 @@ } return ok; } +# endif case genpw: case addpw: { if (param == 0) return emit_usage(