Page MenuHome GnuPG

pinentry doesn't compile: declaration of ttytype conflicts with curses.h
Closed, ResolvedPublic

Description

I'm surprised, that I did not find anything relative to this bug. It may be related also to my version von ncurses as well as compiler and development environment.
Versions: pinentry 1.1.0, ncurses 6.2, gcc 9.3.0. GNU/Linux x86 system.

configure command: configure --prefix=/usr --enable-pinentry-tty
error in make process
In Datei, eingebunden von /usr/include/curses.h:61,

von ../../pinentry-1.1.0/pinentry/pinentry-curses.c:25:

../../pinentry-1.1.0/pinentry/pinentry.h:78:9: Fehler: Feld »_nc_ttytype« als Funktion deklariert

78 |   char *ttytype;
   |         ^~~~~~~

Solution is to change the name in pinentry/pinentry.h:78. I replaced it by tty__type

So this is the patch that worked for me to compile cleanly:

  • snip -----------------------------------

diff -Naur pinentry-1.1.0/pinentry/pinentry.c pinentry-1.1.0-patched/pinentry/pinentry.c

  • pinentry-1.1.0/pinentry/pinentry.c 2017-12-03 17:13:15.000000000 +0100

+++ pinentry-1.1.0-patched/pinentry/pinentry.c 2020-04-24 18:24:20.500008014 +0200
@@ -97,7 +97,7 @@

   Don't reset them.  */
int grab = pinentry.grab;
char *ttyname = pinentry.ttyname;
  • char *ttytype = pinentry.ttytype;

+ char *ttytype = pinentry.tty__type;

char *ttyalert = pinentry.ttyalert;
char *lc_ctype = pinentry.lc_ctype;
char *lc_messages = pinentry.lc_messages;

@@ -135,7 +135,7 @@

if (use_defaults)
  {
    free (pinentry.ttyname);
  • free (pinentry.ttytype);

+ free (pinentry.tty__type);

free (pinentry.ttyalert);
free (pinentry.lc_ctype);
free (pinentry.lc_messages);

@@ -194,7 +194,7 @@

{
  pinentry.grab = grab;
  pinentry.ttyname = ttyname;
  • pinentry.ttytype = ttytype;

+ pinentry.tty__type = ttytype;

pinentry.ttyalert = ttyalert;
pinentry.lc_ctype = lc_ctype;
pinentry.lc_messages = lc_messages;

@@ -950,8 +950,8 @@

    }
  break;
case 'N':
  • pinentry.ttytype = strdup (pargs.r.ret_str);
  • if (!pinentry.ttytype)

+ pinentry.ttytype = strdup (pargs.r.ret_str);
+ if (!pinentry.tty
type)

{

#ifndef HAVE_W32CE_SYSTEM

fprintf (stderr, "%s: %s\n", this_pgmname, strerror (errno));

@@ -1070,10 +1070,10 @@

  }
else if (!strcmp (key, "ttytype"))
  {
  • if (pinentry.ttytype)
  • free (pinentry.ttytype);
  • pinentry.ttytype = strdup (value);
  • if (!pinentry.ttytype)

+ if (pinentry.ttytype)
+ free (pinentry.tty
type);
+ pinentry.ttytype = strdup (value);
+ if (!pinentry.tty
type)

     return gpg_error_from_syserror ();
  }
else if (!strcmp (key, "ttyalert"))

@@ -1755,7 +1755,7 @@

{
  snprintf (buffer, sizeof buffer, "%s %s %s",
            pinentry.ttyname? pinentry.ttyname : "-",
  • pinentry.ttytype? pinentry.ttytype : "-",

+ pinentry.ttytype? pinentry.ttytype : "-",

          pinentry.display? pinentry.display : "-" );
buffer[sizeof buffer -1] = 0;
rc = assuan_send_data (ctx, buffer, strlen (buffer));

diff -Naur pinentry-1.1.0/pinentry/pinentry-curses.c pinentry-1.1.0-patched/pinentry/pinentry-curses.c

  • pinentry-1.1.0/pinentry/pinentry-curses.c 2017-12-03 17:13:05.000000000 +0100

+++ pinentry-1.1.0-patched/pinentry/pinentry-curses.c 2020-04-24 18:29:40.919059750 +0200
@@ -1188,7 +1188,7 @@

}

#endif

  • rc = dialog_run (pinentry, pinentry->ttyname, pinentry->ttytype);

+ rc = dialog_run (pinentry, pinentry->ttyname, pinentry->tty__type);

do_touch_file (pinentry);
return rc;

}
diff -Naur pinentry-1.1.0/pinentry/pinentry.h pinentry-1.1.0-patched/pinentry/pinentry.h

  • pinentry-1.1.0/pinentry/pinentry.h 2017-12-03 17:13:05.000000000 +0100

+++ pinentry-1.1.0-patched/pinentry/pinentry.h 2020-04-24 18:24:20.500008014 +0200
@@ -75,7 +75,7 @@

   supported.  (Assuan: "OPTION ttyname TTYNAME".)  */
char *ttyname;
/* The type of the terminal.  (Assuan: "OPTION ttytype TTYTYPE".)  */
  • char *ttytype;

+ char *tty__type;

/* Set the alert mode (none, beep or flash).  */
char *ttyalert;
/* The LC_CTYPE value for the terminal.  (Assuan: "OPTION lc-ctype

Details

Version
1.1.0

Revisions and Commits

Event Timeline

Using a double underscore in a symbol should be avoided because such symbols are reserved for system use.
(To include a diff inline, please intend it by two spaces so that it is not not considered as marked up text.)

Ok. Renamed ist "ttytype_l" (l for local) and found the button to upload a file.
Hope it helps.

There was a patch for this by david faure which added an
#undef ttytype after including curses.h

I was not sure if that was the correct solution and forgot about it. I think renaming the variable is better. I'll apply your patch.

Thanks.

aheinecke changed the task status from Open to Testing.May 8 2020, 12:07 PM
aheinecke triaged this task as Normal priority.

I keep it open as testing so that we keep it in mind for a release.

gouttegd claimed this task.
gouttegd added a subscriber: gouttegd.

The fix will be part of the upcoming pinentry-1.1.1.