diff options
author | Jack Lloyd <[email protected]> | 2018-12-29 09:15:28 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-29 09:15:28 -0500 |
commit | 30f79bda793634bb1891e61ee4ea998a64c9b13b (patch) | |
tree | 5e0f1b6bbbce02e790504cd01064ade94d17d58e /src/lib/utils/os_utils.h | |
parent | 69cad041fd2bf9bf09ca378537d28983a4fce03a (diff) |
Add OS::read_env_variable
Combines the priv check and the getenv call on one.
Diffstat (limited to 'src/lib/utils/os_utils.h')
-rw-r--r-- | src/lib/utils/os_utils.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/utils/os_utils.h b/src/lib/utils/os_utils.h index 24cbdd5a3..a6044dd18 100644 --- a/src/lib/utils/os_utils.h +++ b/src/lib/utils/os_utils.h @@ -80,6 +80,14 @@ size_t get_memory_locking_limit(); size_t system_page_size(); /** +* Read the value of an environment variable. Return nullptr if +* no such variable is set. If the process seems to be running in +* a privileged state (such as setuid) then always returns nullptr, +* similiar to glibc's secure_getenv. +*/ +const char* read_env_variable(const std::string& var_name); + +/** * Request so many bytes of page-aligned RAM locked into memory using * mlock, VirtualLock, or similar. Returns null on failure. The memory * returned is zeroed. Free it with free_locked_pages. |