File tree 1 file changed +11
-2
lines changed 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -67,10 +67,19 @@ pub fn try_init_ssl_cert_env_vars() -> bool {
67
67
// we won't be overwriting existing env variables because if they're valid probe() will have
68
68
// returned them unchanged
69
69
if let Some ( path) = & cert_file {
70
- env :: set_var ( ENV_CERT_FILE , path) ;
70
+ put ( ENV_CERT_FILE , path) ;
71
71
}
72
72
if let Some ( path) = & cert_dir {
73
- env:: set_var ( ENV_CERT_DIR , path) ;
73
+ put ( ENV_CERT_DIR , path) ;
74
+ }
75
+
76
+ fn put ( var : & str , path : & Path ) {
77
+ // Avoid calling `setenv` if the variable already has the same contents. This avoids a
78
+ // crash when called from out of perl <5.38 (Debian Bookworm is at 5.36), as old versions
79
+ // of perl tend to manipulate the `environ` pointer directly.
80
+ if env:: var_os ( var) . as_deref ( ) != Some ( path. as_os_str ( ) ) {
81
+ env:: set_var ( var, path) ;
82
+ }
74
83
}
75
84
76
85
cert_file. is_some ( ) || cert_dir. is_some ( )
You can’t perform that action at this time.
0 commit comments