diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-05-19 15:59:37 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-05-19 16:01:51 -0400 |
commit | 8cc7d4928198f843fa6d790a615405140fc992d3 (patch) | |
tree | d2e7de8e9e120e2228017817f5476f8e9e73c74f /cmd_key.c | |
parent | 0766bee8fdf3973953fd3184f63dfe2a0760c08d (diff) |
cmd_unlock: Add -k argument to specify keyring
This adds a new argument (-k) to cmd_unlock for specifying the keyring
to add to. The default is user, but user_session and session can also be
specified.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'cmd_key.c')
-rw-r--r-- | cmd_key.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -14,20 +14,26 @@ static void unlock_usage(void) "\n" "Options:\n" " -c Check if a device is encrypted\n" + " -k (session|user|user_session)\n" + " Keyring to add to (default: user)\n" " -h Display this help and exit\n" "Report bugs to <linux-bcache@vger.kernel.org>"); } int cmd_unlock(int argc, char *argv[]) { + const char *keyring = "user"; bool check = false; int opt; - while ((opt = getopt(argc, argv, "ch")) != -1) + while ((opt = getopt(argc, argv, "ck:h")) != -1) switch (opt) { case 'c': check = true; break; + case 'k': + keyring = strdup(optarg); + break; case 'h': unlock_usage(); exit(EXIT_SUCCESS); @@ -59,7 +65,7 @@ int cmd_unlock(int argc, char *argv[]) char *passphrase = read_passphrase("Enter passphrase: "); - bch2_add_key(sb.sb, passphrase); + bch2_add_key(sb.sb, "user", keyring, passphrase); bch2_free_super(&sb); memzero_explicit(passphrase, strlen(passphrase)); |