From b781113cf1391926dedf8dc943624d3bb9726318 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sun, 14 Aug 2016 20:17:51 +0200 Subject: g13: Implement --umount for dm-crypt. * g13/g13.c (main): Implement command --umount. * g13/mount.c (g13_umount_container): use the syshelper if needed. * g13/backend.c (be_umount_container): New. * g13/be-dmcrypt.c (be_dmcrypt_umount_container): New. * g13/call-syshelp.c (call_syshelp_run_umount): New. * g13/sh-cmd.c (cmd_umount): New. (register_commands): Register UMOUNT. * g13/sh-dmcrypt.c (sh_dmcrypt_umount_container): New. Signed-off-by: Werner Koch --- g13/sh-cmd.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'g13/sh-cmd.c') diff --git a/g13/sh-cmd.c b/g13/sh-cmd.c index 20db8dce0..821491982 100644 --- a/g13/sh-cmd.c +++ b/g13/sh-cmd.c @@ -500,6 +500,40 @@ cmd_mount (assuan_context_t ctx, char *line) } +static const char hlp_umount[] = + "UMOUNT \n" + "\n" + "Unmount an encrypted partition and wipe the key.\n" + " must be \"dm-crypt\" for now."; +static gpg_error_t +cmd_umount (assuan_context_t ctx, char *line) +{ + ctrl_t ctrl = assuan_get_pointer (ctx); + gpg_error_t err = 0; + + line = skip_options (line); + + if (strcmp (line, "dm-crypt")) + { + err = set_error (GPG_ERR_INV_ARG, "Type must be \"dm-crypt\""); + goto leave; + } + + 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_dmcrypt_umount_container (ctrl, ctrl->server_local->devicename); + + leave: + return leave_cmd (ctx, err); +} + + static const char hlp_suspend[] = "SUSPEND \n" "\n" @@ -713,6 +747,7 @@ register_commands (assuan_context_t ctx, int fail_all) { "CREATE", cmd_create, hlp_create }, { "GETKEYBLOB", cmd_getkeyblob, hlp_getkeyblob }, { "MOUNT", cmd_mount, hlp_mount }, + { "UMOUNT", cmd_umount, hlp_umount }, { "SUSPEND", cmd_suspend,hlp_suspend}, { "RESUME", cmd_resume, hlp_resume }, { "INPUT", NULL }, -- cgit v1.2.3