2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" and Copyright (C) 2007, 2012 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" References consulted:
8 .\" Linux libc source code
9 .\" Lewine's "POSIX Programmer's Guide" (O'Reilly & Associates, 1991)
11 .\" Modified Sat Jul 24 19:30:29 1993 by Rik Faith (faith@cs.unc.edu)
12 .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl)
14 .TH getenv 3 (date) "Linux man-pages (unreleased)"
16 getenv, secure_getenv \- get an environment variable
19 .RI ( libc ", " \-lc )
22 .B #include <stdlib.h>
24 .BI "char *getenv(const char *" name );
25 .BI "char *secure_getenv(const char *" name );
29 Feature Test Macro Requirements for glibc (see
30 .BR feature_test_macros (7)):
40 function searches the environment list to find the
43 and returns a pointer to the corresponding
51 except that it returns NULL in cases where "secure execution" is required.
52 Secure execution is required if one of the following conditions
53 was true when the program run by the calling process was loaded:
55 the process's effective user ID did not match its real user ID or
56 the process's effective group ID did not match its real group ID
57 (typically this is the result of executing a set-user-ID or
58 set-group-ID program);
60 the effective capability bit was set on the executable file; or
62 the process has a nonempty permitted capability set.
64 Secure execution may also be required if triggered
65 by some Linux security modules.
69 function is intended for use in general-purpose libraries
70 to avoid vulnerabilities that could occur if
71 set-user-ID or set-group-ID programs accidentally
72 trusted the environment.
76 function returns a pointer to the value in the
77 environment, or NULL if there is no match.
80 first appeared in glibc 2.17.
82 For an explanation of the terms used in this section, see
90 Interface Attribute Value
94 T} Thread safety MT-Safe env
101 POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
106 The strings in the environment list are of the form \fIname=value\fP.
108 As typically implemented,
110 returns a pointer to a string within the environment list.
111 The caller must take care not to modify this string,
112 since that would change the environment of the process.
114 The implementation of
116 is not required to be reentrant.
117 The string pointed to by the return value of
119 may be statically allocated,
120 and can be modified by a subsequent call to
127 The "secure execution" mode of
131 flag contained in the auxiliary vector passed from the kernel to user space.
138 .BR capabilities (7),