Skip to content

Commit c4e81d0

Browse files
committed
Auto merge of #3304 - CuriouslyCurious:secure_getenv_linux, r=JohnTitor
Add secure_getenv function for Linux variants This adds the [`secure_getenv`](https://www.gnu.org/software/libc/manual/html_node/Environment-Access.html#index-secure_005fgetenv) function for Linux variants as it is supported in both GNU libc (2.17+) and musl ([1.1.24+](https://git.musl-libc.org/cgit/musl/commit/?h=v1.1.24&id=ea9525c8bcf6170df59364c4bcd616de1acf8703)). It is recommended to be used over the regular `getenv`, and there is a [standing issue](rust-lang/rust#92558) for the Rust library to use it instead. I can't properly test it on my machine as there is some funky stuff going on with musl. I'll open up a [separate issue](#3305) with the output as it doesn't concern this fairly simple change.
2 parents 5d5a855 + 6e06e46 commit c4e81d0

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

libc-test/semver/linux.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3414,6 +3414,7 @@ sched_setparam
34143414
sched_setscheduler
34153415
sctp_assoc_t
34163416
seccomp_data
3417+
secure_getenv
34173418
seed48
34183419
seekdir
34193420
sem_close

src/unix/linux_like/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,7 @@ extern "C" {
17361736
pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: ::c_int) -> ::c_int;
17371737
pub fn ptsname_r(fd: ::c_int, buf: *mut ::c_char, buflen: ::size_t) -> ::c_int;
17381738
pub fn clearenv() -> ::c_int;
1739+
pub fn secure_getenv(name: *const ::c_char) -> *mut ::c_char;
17391740
pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int)
17401741
-> ::c_int;
17411742
pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int;

0 commit comments

Comments
 (0)