[git] Pinentry - branch, master, updated. pinentry-1.0.0-23-g1dba96f

by Marcus Brinkmann cvs at cvs.gnupg.org
Tue Jul 11 19:28:00 CEST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".

The branch, master has been updated
       via  1dba96fafa123f3631c0a50bb01835306c23b903 (commit)
      from  f69dadc6ccea7672869436291ab5c1f58d545466 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1dba96fafa123f3631c0a50bb01835306c23b903
Author: Marcus Brinkmann <marcus.brinkmann at ruhr-uni-bochum.de>
Date:   Tue Jul 11 19:06:22 2017 +0200

    curses: Add option to beep or flash terminal on dialog.
    
    * pinentry/pinentry-curses.c (dialog_run): Beep or flash terminal.
    * pinentry/pinentry.c (pinentry_reset): Reset ttyalert option.
    (pinentry_parse_opts): Parse option ttyalert.
    (option_handler): Handle option ttyalert.
    * pinentry/pinentry.h (struct pinentry): New option ttyalert.
    
    Signed-off-by: Marcus Brinkmann <mb at g10code.com>
    GnuPG-bug-id: 2013

diff --git a/pinentry/pinentry-curses.c b/pinentry/pinentry-curses.c
index 6fa4c72..7c82e0f 100644
--- a/pinentry/pinentry-curses.c
+++ b/pinentry/pinentry-curses.c
@@ -889,6 +889,14 @@ dialog_run (pinentry_t pinentry, const char *tty_name, const char *tty_type)
   cbreak ();		/* Take input chars one at a time, no wait for \n.  */
   noecho ();		/* Don't echo input - in color.  */
 
+  if (pinentry->ttyalert)
+    {
+      if (! strcmp(pinentry->ttyalert, "beep"))
+	beep ();
+      else if (! strcmp(pinentry->ttyalert, "flash"))
+	flash ();
+    }
+
   if (has_colors ())
     {
       start_color ();
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 0d889a6..ed8fa6d 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -87,6 +87,7 @@ pinentry_reset (int use_defaults)
   int grab = pinentry.grab;
   char *ttyname = pinentry.ttyname;
   char *ttytype = pinentry.ttytype;
+  char *ttyalert = pinentry.ttyalert;
   char *lc_ctype = pinentry.lc_ctype;
   char *lc_messages = pinentry.lc_messages;
   int allow_external_password_cache = pinentry.allow_external_password_cache;
@@ -123,6 +124,7 @@ pinentry_reset (int use_defaults)
     {
       free (pinentry.ttyname);
       free (pinentry.ttytype);
+      free (pinentry.ttyalert);
       free (pinentry.lc_ctype);
       free (pinentry.lc_messages);
       free (pinentry.default_ok);
@@ -179,6 +181,7 @@ pinentry_reset (int use_defaults)
       pinentry.grab = grab;
       pinentry.ttyname = ttyname;
       pinentry.ttytype = ttytype;
+      pinentry.ttyalert = ttyalert;
       pinentry.lc_ctype = lc_ctype;
       pinentry.lc_messages = lc_messages;
       pinentry.allow_external_password_cache = allow_external_password_cache;
@@ -818,6 +821,7 @@ pinentry_parse_opts (int argc, char *argv[])
                  "Grab keyboard only while window is focused"),
     ARGPARSE_s_u('W', "parent-wid", "Parent window ID (for positioning)"),
     ARGPARSE_s_s('c', "colors", "|STRING|Set custom colors for ncurses"),
+    ARGPARSE_s_s('a', "ttyalert", "|STRING|Set the alert mode (none, beep or flash)"),
     ARGPARSE_end()
   };
   ARGPARSE_ARGS pargs = { &argc, &argv, 0 };
@@ -909,6 +913,17 @@ pinentry_parse_opts (int argc, char *argv[])
 	  pinentry.timeout = pargs.r.ret_int;
 	  break;
 
+	case 'a':
+	  pinentry.ttyalert = strdup (pargs.r.ret_str);
+	  if (!pinentry.ttyalert)
+	    {
+#ifndef HAVE_W32CE_SYSTEM
+	      fprintf (stderr, "%s: %s\n", this_pgmname, strerror (errno));
+#endif
+	      exit (EXIT_FAILURE);
+	    }
+	  break;
+
         default:
           pargs.err = ARGPARSE_PRINT_WARNING;
 	  break;
@@ -975,6 +990,14 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
       if (!pinentry.ttytype)
 	return gpg_error_from_syserror ();
     }
+  else if (!strcmp (key, "ttyalert"))
+    {
+      if (pinentry.ttyalert)
+	free (pinentry.ttyalert);
+      pinentry.ttyalert = strdup (value);
+      if (!pinentry.ttyalert)
+	return gpg_error_from_syserror ();
+    }
   else if (!strcmp (key, "lc-ctype"))
     {
       if (pinentry.lc_ctype)
diff --git a/pinentry/pinentry.h b/pinentry/pinentry.h
index 868b4d8..a4447a8 100644
--- a/pinentry/pinentry.h
+++ b/pinentry/pinentry.h
@@ -75,6 +75,8 @@ struct pinentry
   char *ttyname;
   /* The type of the terminal.  (Assuan: "OPTION ttytype TTYTYPE".)  */
   char *ttytype;
+  /* Set the alert mode (none, beep or flash).  */
+  char *ttyalert;
   /* The LC_CTYPE value for the terminal.  (Assuan: "OPTION lc-ctype
      LC_CTYPE".)  */
   char *lc_ctype;

-----------------------------------------------------------------------

Summary of changes:
 pinentry/pinentry-curses.c |  8 ++++++++
 pinentry/pinentry.c        | 23 +++++++++++++++++++++++
 pinentry/pinentry.h        |  2 ++
 3 files changed, 33 insertions(+)


hooks/post-receive
-- 
The standard pinentry collection
http://git.gnupg.org




More information about the Gnupg-commits mailing list