Skip to content

Commit e0e4dd3

Browse files
committed
- Adds component subcommand
- Fixes inconsistent 8-column tab indentation - Convert British spellings to US
1 parent 95f38e8 commit e0e4dd3

22 files changed

+667
-486
lines changed

LICENSE-APACHE

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.
193193
You may obtain a copy of the License at
194194

195-
http://www.apache.org/licenses/LICENSE-2.0
195+
http://www.apache.org/licenses/LICENSE-2.0
196196

197197
Unless required by applicable law or agreed to in writing, software
198198
distributed under the License is distributed on an "AS IS" BASIS,

rustup-init.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ main() {
3232

3333
local _ext=""
3434
case "$_arch" in
35-
*windows*)
36-
_ext=".exe"
37-
;;
35+
*windows*)
36+
_ext=".exe"
37+
;;
3838
esac
3939

4040
local _url="$RUSTUP_UPDATE_ROOT/$_arch/rustup-init$_ext"
@@ -48,9 +48,9 @@ main() {
4848
ensure curl -sSfL "$_url" -o "$_file"
4949
ensure chmod u+x "$_file"
5050
if [ ! -x "$_file" ]; then
51-
echo "Cannot execute $_file (likely because of mounting /tmp as noexec)."
52-
echo "Please copy the file to a location where you can execute binaries and run ./rustup-init$_ext."
53-
exit 1
51+
echo "Cannot execute $_file (likely because of mounting /tmp as noexec)."
52+
echo "Please copy the file to a location where you can execute binaries and run ./rustup-init$_ext."
53+
exit 1
5454
fi
5555

5656
# check if we have to use /dev/tty to prompt the user
@@ -149,9 +149,9 @@ get_architecture() {
149149
local _ostype="${_ostype}eabihf"
150150
;;
151151

152-
aarch64)
153-
local _cputype=aarch64
154-
;;
152+
aarch64)
153+
local _cputype=aarch64
154+
;;
155155

156156
x86_64 | x86-64 | x64 | amd64)
157157
local _cputype=x86_64

src/ca-loader/src/sys/macos.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,34 @@ impl IntoIterator for CertBundle {
2020
type IntoIter = CertIter;
2121

2222
fn into_iter(self) -> Self::IntoIter {
23-
CertIter { it: Box::new(self.rv.into_iter()) }
23+
CertIter { it: Box::new(self.rv.into_iter()) }
2424
}
2525
}
2626

2727
impl Iterator for CertIter {
2828
type Item = CertItem;
2929

3030
fn next(&mut self) -> Option<CertItem> {
31-
if let Some(res) = self.it.next() {
32-
if let Some(ref rref) = res.reference {
33-
match rref {
34-
&Reference::Certificate(ref cert) => return Some(CertItem::Blob(cert.to_der())),
35-
_ => ()
36-
}
37-
}
38-
return self.next();
39-
}
40-
None
31+
if let Some(res) = self.it.next() {
32+
if let Some(ref rref) = res.reference {
33+
match rref {
34+
&Reference::Certificate(ref cert) => return Some(CertItem::Blob(cert.to_der())),
35+
_ => ()
36+
}
37+
}
38+
return self.next();
39+
}
40+
None
4141
}
4242
}
4343

4444
impl CertBundle {
4545
pub fn new() -> Result<CertBundle, ()> {
46-
let root_kc = try!(SecKeychain::open("/System/Library/Keychains/SystemRootCertificates.keychain").map_err(|_| ()));
47-
let chains = [ root_kc ];
48-
let mut opts = ItemSearchOptions::new();
49-
let opts = opts.keychains(&chains).class(ItemClass::Certificate).load_refs(true).limit(i32::MAX as i64);
50-
let rv = try!(opts.search().map_err(|_| ()));
51-
Ok(CertBundle { rv: rv })
46+
let root_kc = try!(SecKeychain::open("/System/Library/Keychains/SystemRootCertificates.keychain").map_err(|_| ()));
47+
let chains = [ root_kc ];
48+
let mut opts = ItemSearchOptions::new();
49+
let opts = opts.keychains(&chains).class(ItemClass::Certificate).load_refs(true).limit(i32::MAX as i64);
50+
let rv = try!(opts.search().map_err(|_| ()));
51+
Ok(CertBundle { rv: rv })
5252
}
5353
}

src/ca-loader/src/sys/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
cfg_if! {
22
if #[cfg(windows)] {
3-
mod windows;
4-
pub use self::windows::CertBundle;
3+
mod windows;
4+
pub use self::windows::CertBundle;
55
} else if #[cfg(target_os = "macos")] {
6-
mod macos;
7-
pub use self::macos::CertBundle;
6+
mod macos;
7+
pub use self::macos::CertBundle;
88
} else if #[cfg(unix)] {
9-
mod unix;
10-
pub use self::unix::CertBundle;
9+
mod unix;
10+
pub use self::unix::CertBundle;
1111
} else {
12-
// Unknown
12+
// Unknown
1313
}
1414
}

src/ca-loader/src/sys/unix.rs

+106-106
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,78 @@ use super::super::CertItem;
88

99
cfg_if! {
1010
if #[cfg(any(target_os = "android", target_os = "solaris"))] {
11-
use std::fs::{read_dir, ReadDir};
12-
13-
pub struct CertBundle(&'static str);
14-
15-
pub struct CertIter(&'static str, Option<ReadDir>);
16-
17-
impl IntoIterator for CertBundle {
18-
type Item = CertItem;
19-
type IntoIter = CertIter;
20-
21-
fn into_iter(self) -> Self::IntoIter {
22-
if let Ok(dir) = read_dir(self.0) {
23-
CertIter(self.0, Some(dir))
24-
} else {
25-
CertIter(self.0, None)
26-
}
27-
}
28-
}
29-
30-
impl Iterator for CertIter {
31-
type Item = CertItem;
32-
33-
fn next(&mut self) -> Option<Self::Item> {
34-
match self.1 {
35-
None => return None,
36-
Some(ref mut dir) => {
37-
match dir.next() {
38-
None => return None,
39-
Some(Err(_)) => return None,
40-
Some(Ok(ref de)) => {
41-
if let Ok(ftyp) = de.file_type() {
42-
if !ftyp.is_dir() {
43-
if let Some(s) = de.file_name().to_str() {
44-
let mut full_name = String::from(self.0);
45-
full_name.push('/');
46-
full_name.push_str(s);
47-
return Some(CertItem::File(full_name));
48-
}
49-
}
50-
}
51-
}
52-
}
53-
}
54-
}
55-
self.next()
56-
}
57-
}
58-
59-
impl CertBundle {
60-
pub fn new() -> Result<CertBundle, ()> {
61-
Ok(CertBundle(try!(sys_path())))
62-
}
63-
}
11+
use std::fs::{read_dir, ReadDir};
12+
13+
pub struct CertBundle(&'static str);
14+
15+
pub struct CertIter(&'static str, Option<ReadDir>);
16+
17+
impl IntoIterator for CertBundle {
18+
type Item = CertItem;
19+
type IntoIter = CertIter;
20+
21+
fn into_iter(self) -> Self::IntoIter {
22+
if let Ok(dir) = read_dir(self.0) {
23+
CertIter(self.0, Some(dir))
24+
} else {
25+
CertIter(self.0, None)
26+
}
27+
}
28+
}
29+
30+
impl Iterator for CertIter {
31+
type Item = CertItem;
32+
33+
fn next(&mut self) -> Option<Self::Item> {
34+
match self.1 {
35+
None => return None,
36+
Some(ref mut dir) => {
37+
match dir.next() {
38+
None => return None,
39+
Some(Err(_)) => return None,
40+
Some(Ok(ref de)) => {
41+
if let Ok(ftyp) = de.file_type() {
42+
if !ftyp.is_dir() {
43+
if let Some(s) = de.file_name().to_str() {
44+
let mut full_name = String::from(self.0);
45+
full_name.push('/');
46+
full_name.push_str(s);
47+
return Some(CertItem::File(full_name));
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}
55+
self.next()
56+
}
57+
}
58+
59+
impl CertBundle {
60+
pub fn new() -> Result<CertBundle, ()> {
61+
Ok(CertBundle(try!(sys_path())))
62+
}
63+
}
6464
} else {
65-
use std::option;
65+
use std::option;
6666

67-
pub struct CertBundle(Option<CertItem>);
67+
pub struct CertBundle(Option<CertItem>);
6868

69-
impl IntoIterator for CertBundle {
70-
type Item = CertItem;
71-
type IntoIter = option::IntoIter<CertItem>;
69+
impl IntoIterator for CertBundle {
70+
type Item = CertItem;
71+
type IntoIter = option::IntoIter<CertItem>;
7272

73-
fn into_iter(self) -> Self::IntoIter {
74-
self.0.into_iter()
75-
}
76-
}
73+
fn into_iter(self) -> Self::IntoIter {
74+
self.0.into_iter()
75+
}
76+
}
7777

78-
impl CertBundle {
79-
pub fn new() -> Result<CertBundle, ()> {
80-
Ok(CertBundle(Some(CertItem::File(try!(sys_path()).to_string()))))
81-
}
82-
}
78+
impl CertBundle {
79+
pub fn new() -> Result<CertBundle, ()> {
80+
Ok(CertBundle(Some(CertItem::File(try!(sys_path()).to_string()))))
81+
}
82+
}
8383
}
8484
}
8585

@@ -91,50 +91,50 @@ pub fn sys_path() -> Result<&'static str, ()> {
9191
// the contents of struct utsname on input, and will fill it with
9292
// properly NUL-terminated strings on successful return.
9393
unsafe {
94-
let mut uts = mem::uninitialized::<libc::utsname>();
95-
96-
if libc::uname(&mut uts) < 0 {
97-
return Err(());
98-
}
99-
let sysname = try!(CStr::from_ptr(uts.sysname.as_ptr()).to_str().map_err(|_| ()));
100-
let release = try!(CStr::from_ptr(uts.release.as_ptr()).to_str().map_err(|_| ()));
101-
let path = match sysname {
102-
"FreeBSD" | "OpenBSD" => "/etc/ssl/cert.pem",
103-
"NetBSD" => "/etc/ssl/certs",
104-
"Linux" => linux_distro_guess_ca_path(),
105-
"SunOS" => {
106-
let major = release.split('.').take(1).collect::<String>();
107-
let major = major.parse::<u32>().unwrap_or(5);
108-
let minor = release.split('.').skip(1).take(1).collect::<String>();
109-
let minor = minor.parse::<u32>().unwrap_or(10);
110-
if major < 5 || (major == 5 && minor < 11) {
111-
"/opt/csw/share/cacertificates/mozilla"
112-
} else {
113-
"/etc/certs/CA"
114-
}
115-
}
116-
_ => unimplemented!()
117-
};
118-
Ok(path)
94+
let mut uts = mem::uninitialized::<libc::utsname>();
95+
96+
if libc::uname(&mut uts) < 0 {
97+
return Err(());
98+
}
99+
let sysname = try!(CStr::from_ptr(uts.sysname.as_ptr()).to_str().map_err(|_| ()));
100+
let release = try!(CStr::from_ptr(uts.release.as_ptr()).to_str().map_err(|_| ()));
101+
let path = match sysname {
102+
"FreeBSD" | "OpenBSD" => "/etc/ssl/cert.pem",
103+
"NetBSD" => "/etc/ssl/certs",
104+
"Linux" => linux_distro_guess_ca_path(),
105+
"SunOS" => {
106+
let major = release.split('.').take(1).collect::<String>();
107+
let major = major.parse::<u32>().unwrap_or(5);
108+
let minor = release.split('.').skip(1).take(1).collect::<String>();
109+
let minor = minor.parse::<u32>().unwrap_or(10);
110+
if major < 5 || (major == 5 && minor < 11) {
111+
"/opt/csw/share/cacertificates/mozilla"
112+
} else {
113+
"/etc/certs/CA"
114+
}
115+
}
116+
_ => unimplemented!()
117+
};
118+
Ok(path)
119119
}
120120
}
121121

122122
cfg_if! {
123123
if #[cfg(target_os = "android")] {
124-
fn linux_distro_guess_ca_path() -> &'static str {
125-
"/system/etc/security/cacerts"
126-
}
124+
fn linux_distro_guess_ca_path() -> &'static str {
125+
"/system/etc/security/cacerts"
126+
}
127127
} else {
128-
fn linux_distro_guess_ca_path() -> &'static str {
129-
if let Ok(_debian) = fs::metadata("/etc/debian_version") {
130-
"/etc/ssl/certs/ca-certificates.crt"
131-
} else if let Ok(_rh) = fs::metadata("/etc/redhat-release") {
132-
"/etc/pki/tls/certs/ca-bundle.crt"
133-
} else if let Ok(_suse) = fs::metadata("/etc/SuSE-release") {
134-
"/etc/ssl/ca-bundle.pem"
135-
} else { // fallback
136-
"/etc/pki/tls/cacert.pem"
137-
}
138-
}
128+
fn linux_distro_guess_ca_path() -> &'static str {
129+
if let Ok(_debian) = fs::metadata("/etc/debian_version") {
130+
"/etc/ssl/certs/ca-certificates.crt"
131+
} else if let Ok(_rh) = fs::metadata("/etc/redhat-release") {
132+
"/etc/pki/tls/certs/ca-bundle.crt"
133+
} else if let Ok(_suse) = fs::metadata("/etc/SuSE-release") {
134+
"/etc/ssl/ca-bundle.pem"
135+
} else { // fallback
136+
"/etc/pki/tls/cacert.pem"
137+
}
138+
}
139139
}
140140
}

0 commit comments

Comments
 (0)