diff --git a/perlmod/src/ffi.rs b/perlmod/src/ffi.rs index 9f07bfa..b1ac2e7 100644 --- a/perlmod/src/ffi.rs +++ b/perlmod/src/ffi.rs @@ -412,6 +412,8 @@ extern "C" { pub fn RSPL_substr(orig: *mut SV, off: usize, len: usize) -> *mut SV; pub fn RSPL_defstash() -> *mut HV; + + pub fn RSPL_set_use_safe_putenv(on: libc::c_int); } /// Argument marker for the stack. @@ -577,3 +579,9 @@ where res } + +/// Tell perl to use a "safe" `putenv` call instead of manually manipulating the `environ` +/// variable. Without this, changing environment variables can lead to crashes. +pub fn use_safe_putenv(on: bool) { + unsafe { RSPL_set_use_safe_putenv(on as _) } +} diff --git a/perlmod/src/glue.c b/perlmod/src/glue.c index 96f0618..6e05684 100644 --- a/perlmod/src/glue.c +++ b/perlmod/src/glue.c @@ -454,6 +454,10 @@ extern HV* RSPL_defstash() { return PL_defstash; } +extern void RSPL_set_use_safe_putenv(int on) { + PL_use_safe_putenv = on ? TRUE : FALSE; +} + /* These make are convoluted brainfarts: SVt_NULL undef