1 /* misc.c - Miscellaneous fucntions
2 * Copyright (C) 2004 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
35 /* Setup the environment so that the pinentry is able to get all
36 required information. This is used prior to an exec of the
39 setup_pinentry_env (void)
41 #ifndef HAVE_W32_SYSTEM
45 setenv ("DISPLAY", opt
.display
, 1);
47 /* Try to make sure that GPG_TTY has been set. This is needed if we
48 call for example the protect-tools with redirected stdin and thus
49 it won't be able to ge a default by itself. Try to do it here
50 but print a warning. */
52 setenv ("GPG_TTY", opt
.ttyname
, 1);
53 else if (!(lc
=getenv ("GPG_TTY")) || !*lc
)
55 log_error (_("GPG_TTY has not been set - "
56 "using maybe bogus default\n"));
60 setenv ("GPG_TTY", lc
, 1);
64 setenv ("TERM", opt
.ttytype
, 1);
67 setenv ("LC_CTYPE", opt
.lc_ctype
, 1);
68 #if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
69 else if ( (lc
= setlocale (LC_CTYPE
, "")) )
70 setenv ("LC_CTYPE", lc
, 1);
74 setenv ("LC_MESSAGES", opt
.lc_messages
, 1);
75 #if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
76 else if ( (lc
= setlocale (LC_MESSAGES
, "")) )
77 setenv ("LC_MESSAGES", lc
, 1);
81 setenv ("XAUTHORITY", opt
.xauthority
, 1);
83 if (opt
.pinentry_user_data
)
84 setenv ("PINENTRY_USER_DATA", opt
.pinentry_user_data
, 1);
86 #endif /*!HAVE_W32_SYSTEM*/