GETENV(3C)              Standard C Library Functions              GETENV(3C)
NAME
     getenv, 
secure_getenv - return value for environment name
LIBRARY
     Standard C Library (libc, -lc)
SYNOPSIS
     #include <stdlib.h>     char *     getenv(
const char *name);     
char *     secure_getenv(
const char *name);
DESCRIPTION
     The 
getenv() function searches the environment list (see 
environ(7))
     for a string of the form 
name=
Value and, if the string is present,
     returns a pointer to the 
value in the current environment.
     The 
secure_getenv() function behaves similarly; however, evaluates the
     conditions that the process was executed under.  If the process was
     executed in a way that it is considered setuid, setgid, or raised its
     privileges, that is the 
issetugid(2) function would return true, then
     the 
secure_getenv() function will always return NULL.  This is designed
     for programs that want to ensure they do not trust potentially
     malicious user input while executed with elevated capabilities.  In all
     other respects, the 
secure_getenv() function is identical to the     
getenv() function.
RETURN VALUES
     If successful, the 
getenv() and 
secure_getenv() functions return a
     pointer to the 
value in the current environment; otherwise, they
     returns a NULL pointer.
USAGE
     The 
getenv() function can be safely called from a multithreaded
     application.  Care must be exercised when using both 
getenv() and     
putenv(3C) in a multithreaded application.  These functions examine and
     modify the environment list, which is shared by all threads in an
     application.  The system prevents the list from being accessed
     simultaneously by two different threads.  It does not, however, prevent
     two threads from successively accessing the environment list using     
getenv() or 
putenv(3C)INTERFACE STABILITY
     CommittedMT-LEVEL     SafeSEE ALSO
     exec(2), 
issetugid(2), 
putenv(3C), 
attributes(7), 
environ(7),     
standards(7)illumos                       January 19, 2025                       illumos