[git] Pinentry - branch, master, updated. pinentry-1.1.0-7-g779b8e6

by Werner Koch cvs at cvs.gnupg.org
Wed Jun 13 16:11:46 CEST 2018


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  779b8e6df7d2678d40bc61ba9e9ff35324a40d03 (commit)
      from  948105b7a34ec9a9e5479d376b7c86bafee50a01 (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 779b8e6df7d2678d40bc61ba9e9ff35324a40d03
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jun 13 16:10:53 2018 +0200

    core: Add info about tty mode etc to 'getinfo ttyinfo'
    
    * configure.ac: Check for 'stat'.
    * pinentry/pinentry.c: Include types.h and stat.h.
    (device_stat_string): New.
    (cmd_getinfo): Print more info.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/configure.ac b/configure.ac
index e305e44..51a2313 100644
--- a/configure.ac
+++ b/configure.ac
@@ -221,7 +221,7 @@ AC_HEADER_STDC
 AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h utime.h wchar.h)
 
 dnl Checks for library functions.
-AC_CHECK_FUNCS(seteuid stpcpy mmap)
+AC_CHECK_FUNCS(seteuid stpcpy mmap stat)
 GNUPG_CHECK_MLOCK
 
 dnl Checks for standard types.
diff --git a/pinentry/pinentry.c b/pinentry/pinentry.c
index 30c333b..cd813d8 100644
--- a/pinentry/pinentry.c
+++ b/pinentry/pinentry.c
@@ -27,6 +27,8 @@
 #endif
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <assert.h>
 #ifndef HAVE_W32_SYSTEM
@@ -1706,6 +1708,33 @@ cmd_message (assuan_context_t ctx, char *line)
   return cmd_confirm (ctx, "--one-button");
 }
 
+
+/* Return a staically allocated string with information on the mode,
+ * uid, and gid of DEVICE.  On error "?" is returned if DEVICE is
+ * NULL, "-" is returned.  */
+static const char *
+device_stat_string (const char *device)
+{
+#ifdef HAVE_STAT
+  static char buf[40];
+  struct stat st;
+
+  if (!device || !*device)
+    return "-";
+
+  if (stat (device, &st))
+    return "?";  /* Error */
+  snprintf (buf, sizeof buf, "%lo/%lu/%lu",
+            (unsigned long)st.st_mode,
+            (unsigned long)st.st_uid,
+            (unsigned long)st.st_gid);
+  return buf;
+#else
+  return "-";
+#endif
+}
+
+
 /* GETINFO <what>
 
    Multipurpose function to return a variety of information.
@@ -1721,7 +1750,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
 {
   int rc;
   const char *s;
-  char buffer[100];
+  char buffer[150];
 
   if (!strcmp (line, "version"))
     {
@@ -1753,10 +1782,17 @@ cmd_getinfo (assuan_context_t ctx, char *line)
     }
   else if (!strcmp (line, "ttyinfo"))
     {
-      snprintf (buffer, sizeof buffer, "%s %s %s",
+      snprintf (buffer, sizeof buffer, "%s %s %s %s %lu/%lu",
                 pinentry.ttyname? pinentry.ttyname : "-",
                 pinentry.ttytype? pinentry.ttytype : "-",
-                pinentry.display? pinentry.display : "-" );
+                pinentry.display? pinentry.display : "-",
+                device_stat_string (pinentry.ttyname),
+#ifdef HAVE_DOSISH_SYSTEM
+                0l, 0l
+#else
+                (unsigned long)geteuid (), (unsigned long)getegid ()
+#endif
+                );
       buffer[sizeof buffer -1] = 0;
       rc = assuan_send_data (ctx, buffer, strlen (buffer));
     }

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

Summary of changes:
 configure.ac        |  2 +-
 pinentry/pinentry.c | 42 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 4 deletions(-)


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




More information about the Gnupg-commits mailing list