diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-09-09 14:33:22 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-09-09 17:00:59 +0200 |
commit | 76c69c563ba6cfc708323a0c567d1a6920002efd (patch) | |
tree | b5c0f860e4fd8d926c918fb684a4fe4443750835 | |
parent | 350918b63b572a0d8cdd18915106c3d7607ec383 (diff) |
net: Do not diddle with the permissions.
-rw-r--r-- | net/src/wkd.rs | 19 | ||||
-rw-r--r-- | tool/src/sq-usage.rs | 4 | ||||
-rw-r--r-- | tool/src/sq_cli.rs | 5 |
3 files changed, 2 insertions, 26 deletions
diff --git a/net/src/wkd.rs b/net/src/wkd.rs index 1cad4b05..89f6d4ad 100644 --- a/net/src/wkd.rs +++ b/net/src/wkd.rs @@ -20,7 +20,6 @@ extern crate tokio_core; use std::fmt; use std::fs; use std::io::Write; -use std::os::unix::fs::{DirBuilderExt, PermissionsExt}; use std::path::{Path, PathBuf}; use futures::{future, Future, Stream}; @@ -296,10 +295,6 @@ pub fn get<S: AsRef<str>>(email_address: S) } /// Generates a Web Key Directory for the given domain and keys. -/// -/// The owner of the directory and files will be the user that runs this -/// command. -/// This command only works on Unix-like systems. pub fn generate<S, T, P>(domain: S, tpks: &[TPK], base_path: P, direct_method: T) -> Result<()> @@ -320,11 +315,7 @@ pub fn generate<S, T, P>(domain: S, tpks: &[TPK], base_path: P, let dir_path = base_path.join( Path::new(&file_path).parent().unwrap()); - // With fs::create_dir_all the permissions can't be set. - fs::DirBuilder::new() - .mode(0o744) - .recursive(true) - .create(&dir_path)?; + fs::create_dir_all(&dir_path)?; // Create the files. // This is very similar to parse_body, but here the userids must contain @@ -339,8 +330,6 @@ pub fn generate<S, T, P>(domain: S, tpks: &[TPK], base_path: P, // name is needed. let file_path = dir_path.join(wkd_url.local_encoded); let mut file = fs::File::create(&file_path)?; - // Set Read/write for owner and read for others. - file.metadata()?.permissions().set_mode(0o644); tpk.serialize(&mut tpk_bytes)?; file.write_all(&tpk_bytes)?; } @@ -468,20 +457,14 @@ mod tests { "openpgpkey.sequoia-pgp.org/\ .well-known/openpgpkey/sequoia-pgp.org/hu\ /jwp7xjqkdujgz5op6bpsoypg34pnrgmq"); - // Check parent directory permissions - assert_eq!(path.parent().unwrap().metadata().unwrap().permissions() - .mode(),16868); // 744 // Check that justus file was created assert!(path.is_file()); - // Check the permissions of the file. - assert_eq!(path.metadata().unwrap().permissions().mode(),33188); // 644 let path = dir_path.join( "openpgpkey.sequoia-pgp.org/\ .well-known/openpgpkey/sequoia-pgp.org/hu\ /7t1uqk9cwh1955776rc4z1gqf388566j"); // Check that juga file was created. assert!(path.is_file()); - assert_eq!(path.metadata().unwrap().permissions().mode(),33188); // Check that the file for test uid is not created. let path = dir_path.join( "openpgpkey.example.com/\ diff --git a/tool/src/sq-usage.rs b/tool/src/sq-usage.rs index bc012ae3..009cff34 100644 --- a/tool/src/sq-usage.rs +++ b/tool/src/sq-usage.rs @@ -671,8 +671,6 @@ //! //! SUBCOMMANDS: //! generate Generates a Web Key Directory for the given domain and keys. -//! The owner of the directory and files will be the user that runs this command. -//! This command only works on Unix-like systems. //! get Writes to the standard output the TPK retrieved from a Web Key Directory, given an email address //! help Prints this message or the help of the given subcommand(s) //! url Prints the Web Key Directory URL of an email address. @@ -682,8 +680,6 @@ //! //! ```text //! Generates a Web Key Directory for the given domain and keys. -//! The owner of the directory and files will be the user that runs this command. -//! This command only works on Unix-like systems. //! //! USAGE: //! sq wkd generate [FLAGS] [OPTIONS] <DOMAIN> [KEYRING] diff --git a/tool/src/sq_cli.rs b/tool/src/sq_cli.rs index 126fb363..c26f1e4c 100644 --- a/tool/src/sq_cli.rs +++ b/tool/src/sq_cli.rs @@ -503,10 +503,7 @@ pub fn build() -> App<'static, 'static> { .help("Don't ASCII-armor encode the OpenPGP data"))) .subcommand(SubCommand::with_name("generate") .about("Generates a Web Key Directory for the \ - given domain and keys.\n\ - The owner of the directory and files will be the user \ - that runs this command.\n\ - This command only works on Unix-like systems.") + given domain and keys.") .arg(Arg::with_name("output") .long("output") .short("o") |