[mew-dist 29282] Re: NTEmacsでmaster passwd が使えない

Yu-ji Hosokawa <[email protected]>
Newsgroups gmane.mail.mew.general.japanese
Message-ID <[email protected]>
細川です

|Date: Sat, 30 Aug 2008 15:35:36 +0900 ()
|From: Kentaro KAWAMOTO <[email protected]>
|Message-Id: <[email protected]>
|Subject: [mew-dist 28609] Re: NTEmacsでmaster passwdが使えない
>
> On Wed, 27 Aug 2008 09:40:56 +0900 ()
> Kentaro KAWAMOTO <[email protected]> wrote:
>
>> 最近の GnuPG は、--use-agent をサポートしていないようです。
>> コマンドラインで実行したら、
>> gpg: NOTE: --use-agent is not available in this version
>> と言われてしまいました。
>>
>> 上記 URL に書いてあるように、
>> パッチを当てた GnuPG を作ってみます。
>
> http://clbianco.altervista.org/gnupg/eng/gnupg.html
> http://www.issp.u-tokyo.ac.jp/labs/sor/iida/gnupg/
> を参考に、GnuPG 1.4.9 にパッチを当ててビルドしたら
> Mew から使えるようになりました。
>
> 参考までにパッチを添付します。

便利に使わせていただいています、ありがとうございます。
このパッチを GnuPG 1.4.11 に当たるよう修正したものを添付します。

Windows の Emacs 23.2 と Cygwin 1.7 の GnuPG 1.4.9 で署名がうまくいか
ないこと、および、このパッチをあてた GnuPG 1.4.11 で署名がうまくいく
ことを確認してあります。

--
Yu-ji Hosokawa (細川雄司)
gnupg-1.4.11_ttyio.patch (text/x-patch, 3.6 KB)
diff -pur gnupg-1.4.11.orig/util/ttyio.c gnupg-1.4.11/util/ttyio.c
--- gnupg-1.4.11.orig/util/ttyio.c	2010-09-28 18:39:05.000000000 +0900
+++ gnupg-1.4.11/util/ttyio.c	2010-10-20 06:18:01.029056500 +0900
@@ -71,6 +71,7 @@ static struct {

 #else /* yeah, we have a real OS */
 static FILE *ttyfp = NULL;
+static FILE *ttyfpin = NULL;
 #endif

 static int initialized;
@@ -157,7 +158,7 @@ init_ttyfp(void)
 	return;

 #if defined(_WIN32)
-    {
+    if( isatty(fileno(stdin)) ) {
 	SECURITY_ATTRIBUTES sa;

 	memset(&sa, 0, sizeof(sa));
@@ -176,6 +177,9 @@ init_ttyfp(void)
 			       &sa, OPEN_EXISTING, 0, 0 );
 	if (con.in == INVALID_HANDLE_VALUE)
             log_fatal ("open(CONIN$) failed: %s", w32_strerror (0));
+    } else {
+      con.out = GetStdHandle(STD_OUTPUT_HANDLE);
+      con.in = GetStdHandle(STD_INPUT_HANDLE);
     }
     SetConsoleMode(con.in, DEF_INPMODE );
     SetConsoleMode(con.out, DEF_OUTMODE );
@@ -183,7 +187,8 @@ init_ttyfp(void)
 #elif defined(__EMX__)
     ttyfp = stdout; /* Fixme: replace by the real functions: see wklib */
 #else
-    ttyfp = batchmode? stderr : fopen( tty_get_ttyname (), "r+");
+    ttyfp = batchmode? stderr : stdout;
+    ttyfpin = batchmode? stderr : stdin;
     if( !ttyfp ) {
 	log_error("cannot open `%s': %s\n",
                   tty_get_ttyname (), strerror(errno) );
@@ -268,7 +273,7 @@ tty_printf( const char *fmt, ... )
           log_bug("xtryvasprintf() failed\n");
         n = strlen (buf);

-	if (!WriteConsoleA (con.out, buf, n, &nwritten, NULL))
+	if (!WriteFile( con.out, buf, n, &nwritten, NULL ) )
 	    log_fatal ("WriteConsole failed: %s", w32_strerror (0));
 	if( n != nwritten )
 	    log_fatal ("WriteConsole failed: %d != %d\n", n, (int)nwritten );
@@ -446,7 +451,7 @@ do_get( const char *prompt, int hidden )
     for(;;) {
 	DWORD nread;

-	if (!ReadConsoleA (con.in, cbuf, 1, &nread, NULL))
+	if( !ReadFile( con.in, cbuf, 1, &nread, NULL ) )
 	    log_fatal ("ReadConsole failed: %s", w32_strerror (0));
 	if( !nread )
 	    continue;
@@ -515,16 +520,18 @@ do_get( const char *prompt, int hidden )
     } while (c != '\n');
     i = (i>0) ? i-1 : 0;
 #else /* unix version */
+    if( !isatty(fileno(stdin)) ) hidden = 0;
+
     if( hidden ) {
 #ifdef HAVE_TCGETATTR
 	struct termios term;

-	if( tcgetattr(fileno(ttyfp), &termsave) )
+	if( tcgetattr(fileno(ttyfpin), &termsave) )
 	    log_fatal("tcgetattr() failed: %s\n", strerror(errno) );
 	restore_termios = 1;
 	term = termsave;
 	term.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
-	if( tcsetattr( fileno(ttyfp), TCSAFLUSH, &term ) )
+	if( tcsetattr( fileno(ttyfpin), TCSAFLUSH, &term ) )
 	    log_fatal("tcsetattr() failed: %s\n", strerror(errno) );
 #endif
 # ifdef __VMS
@@ -538,7 +545,7 @@ do_get( const char *prompt, int hidden )

     /* fixme: How can we avoid that the \n is echoed w/o disabling
      * canonical mode - w/o this kill_prompt can't work */
-    while( read(fileno(ttyfp), cbuf, 1) == 1 && *cbuf != '\n' ) {
+    while( read(fileno(ttyfpin), cbuf, 1) == 1 && *cbuf != '\n' ) {
 	if( !hidden )
 	    last_prompt_len++;
 	c = *cbuf;
@@ -565,7 +572,7 @@ do_get( const char *prompt, int hidden )

     if( hidden ) {
 # ifdef HAVE_TCGETATTR
-	if( tcsetattr(fileno(ttyfp), TCSAFLUSH, &termsave) )
+	if( tcsetattr(fileno(ttyfpin), TCSAFLUSH, &termsave) )
 	    log_error("tcsetattr() failed: %s\n", strerror(errno) );
 	restore_termios = 0;
 # endif
@@ -641,7 +648,8 @@ tty_kill_prompt()
     if( !last_prompt_len )
 	return;
 #ifdef _WIN32
-    tty_printf("\r%*s\r", last_prompt_len, "");
+    if( isatty(fileno(stdin)) )
+      tty_printf("\r%*s\r", last_prompt_len, "");
 #else
     {
 	int i;
signature.asc (application/pgp-signature, 227 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Cygwin)

iF4EABEIAAYFAky+GuEACgkQhBUuX+Eky0EitgD/VXiZFu0nNvlRKXnGu1DZA0OV
lSewt6Ljg16diQfmhDwA/jwo9DBqKLRuE9Oo+OWuIrW+GEsyPBkkstEjLgBgziOC
=yogn
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.