1GETENV(3)                  Linux Programmer's Manual                 GETENV(3)
2
3
4

NAME

6       getenv, secure_getenv - get an environment variable
7

SYNOPSIS

9       #include <stdlib.h>
10
11       char *getenv(const char *name);
12
13       char *secure_getenv(const char *name);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       secure_getenv(): _GNU_SOURCE
18

DESCRIPTION

20       The  getenv()  function searches the environment list to find the envi‐
21       ronment variable name, and returns a pointer to the corresponding value
22       string.
23
24       The  GNU-specific secure_getenv() function is just like getenv() except
25       that it returns NULL in cases where  "secure  execution"  is  required.
26       Secure  execution  is  required  if one of the following conditions was
27       true when the program run by the calling process was loaded:
28
29       *  the process's effective user ID did not match its real  user  ID  or
30          the  process's  effective  group  ID did not match its real group ID
31          (typically this is the result of executing  a  set-user-ID  or  set-
32          group-ID program);
33
34       *  the effective capability bit was set on the executable file; or
35
36       *  the process has a nonempty permitted capability set.
37
38       Secure  execution may also required if triggered by some Linux security
39       modules.
40
41       The secure_getenv() function is intended  for  use  in  general-purpose
42       libraries  to  avoid vulnerabilities that could occur if set-user-ID or
43       set-group-ID programs accidentally trusted the environment.
44

RETURN VALUE

46       The getenv() function returns a pointer to the value  in  the  environ‐
47       ment, or NULL if there is no match.
48

VERSIONS

50       secure_getenv() first appeared in glibc 2.17.
51

CONFORMING TO

53       getenv(): SVr4, POSIX.1-2001, 4.3BSD, C89, C99.
54
55       secure_getenv() is a GNU extension.
56

NOTES

58       The strings in the environment list are of the form name=value.
59
60       As typically implemented, getenv() returns a pointer to a string within
61       the environment list.  The caller must take care  not  to  modify  this
62       string, since that would change the environment of the process.
63
64       The  implementation  of  getenv() is not required to be reentrant.  The
65       string pointed to by the return value of  getenv()  may  be  statically
66       allocated,  and  can  be  modified  by  a  subsequent call to getenv(),
67       putenv(3), setenv(3), or unsetenv(3).
68
69       The "secure execution" mode of secure_getenv()  is  controlled  by  the
70       AT_SECURE flag contained in the auxiliary vector passed from the kernel
71       to user space.
72

SEE ALSO

74       clearenv(3), getauxval(3), putenv(3), setenv(3), unsetenv(3), capabili‐
75       ties(7), environ(7)
76

COLOPHON

78       This  page  is  part of release 3.53 of the Linux man-pages project.  A
79       description of the project, and information about reporting  bugs,  can
80       be found at http://www.kernel.org/doc/man-pages/.
81
82
83
84GNU                               2012-08-14                         GETENV(3)
Impressum