From 1c9b8a029b351e634c9e7849ece614338dc37b8c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 4 Mar 2015 14:14:05 -0800 Subject: [PATCH] Cut down on unstable features in openssl-sys * Move from `old_path` to `path` (leveraging the `fs` feature as well) * Move from `StaticMutex` to `Mutex<()>` as they're dynamically initialized --- openssl-sys/build.rs | 2 +- openssl-sys/src/lib.rs | 10 +++++----- openssl-sys/src/probe.rs | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs index ce807dd2..7b86e782 100644 --- a/openssl-sys/build.rs +++ b/openssl-sys/build.rs @@ -1,4 +1,4 @@ -#![feature(env, path)] +#![feature(path)] extern crate "pkg-config" as pkg_config; extern crate gcc; diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 6801d053..6d9ffb39 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] #![allow(dead_code)] -#![feature(core, old_io, old_path, std_misc, env)] +#![feature(path, fs)] #![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/openssl-sys")] extern crate libc; @@ -11,7 +11,7 @@ extern crate "libressl-pnacl-sys" as _for_linkage; use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t}; use std::mem; use std::ptr; -use std::sync::{StaticMutex, MutexGuard, MUTEX_INIT}; +use std::sync::{Mutex, MutexGuard}; use std::sync::{Once, ONCE_INIT}; pub type ASN1_INTEGER = c_void; @@ -193,7 +193,7 @@ pub const X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: c_int = 45; pub const X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: c_int = 53; pub const X509_V_OK: c_int = 0; -static mut MUTEXES: *mut Vec = 0 as *mut Vec; +static mut MUTEXES: *mut Vec> = 0 as *mut Vec>; static mut GUARDS: *mut Vec>> = 0 as *mut Vec>>; extern fn locking_function(mode: c_int, n: c_int, _file: *const c_char, @@ -220,11 +220,11 @@ pub fn init() { let num_locks = CRYPTO_num_locks(); let mut mutexes = Box::new(Vec::new()); for _ in 0..num_locks { - mutexes.push(MUTEX_INIT); + mutexes.push(Mutex::new(())); } MUTEXES = mem::transmute(mutexes); let guards: Box>>> = - Box::new(range(0, num_locks).map(|_| None).collect()); + Box::new((0..num_locks).map(|_| None).collect()); GUARDS = mem::transmute(guards); CRYPTO_set_locking_callback(locking_function); diff --git a/openssl-sys/src/probe.rs b/openssl-sys/src/probe.rs index dcbefb6d..8163f97a 100644 --- a/openssl-sys/src/probe.rs +++ b/openssl-sys/src/probe.rs @@ -1,16 +1,17 @@ use std::env; -use std::old_io::fs::PathExtensions; +use std::fs::PathExt; +use std::path::PathBuf; pub struct ProbeResult { - pub cert_file: Option, - pub cert_dir: Option, + pub cert_file: Option, + pub cert_dir: Option, } /// Probe the system for the directory in which CA certificates should likely be /// found. /// /// This will only search known system locations. -pub fn find_certs_dirs() -> Vec { +pub fn find_certs_dirs() -> Vec { // see http://gagravarr.org/writing/openssl-certs/others.shtml [ "/var/ssl", @@ -23,7 +24,7 @@ pub fn find_certs_dirs() -> Vec { "/etc/openssl", "/etc/pki/tls", "/etc/ssl", - ].iter().map(|s| Path::new(*s)).filter(|p| { + ].iter().map(|s| PathBuf::new(*s)).filter(|p| { p.exists() }).collect() } @@ -39,7 +40,7 @@ pub fn init_ssl_cert_env_vars() { None => {} } - fn put(var: &str, path: Path) { + fn put(var: &str, path: PathBuf) { // Don't stomp over what anyone else has set match env::var(var) { Ok(..) => {} @@ -50,8 +51,8 @@ pub fn init_ssl_cert_env_vars() { pub fn probe() -> ProbeResult { let mut result = ProbeResult { - cert_file: env::var("SSL_CERT_FILE").ok().map(Path::new), - cert_dir: env::var("SSL_CERT_DIR").ok().map(Path::new), + cert_file: env::var_os("SSL_CERT_FILE").map(|s| PathBuf::new(&s)), + cert_dir: env::var_os("SSL_CERT_DIR").map(|s| PathBuf::new(&s)), }; for certs_dir in find_certs_dirs().iter() { // cert.pem looks to be an openssl 1.0.1 thing, while @@ -65,7 +66,7 @@ pub fn probe() -> ProbeResult { result } -fn try(dst: &mut Option, val: Path) { +fn try(dst: &mut Option, val: PathBuf) { if dst.is_none() && val.exists() { *dst = Some(val); }