aboutsummaryrefslogtreecommitdiffstats
path: root/g13/sh-cmd.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-01-09 18:52:04 +0000
committerWerner Koch <[email protected]>2024-01-09 18:52:04 +0000
commit6233a17ac99deb8d246458380813b621df2609bf (patch)
treea15a5797bf8cb809353e3e1086933563555d9245 /g13/sh-cmd.c
parentgpg: Print a useful error id SKI algo 253 is found. (diff)
downloadgnupg-6233a17ac99deb8d246458380813b621df2609bf.tar.gz
gnupg-6233a17ac99deb8d246458380813b621df2609bf.zip
g13: New option --no-mount.
* g13/g13.c (oNoMount): New. (opts): Add --no-mount. (main): Implement this. * g13/g13-common.h (opt): Add field no_mount. * common/status.h (STATUS_PLAINDEV): New. * g13/sh-cmd.c (has_option): Uncomment. (cmd_mount): Add option --no-mount and pass down. * g13/sh-dmcrypt.c (sh_dmcrypt_mount_container): Add arg nomount and emit PLAINDEV status line. (sh_dmcrypt_umount_container): Rund findmnt before umount. -- This option can be used to decrypt a device but not to mount it. For example to run fsck first. A command or option to run fsck before a mount will eventually be added. The use of findmnt is needed so that we can easily remove a device which has not been mounted.
Diffstat (limited to 'g13/sh-cmd.c')
-rw-r--r--g13/sh-cmd.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/g13/sh-cmd.c b/g13/sh-cmd.c
index 791e3b7f4..1d21f6cc4 100644
--- a/g13/sh-cmd.c
+++ b/g13/sh-cmd.c
@@ -83,17 +83,17 @@ skip_options (const char *line)
/* Check whether the option NAME appears in LINE. */
-/* static int */
-/* has_option (const char *line, const char *name) */
-/* { */
-/* const char *s; */
-/* int n = strlen (name); */
+static int
+has_option (const char *line, const char *name)
+{
+ const char *s;
+ int n = strlen (name);
-/* s = strstr (line, name); */
-/* if (s && s >= skip_options (line)) */
-/* return 0; */
-/* return (s && (s == line || spacep (s-1)) && (!s[n] || spacep (s+n))); */
-/* } */
+ s = strstr (line, name);
+ if (s && s >= skip_options (line))
+ return 0;
+ return (s && (s == line || spacep (s-1)) && (!s[n] || spacep (s+n)));
+}
/* Helper to print a message while leaving a command. */
@@ -431,10 +431,11 @@ cmd_getkeyblob (assuan_context_t ctx, char *line)
static const char hlp_mount[] =
- "MOUNT <type>\n"
+ "MOUNT [--no-mount] <type>\n"
"\n"
"Mount an encrypted partition on the current device.\n"
- "<type> must be \"dm-crypt\" for now.";
+ "<type> must be \"dm-crypt\" for now. Option --no-mount\n"
+ "stops right before calling the mount command.\n";
static gpg_error_t
cmd_mount (assuan_context_t ctx, char *line)
{
@@ -443,6 +444,9 @@ cmd_mount (assuan_context_t ctx, char *line)
unsigned char *keyblob = NULL;
size_t keybloblen;
tupledesc_t tuples = NULL;
+ int nomount;
+
+ nomount = has_option (line, "--no-mount");
line = skip_options (line);
@@ -493,7 +497,7 @@ cmd_mount (assuan_context_t ctx, char *line)
err = sh_dmcrypt_mount_container (ctrl,
ctrl->server_local->devicename,
- tuples);
+ tuples, nomount);
leave:
destroy_tupledesc (tuples);