gpg: Support 'gpgcompose --encrypted-pop --help'
authorNeal H. Walfield <neal@g10code.com>
Sun, 11 Jun 2017 12:00:22 +0000 (14:00 +0200)
committerNeal H. Walfield <neal@g10code.com>
Sun, 11 Jun 2017 12:06:44 +0000 (14:06 +0200)
* g10/gpgcompose.c (encrypted_pop_options): New variable.
(encrypted_pop): Support the --help option.

Reported-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
g10/gpgcompose.c

index a8da54c..49bb8af 100644 (file)
@@ -2580,18 +2580,36 @@ encrypted (const char *option, int argc, char *argv[], void *cookie)
   return processed;
 }
 \f
+static struct option encrypted_pop_options[] = {
+  { NULL, NULL,
+    "Example:\n\n"
+    "  $ gpgcompose --sk-esk PASSWORD \\\n"
+    "    --encrypted-mdc \\\n"
+    "      --literal --value foo \\\n"
+    "    --encrypted-pop | " GPG_NAME " --list-packets" }
+};
+
 static int
 encrypted_pop (const char *option, int argc, char *argv[], void *cookie)
 {
   iobuf_t out = cookie;
+  int processed;
 
-  (void) argc;
-  (void) argv;
+  processed = process_options (option,
+                               major_options,
+                               encrypted_pop_options,
+                               NULL,
+                               global_options, NULL,
+                               argc, argv);
+  /* We only support a single option, --help, which causes the program
+   * to exit.  */
+  log_assert (processed == 0);
 
+  filter_pop (out, PKT_ENCRYPTED);
 
   debug ("Popped encryption container.\n");
 
-  return 0;
+  return processed;
 }
 \f
 struct data