Initialization function sets environment variables
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 450
- Avg merge
- 11m
- Merged PRs (30d)
- 1
Description
This function is called by pretty much everything in this crate.
fn init() {
static INIT: Once = Once::new();
INIT.call_once(|| {
openssl_env_init();
});
raw::init();
}
The problem is that openssl_env_init sets environment variables.
pub fn try_init_ssl_cert_env_vars() -> bool {
let ProbeResult { cert_file, cert_dir } = probe();
// we won't be overwriting existing env variables because if they're valid probe() will have
// returned them unchanged
if let Some(path) = &cert_file {
env::set_var(ENV_CERT_FILE, path);
}
if let Some(path) = &cert_dir {
env::set_var(ENV_CERT_DIR, path);
}
cert_file.is_some() || cert_dir.is_some()
}
This is a problem because set_var is unsound in multi-threaded programs, see https://internals.rust-lang.org/t/synchronized-ffi-access-to-posix-environment-variable-functions/15475?u=xfix. When git is initialized there is no guarantee that there aren't multiple threads involved.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing init through openssl_env_init and try_init_ssl_cert_env_vars. Determine how initialization can retain certificate discovery without calling set_var in a multithreaded process; done means the unsafe environment mutation concern is addressed without losing discovered certificate paths. No file or test names are provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100