diff options
author | Werner Koch <wk@gnupg.org> | 2004-10-04 15:21:37 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2004-10-04 15:21:37 +0200 |
commit | ad5d5fce4fd8a254f00cb18a983a2fea23a33e7e (patch) | |
tree | bef23199a80e5657cce97bf357992aafc9f25f10 /sm/misc.c | |
parent | Typo fixes. (diff) | |
download | gnupg2-ad5d5fce4fd8a254f00cb18a983a2fea23a33e7e.tar.xz gnupg2-ad5d5fce4fd8a254f00cb18a983a2fea23a33e7e.zip |
(setup_pinentry_env): Try hard to set a default for GPG_TTY.
Diffstat (limited to 'sm/misc.c')
-rw-r--r-- | sm/misc.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -30,7 +30,7 @@ #endif #include "gpgsm.h" - +#include "i18n.h" /* Setup the environment so that the pinentry is able to get all required information. This is used prior to an exec of the @@ -42,8 +42,23 @@ setup_pinentry_env (void) if (opt.display) setenv ("DISPLAY", opt.display, 1); + + /* Try to make sure that GPG_TTY has been set. This is needed if we + call for example the protect-tools with redirected stdin and thus + it won't be able to ge a default by itself. Try to do it here + but print a warning. */ if (opt.ttyname) setenv ("GPG_TTY", opt.ttyname, 1); + else if (!(lc=getenv ("GPG_TTY")) || !*lc) + { + log_error (_("GPG_TTY has not been set - " + "using maybe bogus default\n")); + lc = ttyname (0); + if (!lc) + lc = "/dev/tty"; + setenv ("GPG_TTY", lc, 1); + } + if (opt.ttytype) setenv ("TERM", opt.ttytype, 1); |