[svn] pinentry - r155 - in trunk: . pinentry
svn author wk
cvs at cvs.gnupg.org
Wed Feb 14 17:24:03 CET 2007
Author: wk
Date: 2007-02-14 17:24:02 +0100 (Wed, 14 Feb 2007)
New Revision: 155
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/configure.ac
trunk/pinentry/pinentry-curses.c
trunk/pinentry/pinentry.c
trunk/pinentry/pinentry.h
Log:
* pinentry/pinentry.h (struct pinentry): Add TOUCH_FILE.
* pinentry/pinentry.c (option_handler): New option "touch-file".
(pinentry_have_display): Ignore an empty DISPLAY.
* pinentry/pinentry-curses.c (do_touch_file): New.
(curses_cmd_handler): Call it.
* configure.ac: Check for utime.h.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-01-24 18:25:10 UTC (rev 154)
+++ trunk/ChangeLog 2007-02-14 16:24:02 UTC (rev 155)
@@ -1,3 +1,12 @@
+2007-02-14 Werner Koch <wk at g10code.com>
+
+ * pinentry/pinentry.h (struct pinentry): Add TOUCH_FILE.
+ * pinentry/pinentry.c (option_handler): New option "touch-file".
+ (pinentry_have_display): Ignore an empty DISPLAY.
+ * pinentry/pinentry-curses.c (do_touch_file): New.
+ (curses_cmd_handler): Call it.
+ * configure.ac: Check for utime.h.
+
2007-01-24 Werner Koch <wk at g10code.com>
* pinentry/pinentry.c (cmd_message): New.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2007-01-24 18:25:10 UTC (rev 154)
+++ trunk/NEWS 2007-02-14 16:24:02 UTC (rev 155)
@@ -4,7 +4,10 @@
* New command MESSAGE and --one-button compatibility option to
CONFIRM.
+ * New Assuan option touch-file to set a file which will be touched
+ after ncurses does not need the display anymore.
+
Noteworthy changes in version 0.7.2 (2005-01-27)
------------------------------------------------
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-01-24 18:25:10 UTC (rev 154)
+++ trunk/configure.ac 2007-02-14 16:24:02 UTC (rev 155)
@@ -102,7 +102,7 @@
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h)
+AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h utime.h)
dnl Checks for library functions.
AC_CHECK_FUNCS(seteuid stpcpy mmap)
Modified: trunk/pinentry/pinentry-curses.c
===================================================================
--- trunk/pinentry/pinentry-curses.c 2007-01-24 18:25:10 UTC (rev 154)
+++ trunk/pinentry/pinentry-curses.c 2007-02-14 16:24:02 UTC (rev 155)
@@ -33,6 +33,12 @@
#include <limits.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif /*HAVE_UTIME_H*/
#include <memory.h>
@@ -723,8 +729,38 @@
return diag.pin ? (done < 0 ? -1 : diag.pin_len) : (done < 0 ? 0 : 1);
}
+
+/* If a touch has been registered, touch that file. */
+static void
+do_touch_file (pinentry_t pinentry)
+{
+#ifdef HAVE_UTIME_H
+ struct stat st;
+ time_t tim;
+
+ if (!pinentry->touch_file || !*pinentry->touch_file)
+ return;
+
+ if (stat (pinentry->touch_file, &st))
+ return; /* Oops. */
+
+ /* Make sure that we actually update the mtime. */
+ while ( (tim = time (NULL)) == st.st_mtime )
+ sleep (1);
+
+ /* Update but ignore errors as we can't do anything in that case.
+ Printing error messages may even clubber the display further. */
+ utime (pinentry->touch_file, NULL);
+#endif /*HAVE_UTIME_H*/
+}
+
+
int
curses_cmd_handler (pinentry_t pinentry)
{
- return dialog_run (pinentry, pinentry->ttyname, pinentry->ttytype);
+ int rc;
+
+ rc = dialog_run (pinentry, pinentry->ttyname, pinentry->ttytype);
+ do_touch_file (pinentry);
+ return rc;
}
Modified: trunk/pinentry/pinentry.c
===================================================================
--- trunk/pinentry/pinentry.c 2007-01-24 18:25:10 UTC (rev 154)
+++ trunk/pinentry/pinentry.c 2007-02-14 16:24:02 UTC (rev 155)
@@ -65,6 +65,7 @@
0, /* Enhanced mode. */
1, /* Global grab. */
0, /* Parent Window ID. */
+ NULL, /* Touch file. */
0, /* Result. */
0, /* Locale error flag. */
0 /* One-button flag. */
@@ -256,7 +257,10 @@
int
pinentry_have_display (int argc, char **argv)
{
- if (getenv ("DISPLAY"))
+ const char *s;
+
+ s = getenv ("DISPLAY");
+ if (s && *s)
return 1;
for (; argc; argc--, argv++)
if (!strcmp (*argv, "--display"))
@@ -451,6 +455,14 @@
pinentry.parent_wid = atoi (value);
/* FIXME: Use strtol and add some error handling. */
}
+ else if (!strcmp (key, "touch-file"))
+ {
+ if (pinentry.touch_file)
+ free (pinentry.touch_file);
+ pinentry.touch_file = strdup (value);
+ if (!pinentry.touch_file)
+ return ASSUAN_Out_Of_Core;
+ }
else
return ASSUAN_Invalid_Option;
return 0;
Modified: trunk/pinentry/pinentry.h
===================================================================
--- trunk/pinentry/pinentry.h 2007-01-24 18:25:10 UTC (rev 154)
+++ trunk/pinentry/pinentry.h 2007-02-14 16:24:02 UTC (rev 155)
@@ -67,6 +67,10 @@
should be displayed. */
int parent_wid;
+ /* The name of an optional file which will be touched after a curses
+ entry has been displayed. */
+ char *touch_file;
+
/* The user should set this to -1 if the user canceled the request,
and to the length of the PIN stored in pin otherwise. */
int result;
More information about the Gnupg-commits
mailing list