diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2018-11-20 19:01:17 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2018-11-20 19:01:17 +0000 |
commit | f12dd99bc33eefb702280bdaed6156a57d867be1 (patch) | |
tree | 3ced903ff59efa46be0b01f4cae665cd9c974b15 /crypto/getenv.c | |
parent | 43a67e02da9068b94df1c07fc6f0d70bafd9263b (diff) |
Diffstat (limited to 'crypto/getenv.c')
-rw-r--r-- | crypto/getenv.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/crypto/getenv.c b/crypto/getenv.c new file mode 100644 index 0000000000000..53f1dfd457a9c --- /dev/null +++ b/crypto/getenv.c @@ -0,0 +1,31 @@ +/* + * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +#include <stdlib.h> +#include "cryptlib.h" + +char *ossl_safe_getenv(const char *name) +{ +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +# if __GLIBC_PREREQ(2, 17) +# define SECURE_GETENV + return secure_getenv(name); +# endif +#endif + +#ifndef SECURE_GETENV + if (OPENSSL_issetugid()) + return NULL; + return getenv(name); +#endif +} |