diff --git a/acme_common/src/crypto/key_type.rs b/acme_common/src/crypto/key_type.rs index 2207821..5c066ab 100644 --- a/acme_common/src/crypto/key_type.rs +++ b/acme_common/src/crypto/key_type.rs @@ -41,7 +41,7 @@ impl KeyType { Ok(()) } else { let err_msg = format!( - "Incompatible signature algorithm: {} cannot be used with an {} key.", + "incompatible signature algorithm: {} cannot be used with an {} key", alg, self ); Err(err_msg.into()) @@ -75,7 +75,7 @@ impl FromStr for KeyType { "ed25519" => Ok(KeyType::Ed25519), #[cfg(ed448)] "ed448" => Ok(KeyType::Ed448), - _ => Err(format!("{}: unknown algorithm.", s).into()), + _ => Err(format!("{}: unknown algorithm", s).into()), } } } diff --git a/acme_common/src/crypto/openssl_certificate.rs b/acme_common/src/crypto/openssl_certificate.rs index 6593b9d..6e331bb 100644 --- a/acme_common/src/crypto/openssl_certificate.rs +++ b/acme_common/src/crypto/openssl_certificate.rs @@ -16,7 +16,7 @@ const APP_ORG: &str = "ACMEd"; const APP_NAME: &str = "ACMEd"; const X509_VERSION: i32 = 0x02; const CRT_SERIAL_NB_BITS: i32 = 32; -const INVALID_EXT_MSG: &str = "Invalid acmeIdentifier extension."; +const INVALID_EXT_MSG: &str = "invalid acmeIdentifier extension"; fn get_digest(digest: HashFunction, key_pair: &KeyPair) -> MessageDigest { #[cfg(not(any(ed25519, ed448)))] diff --git a/acme_common/src/crypto/openssl_keys.rs b/acme_common/src/crypto/openssl_keys.rs index 6c5b314..591fa40 100644 --- a/acme_common/src/crypto/openssl_keys.rs +++ b/acme_common/src/crypto/openssl_keys.rs @@ -19,17 +19,17 @@ macro_rules! get_key_type { 256 => KeyType::Rsa2048, 512 => KeyType::Rsa4096, s => { - return Err(format!("{}: unsupported RSA key size", s).into()); + return Err(format!("{}: unsupported RSA key size", s * 8).into()); } }, Id::EC => match $key.ec_key()?.group().curve_name() { Some(Nid::X9_62_PRIME256V1) => KeyType::EcdsaP256, Some(Nid::SECP384R1) => KeyType::EcdsaP384, Some(nid) => { - return Err(format!("{:?}: Unsupported EC key.", nid).into()); + return Err(format!("{:?}: unsupported EC key", nid).into()); } None => { - return Err("None: Unsupported EC key".into()); + return Err("unsupported EC key".into()); } }, #[cfg(ed25519)] @@ -37,7 +37,7 @@ macro_rules! get_key_type { #[cfg(ed448)] Id::ED448 => KeyType::Ed448, _ => { - return Err("Unsupported key type".into()); + return Err("unsupported key type".into()); } } }; @@ -167,7 +167,7 @@ impl KeyPair { KeyType::EcdsaP256 => ("P-256", "ES256", Nid::X9_62_PRIME256V1), KeyType::EcdsaP384 => ("P-384", "ES384", Nid::SECP384R1), _ => { - return Err("Not an ECDSA elliptic curve.".into()); + return Err("not an ECDSA elliptic curve".into()); } }; let group = EcGroup::from_curve_name(curve).unwrap(); @@ -209,7 +209,7 @@ impl KeyPair { #[cfg(ed448)] KeyType::Ed448 => "Ed448", _ => { - return Err("Not an EdDSA elliptic curve.".into()); + return Err("not an EdDSA elliptic curve".into()); } }; let x = ""; @@ -273,7 +273,7 @@ pub fn gen_keypair(key_type: KeyType) -> Result { #[cfg(ed448)] KeyType::Ed448 => gen_ed448_pair(), } - .map_err(|_| Error::from(format!("Unable to generate a {} key pair.", key_type)))?; + .map_err(|_| Error::from(format!("unable to generate a {} key pair", key_type)))?; let key_pair = KeyPair { key_type, inner_key: priv_key, diff --git a/acme_common/src/error.rs b/acme_common/src/error.rs index 40690b0..3ab32eb 100644 --- a/acme_common/src/error.rs +++ b/acme_common/src/error.rs @@ -95,13 +95,13 @@ impl From for Error { impl From for Error { fn from(error: glob::PatternError) -> Self { - format!("Pattern error: {}", error).into() + format!("pattern error: {}", error).into() } } impl From for Error { fn from(error: handlebars::TemplateRenderError) -> Self { - format!("Template error: {}", error).into() + format!("template error: {}", error).into() } } diff --git a/acme_common/src/lib.rs b/acme_common/src/lib.rs index 54b79da..d81b884 100644 --- a/acme_common/src/lib.rs +++ b/acme_common/src/lib.rs @@ -14,7 +14,7 @@ macro_rules! exit_match { match $e { Ok(_) => {} Err(e) => { - log::error!("Error: {}", e); + log::error!("error: {}", e); std::process::exit(3); } } diff --git a/acmed/src/account.rs b/acmed/src/account.rs index 63f7ce5..eaf71a7 100644 --- a/acmed/src/account.rs +++ b/acmed/src/account.rs @@ -111,7 +111,7 @@ impl Account { Some(ep) => Ok(ep), None => { let msg = format!( - "{}: unknown endpoint for account {}", + "\"{}\": unknown endpoint for account \"{}\"", endpoint_name, self.name ); Err(msg.into()) @@ -124,7 +124,7 @@ impl Account { Some(ep) => Ok(ep), None => { let msg = format!( - "{}: unknown endpoint for account {}", + "\"{}\": unknown endpoint for account \"{}\"", endpoint_name, self.name ); Err(msg.into()) diff --git a/acmed/src/acme_proto.rs b/acmed/src/acme_proto.rs index b4d2c23..aca6299 100644 --- a/acmed/src/acme_proto.rs +++ b/acmed/src/acme_proto.rs @@ -114,7 +114,7 @@ pub fn request_certificate( let auth = http::get_authorization(endpoint, root_certs, &data_builder, &auth_url) .map_err(HttpError::in_err)?; if let Some(e) = auth.get_error() { - cert.warn(&e.prefix("Error").message); + cert.warn(&e.prefix("error").message); } if auth.status == AuthorizationStatus::Valid { continue; @@ -188,7 +188,7 @@ pub fn request_certificate( domains.as_slice(), ips.as_slice(), )?; - cert.trace(&format!("New CSR:\n{}", csr.to_pem()?)); + cert.trace(&format!("new CSR:\n{}", csr.to_pem()?)); let csr = json!({ "csr": csr.to_der_base64()?, }); @@ -197,7 +197,7 @@ pub fn request_certificate( let order = http::finalize_order(endpoint, root_certs, &data_builder, &order.finalize) .map_err(HttpError::in_err)?; if let Some(e) = order.get_error() { - cert.warn(&e.prefix("Error").message); + cert.warn(&e.prefix("error").message); } // Pool the order in order to see whether or not it is valid @@ -209,14 +209,14 @@ pub fn request_certificate( // Download the certificate let crt_url = order .certificate - .ok_or_else(|| Error::from("No certificate available for download."))?; + .ok_or_else(|| Error::from("no certificate available for download"))?; let data_builder = set_empty_data_builder!(account, endpoint_name); let crt = http::get_certificate(endpoint, root_certs, &data_builder, &crt_url) .map_err(HttpError::in_err)?; storage::write_certificate(&cert.file_manager, &crt.as_bytes())?; cert.info(&format!( - "Certificate renewed (identifiers: {})", + "certificate renewed (identifiers: {})", cert.identifier_list() )); Ok(()) diff --git a/acmed/src/acme_proto/account.rs b/acmed/src/acme_proto/account.rs index 5cff119..e5e9754 100644 --- a/acmed/src/acme_proto/account.rs +++ b/acmed/src/acme_proto/account.rs @@ -15,8 +15,10 @@ macro_rules! create_account_if_does_not_exist { Err(he) => match he { HttpError::ApiError(ref e) => match e.get_acme_type() { AcmeError::AccountDoesNotExist => { - let msg = - format!("account has been dropped by endpoint {}", $endpoint.name); + let msg = format!( + "account has been dropped by endpoint \"{}\"", + $endpoint.name + ); $account.debug(&msg); return register_account($endpoint, $root_certs, $account); } @@ -34,7 +36,7 @@ pub fn register_account( account: &mut BaseAccount, ) -> Result<(), Error> { account.debug(&format!( - "creating account on endpoint {}...", + "creating account on endpoint \"{}\"...", &endpoint.name )); let account_struct = Account::new(account, endpoint); @@ -48,7 +50,7 @@ pub fn register_account( http::new_account(endpoint, root_certs, &data_builder).map_err(HttpError::in_err)?; account.set_account_url(&endpoint.name, &account_url)?; let msg = format!( - "endpoint {}: account {}: the server has not provided an order URL upon account creation", + "endpoint \"{}\": account \"{}\": the server has not provided an order URL upon account creation", &endpoint.name, &account.name ); let order_url = acc_rep.orders.ok_or_else(|| Error::from(&msg))?; @@ -56,7 +58,10 @@ pub fn register_account( account.update_key_hash(&endpoint.name)?; account.update_contacts_hash(&endpoint.name)?; account.save()?; - account.info(&format!("account created on endpoint {}", &endpoint.name)); + account.info(&format!( + "account created on endpoint \"{}\"", + &endpoint.name + )); Ok(()) } @@ -67,7 +72,7 @@ pub fn update_account_contacts( ) -> Result<(), Error> { let endpoint_name = endpoint.name.clone(); account.debug(&format!( - "updating account contacts on endpoint {}...", + "updating account contacts on endpoint \"{}\"...", &endpoint_name )); let new_contacts: Vec = account.contacts.iter().map(|c| c.to_string()).collect(); @@ -84,7 +89,7 @@ pub fn update_account_contacts( account.update_contacts_hash(&endpoint_name)?; account.save()?; account.info(&format!( - "account contacts updated on endpoint {}", + "account contacts updated on endpoint \"{}\"", &endpoint_name )); Ok(()) @@ -97,7 +102,7 @@ pub fn update_account_key( ) -> Result<(), Error> { let endpoint_name = endpoint.name.clone(); account.debug(&format!( - "updating account key on endpoint {}...", + "updating account key on endpoint \"{}\"...", &endpoint_name )); let url = endpoint.dir.key_change.clone(); @@ -132,7 +137,7 @@ pub fn update_account_key( account.update_key_hash(&endpoint_name)?; account.save()?; account.info(&format!( - "account key updated on endpoint {}", + "account key updated on endpoint \"{}\"", &endpoint_name )); Ok(()) diff --git a/acmed/src/acme_proto/http.rs b/acmed/src/acme_proto/http.rs index 925de8c..b069329 100644 --- a/acmed/src/acme_proto/http.rs +++ b/acmed/src/acme_proto/http.rs @@ -55,7 +55,7 @@ where let acc_uri = response .headers() .get(http::HEADER_LOCATION) - .ok_or_else(|| Error::from("No account location found."))?; + .ok_or_else(|| Error::from("no account location found"))?; let acc_uri = http::header_to_string(&acc_uri)?; let acc_resp = response.json::()?; Ok((acc_resp, acc_uri)) @@ -74,7 +74,7 @@ where let order_uri = response .headers() .get(http::HEADER_LOCATION) - .ok_or_else(|| Error::from("No order location found."))?; + .ok_or_else(|| Error::from("no order location found"))?; let order_uri = http::header_to_string(&order_uri)?; let order_resp = response.json::()?; Ok((order_resp, order_uri)) @@ -107,7 +107,7 @@ where { pool_object!( Authorization, - "Authorization", + "authorization", endpoint, root_certs, url, @@ -129,7 +129,7 @@ where { pool_object!( Order, - "Order", + "order", endpoint, root_certs, url, diff --git a/acmed/src/acme_proto/structs/error.rs b/acmed/src/acme_proto/structs/error.rs index c385648..9f4fe53 100644 --- a/acmed/src/acme_proto/structs/error.rs +++ b/acmed/src/acme_proto/structs/error.rs @@ -73,31 +73,31 @@ impl From for AcmeError { impl fmt::Display for AcmeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let msg = match self { - AcmeError::AccountDoesNotExist => "The request specified an account that does not exist", - AcmeError::AlreadyRevoked => "The request specified a certificate to be revoked that has already been revoked", - AcmeError::BadCSR => "The CSR is unacceptable (e.g., due to a short key)", - AcmeError::BadNonce => "The client sent an unacceptable anti-replay nonce", - AcmeError::BadPublicKey => "The JWS was signed by a public key the server does not support", - AcmeError::BadRevocationReason => "The revocation reason provided is not allowed by the server", - AcmeError::BadSignatureAlgorithm => "The JWS was signed with an algorithm the server does not support", + AcmeError::AccountDoesNotExist => "the request specified an account that does not exist", + AcmeError::AlreadyRevoked => "the request specified a certificate to be revoked that has already been revoked", + AcmeError::BadCSR => "the CSR is unacceptable (e.g., due to a short key)", + AcmeError::BadNonce => "the client sent an unacceptable anti-replay nonce", + AcmeError::BadPublicKey => "the JWS was signed by a public key the server does not support", + AcmeError::BadRevocationReason => "the revocation reason provided is not allowed by the server", + AcmeError::BadSignatureAlgorithm => "the JWS was signed with an algorithm the server does not support", AcmeError::Caa => "Certification Authority Authorization (CAA) records forbid the CA from issuing a certificate", - AcmeError::Compound => "Specific error conditions are indicated in the \"subproblems\" array", - AcmeError::Connection => "The server could not connect to validation target", - AcmeError::Dns => "There was a problem with a DNS query during identifier validation", - AcmeError::ExternalAccountRequired => "The request must include a value for the \"externalAccountBinding\" field", - AcmeError::IncorrectResponse => "Response received didn't match the challenge's requirements", - AcmeError::InvalidContact => "A contact URL for an account was invalid", - AcmeError::Malformed => "The request message was malformed", - AcmeError::OrderNotReady => "The request attempted to finalize an order that is not ready to be finalized", - AcmeError::RateLimited => "The request exceeds a rate limit", - AcmeError::RejectedIdentifier => "The server will not issue certificates for the identifier", - AcmeError::ServerInternal => "The server experienced an internal error", - AcmeError::Tls => "The server received a TLS error during validation", - AcmeError::Unauthorized => "The client lacks sufficient authorization", - AcmeError::UnsupportedContact => "A contact URL for an account used an unsupported protocol scheme", - AcmeError::UnsupportedIdentifier => "An identifier is of an unsupported type", - AcmeError::UserActionRequired => "Visit the \"instance\" URL and take actions specified there", - AcmeError::Unknown => "Unknown error", + AcmeError::Compound => "specific error conditions are indicated in the \"subproblems\" array", + AcmeError::Connection => "the server could not connect to validation target", + AcmeError::Dns => "there was a problem with a DNS query during identifier validation", + AcmeError::ExternalAccountRequired => "the request must include a value for the \"externalAccountBinding\" field", + AcmeError::IncorrectResponse => "response received didn't match the challenge's requirements", + AcmeError::InvalidContact => "a contact URL for an account was invalid", + AcmeError::Malformed => "the request message was malformed", + AcmeError::OrderNotReady => "the request attempted to finalize an order that is not ready to be finalized", + AcmeError::RateLimited => "the request exceeds a rate limit", + AcmeError::RejectedIdentifier => "the server will not issue certificates for the identifier", + AcmeError::ServerInternal => "the server experienced an internal error", + AcmeError::Tls => "the server received a TLS error during validation", + AcmeError::Unauthorized => "the client lacks sufficient authorization", + AcmeError::UnsupportedContact => "a contact URL for an account used an unsupported protocol scheme", + AcmeError::UnsupportedIdentifier => "an identifier is of an unsupported type", + AcmeError::UserActionRequired => "visit the \"instance\" URL and take actions specified there", + AcmeError::Unknown => "unknown error", }; write!(f, "{}", msg) } @@ -147,7 +147,7 @@ impl fmt::Display for HttpApiError { .to_owned() .unwrap_or_else(|| self.get_acme_type().to_string()); let msg = match self.status { - Some(s) => format!("Status {}: {}", s, msg), + Some(s) => format!("status {}: {}", s, msg), None => msg, }; write!(f, "{}", msg) diff --git a/acmed/src/certificate.rs b/acmed/src/certificate.rs index c06297b..c570fea 100644 --- a/acmed/src/certificate.rs +++ b/acmed/src/certificate.rs @@ -70,7 +70,7 @@ impl Certificate { fn is_expiring(&self, cert: &X509Certificate) -> Result { let expires_in = cert.expires_in()?; self.debug(&format!( - "Certificate expires in {} days ({} days delay)", + "certificate expires in {} days ({} days delay)", expires_in.as_secs() / 86400, self.renew_delay.as_secs() / 86400, )); @@ -92,7 +92,7 @@ impl Certificate { .collect::>() .join(", "); self.debug(&format!( - "The certificate does not include the following domains: {}", + "the certificate does not include the following domains: {}", domains )); } @@ -110,7 +110,7 @@ impl Certificate { pub fn should_renew(&self) -> Result { self.debug(&format!( - "Checking for renewal (identifiers: {})", + "checking for renewal (identifiers: {})", self.identifier_list() )); if !certificate_files_exists(&self.file_manager) { @@ -121,18 +121,18 @@ impl Certificate { let renew_ident = self.has_missing_identifiers(&cert); if renew_ident { - self.debug("The current certificate doesn't include all the required identifiers."); + self.debug("the current certificate doesn't include all the required identifiers"); } let renew_exp = self.is_expiring(&cert)?; if renew_exp { - self.debug("The certificate is expiring."); + self.debug("the certificate is expiring"); } let renew = renew_ident || renew_exp; if renew { - self.debug("The certificate will be renewed now"); + self.debug("the certificate will be renewed now"); } else { - self.debug("The certificate will not be renewed now"); + self.debug("the certificate will not be renewed now"); } Ok(renew) } diff --git a/acmed/src/config.rs b/acmed/src/config.rs index 3e9dc7b..f7c26a7 100644 --- a/acmed/src/config.rs +++ b/acmed/src/config.rs @@ -28,7 +28,7 @@ fn get_stdin(hook: &Hook) -> Result { Some(file) => match &hook.stdin_str { Some(_) => { let msg = format!( - "{}: A hook cannot have both stdin and stdin_str", + "{}: a hook cannot have both stdin and stdin_str", &hook.name ); Err(msg.into()) @@ -388,7 +388,7 @@ impl Certificate { let id = self .identifiers .first() - .ok_or_else(|| Error::from("Certificate has no identifiers."))?; + .ok_or_else(|| Error::from("certificate has no identifiers"))?; id.to_string() } }; @@ -423,7 +423,7 @@ impl Certificate { return Ok(endpoint.clone()); } } - Err(format!("{}: unknown endpoint.", self.endpoint).into()) + Err(format!("{}: unknown endpoint", self.endpoint).into()) } pub fn get_endpoint(&self, cnf: &Config) -> Result { @@ -497,7 +497,7 @@ impl Identifier { None => match &self.ip { Some(ip) => (IdentifierType::Ip, ip), None => { - return Err("No identifier found.".into()); + return Err("no identifier found".into()); } }, }; @@ -533,7 +533,7 @@ fn get_cnf_path(from: &PathBuf, file: &str) -> Result, Error> { .collect::>(); if g.is_empty() { log::warn!( - "Pattern `{}` (expanded as `{}`): no matching configuration file found.", + "pattern `{}` (expanded as `{}`): no matching configuration file found", file, raw_path ); @@ -542,7 +542,7 @@ fn get_cnf_path(from: &PathBuf, file: &str) -> Result, Error> { } fn read_cnf(path: &PathBuf) -> Result { - info!("Loading configuration file: {}", path.display()); + info!("loading configuration file: {}", path.display()); let mut file = File::open(path).map_err(|e| Error::from(e).prefix(&path.display().to_string()))?; let mut contents = String::new(); diff --git a/acmed/src/hooks.rs b/acmed/src/hooks.rs index f93e39a..eaca640 100644 --- a/acmed/src/hooks.rs +++ b/acmed/src/hooks.rs @@ -106,7 +106,10 @@ macro_rules! get_hook_output { match $out { Some(path) => { let path = $reg.render_template(path, $data)?; - $logger.trace(&format!("Hook {}: {}: {}", $hook_name, $out_name, &path)); + $logger.trace(&format!( + "hook \"{}\": {}: {}", + $hook_name, $out_name, &path + )); let file = File::create(&path)?; Stdio::from(file) } @@ -120,7 +123,7 @@ where L: HasLogger, T: Clone + HookEnvData + Serialize, { - logger.debug(&format!("Calling hook: {}", hook.name)); + logger.debug(&format!("calling hook \"{}\"", hook.name)); let reg = Handlebars::new(); let mut v = vec![]; let args = match &hook.args { @@ -133,8 +136,8 @@ where } None => &[], }; - logger.trace(&format!("Hook {}: cmd: {}", hook.name, hook.cmd)); - logger.trace(&format!("Hook {}: args: {:?}", hook.name, args)); + logger.trace(&format!("hook \"{}\": cmd: {}", hook.name, hook.cmd)); + logger.trace(&format!("hook \"{}\": args: {:?}", hook.name, args)); let mut cmd = Command::new(&hook.cmd) .envs(data.get_env()) .args(args) @@ -162,13 +165,19 @@ where match &hook.stdin { HookStdin::Str(s) => { let data_in = reg.render_template(&s, &data)?; - logger.trace(&format!("Hook {}: string stdin: {}", hook.name, &data_in)); + logger.trace(&format!( + "hook \"{}\": string stdin: {}", + hook.name, &data_in + )); let stdin = cmd.stdin.as_mut().ok_or("stdin not found")?; stdin.write_all(data_in.as_bytes())?; } HookStdin::File(f) => { let file_name = reg.render_template(&f, &data)?; - logger.trace(&format!("Hook {}: file stdin: {}", hook.name, &file_name)); + logger.trace(&format!( + "hook \"{}\": file stdin: {}", + hook.name, &file_name + )); let stdin = cmd.stdin.as_mut().ok_or("stdin not found")?; let file = File::open(&file_name)?; let buf_reader = BufReader::new(file); @@ -183,14 +192,14 @@ where let status = cmd.wait()?; if !status.success() && !hook.allow_failure { let msg = match status.code() { - Some(code) => format!("Unrecoverable failure: code {}", code).into(), - None => "Unrecoverable failure".into(), + Some(code) => format!("unrecoverable failure: code {}", code).into(), + None => "unrecoverable failure".into(), }; return Err(msg); } match status.code() { - Some(code) => logger.debug(&format!("Hook {}: exited: code {}", hook.name, code)), - None => logger.debug(&format!("Hook {}: exited", hook.name)), + Some(code) => logger.debug(&format!("hook \"{}\": exited: code {}", hook.name, code)), + None => logger.debug(&format!("hook \"{}\": exited", hook.name)), }; Ok(()) } diff --git a/acmed/src/http.rs b/acmed/src/http.rs index 18ace3e..2396bfe 100644 --- a/acmed/src/http.rs +++ b/acmed/src/http.rs @@ -100,7 +100,7 @@ fn rate_limit(endpoint: &mut Endpoint) { pub fn header_to_string(header_value: &header::HeaderValue) -> Result { let s = header_value .to_str() - .map_err(|_| Error::from("Invalid nonce format."))?; + .map_err(|_| Error::from("invalid nonce format"))?; Ok(s.to_string()) } @@ -177,7 +177,7 @@ where } thread::sleep(time::Duration::from_secs(crate::DEFAULT_HTTP_FAIL_WAIT_SEC)); } - Err("Too much errors, will not retry".into()) + Err("too much errors, will not retry".into()) } pub fn post_jose( diff --git a/acmed/src/identifier.rs b/acmed/src/identifier.rs index 512efd2..f3e89ef 100644 --- a/acmed/src/identifier.rs +++ b/acmed/src/identifier.rs @@ -64,7 +64,7 @@ impl Identifier { let challenge = Challenge::from_str(challenge)?; if !id_type.supported_challenges().contains(&challenge) { let msg = format!( - "Challenge {} cannot be used with identifier of type {}", + "challenge {} cannot be used with identifier of type {}", challenge, id_type ); return Err(msg.into()); diff --git a/acmed/src/main_event_loop.rs b/acmed/src/main_event_loop.rs index 895a4db..646ceb6 100644 --- a/acmed/src/main_event_loop.rs +++ b/acmed/src/main_event_loop.rs @@ -22,9 +22,9 @@ fn renew_certificate( account: &mut Account, ) { let (status, is_success) = match request_certificate(crt, root_certs, endpoint, account) { - Ok(_) => ("Success.".to_string(), true), + Ok(_) => ("success".to_string(), true), Err(e) => { - let e = e.prefix("Unable to renew the certificate"); + let e = e.prefix("unable to renew the certificate"); crt.warn(&e.message); (e.message, false) } @@ -32,7 +32,7 @@ fn renew_certificate( match crt.call_post_operation_hooks(&status, is_success) { Ok(_) => {} Err(e) => { - let e = e.prefix("Post-operation hook error"); + let e = e.prefix("post-operation hook error"); crt.warn(&e.message); } }; @@ -144,7 +144,7 @@ impl MainEventLoop { match accounts.get_mut(&crt.account) { Some(acc) => acc.add_endpoint_name(&endpoint_name), None => { - let msg = format!("{}: account not found.", &crt.account); + let msg = format!("{}: account not found", &crt.account); return Err(msg.into()); } }; @@ -152,8 +152,6 @@ impl MainEventLoop { certs.push(cert); } - // TODO: call .synchronize() on every account - Ok(MainEventLoop { certs, root_certs: root_certs.iter().map(|v| (*v).to_string()).collect(), diff --git a/acmed/src/storage.rs b/acmed/src/storage.rs index d52f162..a478e5a 100644 --- a/acmed/src/storage.rs +++ b/acmed/src/storage.rs @@ -115,7 +115,7 @@ fn get_file_path(fm: &FileManager, file_type: FileType) -> Result Result, Error> { - fm.trace(&format!("Reading file {:?}", path)); + fm.trace(&format!("reading file {:?}", path)); let mut file = File::open(path)?; let mut contents = vec![]; file.read_to_end(&mut contents)?; @@ -137,7 +137,7 @@ fn set_owner(fm: &FileManager, path: &PathBuf, file_type: FileType) -> Result<() if u.bytes().all(|b| b.is_ascii_digit()) { let raw_uid = u .parse::() - .map_err(|_| Error::from("Unable to parse the UID"))?; + .map_err(|_| Error::from("unable to parse the UID"))?; let nix_uid = nix::unistd::Uid::from_raw(raw_uid); Some(nix_uid) } else { @@ -152,7 +152,7 @@ fn set_owner(fm: &FileManager, path: &PathBuf, file_type: FileType) -> Result<() if g.bytes().all(|b| b.is_ascii_digit()) { let raw_gid = g .parse::() - .map_err(|_| Error::from("Unable to parse the GID"))?; + .map_err(|_| Error::from("unable to parse the GID"))?; let nix_gid = nix::unistd::Gid::from_raw(raw_gid); Some(nix_gid) } else { @@ -193,7 +193,7 @@ fn write_file(fm: &FileManager, file_type: FileType, data: &[u8]) -> Result<(), hooks::call(fm, &fm.hooks, &hook_data, HookType::FilePreEdit)?; } - fm.trace(&format!("Writing file {:?}", path)); + fm.trace(&format!("writing file {:?}", path)); let mut file = if cfg!(unix) { let mut options = OpenOptions::new(); options.mode(match &file_type { @@ -259,7 +259,7 @@ fn check_files(fm: &FileManager, file_types: &[FileType]) -> bool { } }; fm.trace(&format!( - "Testing file path: {}", + "testing file path: {}", path.to_str().unwrap_or_default() )); if !path.is_file() { diff --git a/tacd/src/main.rs b/tacd/src/main.rs index 3bf23de..c6f92c6 100644 --- a/tacd/src/main.rs +++ b/tacd/src/main.rs @@ -33,7 +33,7 @@ fn get_acme_value(cnf: &ArgMatches, opt: &str, opt_file: &str) -> Result Ok(v.to_string()), None => { debug!( - "Reading {} from {}", + "reading {} from {}", opt, cnf.value_of(opt_file).unwrap_or("stdin") ); @@ -61,7 +61,7 @@ fn init(cnf: &ArgMatches) -> Result<(), Error> { None => DEFAULT_CRT_DIGEST, }; let (pk, cert) = X509Certificate::from_acme_ext(&domain, &ext, crt_signature_alg, crt_digest)?; - info!("Starting {} on {} for {}", APP_NAME, listen_addr, domain); + info!("starting {} on {} for {}", APP_NAME, listen_addr, domain); server_start(listen_addr, &cert, &pk)?; Ok(()) } diff --git a/tacd/src/openssl_server.rs b/tacd/src/openssl_server.rs index 68e2452..2213e41 100644 --- a/tacd/src/openssl_server.rs +++ b/tacd/src/openssl_server.rs @@ -21,7 +21,7 @@ macro_rules! listen_and_accept { if let Ok(stream) = stream { let acceptor = $acceptor.clone(); thread::spawn(move || { - debug!("New client"); + debug!("new client"); let _ = acceptor.accept(stream).unwrap(); }); }; @@ -45,11 +45,11 @@ pub fn start( let acceptor = Arc::new(acceptor.build()); if cfg!(unix) && listen_addr.starts_with("unix:") { let listen_addr = &listen_addr[5..]; - debug!("Listening on unix socket {}", listen_addr); + debug!("listening on unix socket {}", listen_addr); listen_and_accept!(UnixListener, listen_addr, acceptor); } else { - debug!("Listening on {}", listen_addr); + debug!("listening on {}", listen_addr); listen_and_accept!(TcpListener, listen_addr, acceptor); } - Err("Main thread loop unexpectedly exited".into()) + Err("main thread loop unexpectedly exited".into()) }