-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add configurable socket permissions
Have `pueue` set the permissions of the socket created. Previously, the permissions where unspecified and (at least for me) defaulted to `755`. As part of this change, the default settings are moving to `700` which is more restricted than the previous default. Signed-off-by: JP-Ellis <josh@jpellis.me>
- Loading branch information
Showing
8 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use anyhow::Result; | ||
use std::fs; | ||
use std::os::unix::fs::PermissionsExt; | ||
|
||
use anyhow::Context; | ||
|
||
use crate::helper::*; | ||
|
||
/// Make sure that the socket permissions are appropriately set. | ||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
#[cfg(not(target_os = "windows"))] | ||
async fn test_socket_permissions_default() -> Result<()> { | ||
let (settings, _tempdir) = daemon_base_setup()?; | ||
let shared = &settings.shared; | ||
let mut child = standalone_daemon(shared).await?; | ||
|
||
assert_eq!( | ||
fs::metadata(shared.unix_socket_path())? | ||
.permissions() | ||
.mode() | ||
// The permissions are masked with 0o777 to only get the last 3 | ||
// digits. | ||
& 0o777, | ||
0o700 | ||
); | ||
|
||
child.kill()?; | ||
Ok(()) | ||
} | ||
|
||
/// Make sure that the socket permissions can be changed | ||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
#[cfg(not(target_os = "windows"))] | ||
async fn test_socket_permissions_modified() -> Result<()> { | ||
let (mut settings, _tempdir) = daemon_base_setup()?; | ||
settings.shared.unix_socket_permissions = Some(0o777); | ||
let shared = &settings.shared; | ||
settings | ||
.save(&Some(settings.shared.runtime_directory().join("pueue.yml"))) | ||
.context("Couldn't write pueue config to temporary directory")?; | ||
|
||
let mut child = standalone_daemon(shared).await?; | ||
|
||
assert_eq!( | ||
fs::metadata(shared.unix_socket_path())? | ||
.permissions() | ||
.mode() | ||
// The permissions are masked with 0o777 to only get the last 3 | ||
// digits. | ||
& 0o777, | ||
0o777 | ||
); | ||
|
||
child.kill()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters