diff options
author | Werner Koch <wk@gnupg.org> | 2016-08-13 19:27:28 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-08-13 19:40:32 +0200 |
commit | 700920640211168ae1c97d0adef74ba8615d90bb (patch) | |
tree | 0561a5a22deaef82d15dae360e3cb83bbc443740 /g13/sh-cmd.c | |
parent | g13: Move some function around. (diff) | |
download | gnupg2-700920640211168ae1c97d0adef74ba8615d90bb.tar.xz gnupg2-700920640211168ae1c97d0adef74ba8615d90bb.zip |
g13: Consider g13tab for a mount command.
* g13/sh-cmd.c (cmd_getkeyblob): New.
(register_commands): Register it.
* g13/call-syshelp.c (getkeyblob_data_cb): New.
(call_syshelp_get_keyblob): New.
* g13/mount.c: Include callsyshelp.h.
(g13_mount_container): Ask syshelp whether the filename is managed by
g13tab. Call syshelp to get the encrypted keyblob in this case.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g13/sh-cmd.c')
-rw-r--r-- | g13/sh-cmd.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/g13/sh-cmd.c b/g13/sh-cmd.c index e00bb774c..10b1ba93b 100644 --- a/g13/sh-cmd.c +++ b/g13/sh-cmd.c @@ -383,6 +383,52 @@ cmd_create (assuan_context_t ctx, char *line) } +static const char hlp_getkeyblob[] = + "GETKEYBLOB\n" + "\n" + "Return the encrypted keyblob of the current device."; +static gpg_error_t +cmd_getkeyblob (assuan_context_t ctx, char *line) +{ + ctrl_t ctrl = assuan_get_pointer (ctx); + gpg_error_t err; + void *enckeyblob = NULL; + size_t enckeybloblen; + + line = skip_options (line); + + if (!ctrl->server_local->devicename + || !ctrl->server_local->devicefp + || !ctrl->devti) + { + err = set_error (GPG_ERR_ENOENT, "No device has been set"); + goto leave; + } + + err = sh_is_empty_partition (ctrl->server_local->devicename); + if (!err) + { + err = gpg_error (GPG_ERR_ENODEV); + assuan_set_error (ctx, err, "Partition is empty"); + goto leave; + } + err = 0; + + err = g13_keyblob_read (ctrl->server_local->devicename, + &enckeyblob, &enckeybloblen); + if (err) + goto leave; + + err = assuan_send_data (ctx, enckeyblob, enckeybloblen); + if (!err) + err = assuan_send_data (ctx, NULL, 0); /* Flush */ + + leave: + xfree (enckeyblob); + return leave_cmd (ctx, err); +} + + static const char hlp_mount[] = "MOUNT <type>\n" "\n" @@ -667,6 +713,7 @@ register_commands (assuan_context_t ctx, int fail_all) { "FINDDEVICE", cmd_finddevice, hlp_finddevice }, { "DEVICE", cmd_device, hlp_device }, { "CREATE", cmd_create, hlp_create }, + { "GETKEYBLOB", cmd_getkeyblob, hlp_getkeyblob }, { "MOUNT", cmd_mount, hlp_mount }, { "SUSPEND", cmd_suspend,hlp_suspend}, { "RESUME", cmd_resume, hlp_resume }, |