core: Check for GPG_TTY as well as DISPLAY.
* src/engine-assuan.c (llass_new): Update --ttyname from GPG_TTY. * src/engine-g13.c (g13_new): Ditto. * src/engine-gpg.c (gpg_new): Ditto. * src/engine-uiserver.c (uiserver_new): Ditto. * src/engine-gpgsm.c (gpgsm_new): Ditto. -- Useful when no DISPLAY is set and there is no attached terminal to the current process. Signed-off-by: Ben Kibbey <bjk@luxsci.net>
This commit is contained in:
parent
a8ff34fc30
commit
9d62bacac7
@ -219,6 +219,7 @@ llass_new (void **engine, const char *file_name, const char *home_dir,
|
||||
gpgme_error_t err = 0;
|
||||
engine_llass_t llass;
|
||||
char *optstr;
|
||||
char *env_tty = NULL;
|
||||
|
||||
(void)version; /* Not yet used. */
|
||||
|
||||
@ -280,12 +281,23 @@ llass_new (void **engine, const char *file_name, const char *home_dir,
|
||||
}
|
||||
}
|
||||
|
||||
if (llass->opt.gpg_agent && isatty (1))
|
||||
if (llass->opt.gpg_agent)
|
||||
err = _gpgme_getenv ("GPG_TTY", &env_tty);
|
||||
|
||||
if (llass->opt.gpg_agent && (isatty (1) || env_tty || err))
|
||||
{
|
||||
int rc;
|
||||
int rc = 0;
|
||||
char dft_ttyname[64];
|
||||
char *dft_ttytype = NULL;
|
||||
|
||||
if (err)
|
||||
goto leave;
|
||||
else if (env_tty)
|
||||
{
|
||||
snprintf (dft_ttyname, sizeof (dft_ttyname), "%s", env_tty);
|
||||
free (env_tty);
|
||||
}
|
||||
else
|
||||
rc = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname));
|
||||
|
||||
/* Even though isatty() returns 1, ttyname_r() may fail in many
|
||||
|
@ -222,6 +222,7 @@ g13_new (void **engine, const char *file_name, const char *home_dir,
|
||||
const char *argv[5];
|
||||
char *dft_display = NULL;
|
||||
char dft_ttyname[64];
|
||||
char *env_tty = NULL;
|
||||
char *dft_ttytype = NULL;
|
||||
char *optstr;
|
||||
|
||||
@ -284,10 +285,19 @@ g13_new (void **engine, const char *file_name, const char *home_dir,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (isatty (1))
|
||||
err = _gpgme_getenv ("GPG_TTY", &env_tty);
|
||||
if (isatty (1) || env_tty || err)
|
||||
{
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
if (err)
|
||||
goto leave;
|
||||
else if (env_tty)
|
||||
{
|
||||
snprintf (dft_ttyname, sizeof (dft_ttyname), "%s", env_tty);
|
||||
free (env_tty);
|
||||
}
|
||||
else
|
||||
rc = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname));
|
||||
|
||||
/* Even though isatty() returns 1, ttyname_r() may fail in many
|
||||
|
@ -454,6 +454,7 @@ gpg_new (void **engine, const char *file_name, const char *home_dir,
|
||||
char *dft_display = NULL;
|
||||
char dft_ttyname[64];
|
||||
char *dft_ttytype = NULL;
|
||||
char *env_tty = NULL;
|
||||
|
||||
gpg = calloc (1, sizeof *gpg);
|
||||
if (!gpg)
|
||||
@ -560,10 +561,19 @@ gpg_new (void **engine, const char *file_name, const char *home_dir,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (isatty (1))
|
||||
rc = _gpgme_getenv ("GPG_TTY", &env_tty);
|
||||
if (isatty (1) || env_tty || rc)
|
||||
{
|
||||
int err;
|
||||
int err = 0;
|
||||
|
||||
if (rc)
|
||||
goto leave;
|
||||
else if (env_tty)
|
||||
{
|
||||
snprintf (dft_ttyname, sizeof (dft_ttyname), "%s", env_tty);
|
||||
free (env_tty);
|
||||
}
|
||||
else
|
||||
err = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname));
|
||||
|
||||
/* Even though isatty() returns 1, ttyname_r() may fail in many
|
||||
|
@ -253,6 +253,7 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir,
|
||||
#endif
|
||||
char *dft_display = NULL;
|
||||
char dft_ttyname[64];
|
||||
char *env_tty = NULL;
|
||||
char *dft_ttytype = NULL;
|
||||
char *optstr;
|
||||
|
||||
@ -410,10 +411,19 @@ gpgsm_new (void **engine, const char *file_name, const char *home_dir,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (isatty (1))
|
||||
err = _gpgme_getenv ("GPG_TTY", &env_tty);
|
||||
if (isatty (1) || env_tty || err)
|
||||
{
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
if (err)
|
||||
goto leave;
|
||||
else if (env_tty)
|
||||
{
|
||||
snprintf (dft_ttyname, sizeof (dft_ttyname), "%s", env_tty);
|
||||
free (env_tty);
|
||||
}
|
||||
else
|
||||
rc = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname));
|
||||
|
||||
/* Even though isatty() returns 1, ttyname_r() may fail in many
|
||||
|
@ -248,6 +248,7 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir,
|
||||
engine_uiserver_t uiserver;
|
||||
char *dft_display = NULL;
|
||||
char dft_ttyname[64];
|
||||
char *env_tty = NULL;
|
||||
char *dft_ttytype = NULL;
|
||||
char *optstr;
|
||||
|
||||
@ -330,10 +331,19 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (isatty (1))
|
||||
err = _gpgme_getenv ("GPG_TTY", &env_tty);
|
||||
if (isatty (1) || env_tty || err)
|
||||
{
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
if (err)
|
||||
goto leave;
|
||||
else if (env_tty)
|
||||
{
|
||||
snprintf (dft_ttyname, sizeof (dft_ttyname), "%s", env_tty);
|
||||
free (env_tty);
|
||||
}
|
||||
else
|
||||
rc = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname));
|
||||
|
||||
/* Even though isatty() returns 1, ttyname_r() may fail in many
|
||||
|
Loading…
Reference in New Issue
Block a user