mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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>
This commit is contained in:
parent
37e932658c
commit
7009206402
4 changed files with 132 additions and 14 deletions
47
g13/sh-cmd.c
47
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 },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue