diff options
Diffstat (limited to 'g10/passphrase.c')
-rw-r--r-- | g10/passphrase.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c index 10574ec6a..17e259695 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -159,6 +159,19 @@ set_passphrase_from_string(const char *pass) strcpy (fd_passwd, pass); } +void +set_passphrase_from_environment_variable(const char *envvar) +{ + const char *val = getenv(envvar); + if (val == NULL) + val = ""; + xfree (fd_passwd); + fd_passwd = xmalloc_secure(strlen(val)+1); + strcpy (fd_passwd, val); + /* clean up sensitive environment variable to avoid accidental + propagation: */ + unsetenv(envvar); +} void read_passphrase_from_fd( int fd ) |