-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8: Set the executable name in ensure_sealed r=iliana a=iliana Also, prepare v1.0.0 🎉 Co-authored-by: iliana etaoin <[email protected]>
- Loading branch information
Showing
7 changed files
with
24 additions
and
20 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "pentacle" | ||
version = "0.2.0" | ||
version = "1.0.0" | ||
authors = ["iliana destroyer of worlds <[email protected]>"] | ||
edition = "2018" | ||
exclude = ["bors.toml", ".github", ".gitignore"] | ||
|
@@ -15,5 +15,5 @@ libc = "0.2" | |
log = "0.4" | ||
|
||
[package.metadata.docs.rs] | ||
# https://docs.rs/about#metadata | ||
# https://docs.rs/about/metadata | ||
targets = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"] |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2019 iliana destroyer of worlds <[email protected]> | ||
Copyright (c) iliana destroyer of worlds <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2019 iliana destroyer of worlds <[email protected]> | ||
// Copyright (c) iliana destroyer of worlds <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
//! pentacle is a library for executing programs as sealed anonymous files on Linux, using | ||
|
@@ -58,11 +58,6 @@ const MEMFD_SEALS: libc::c_int = F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_S | |
/// implications as [`CommandExt::exec`]: no destructors on the current stack or any other thread’s | ||
/// stack will be run. | ||
/// | ||
/// # Compatibility | ||
/// | ||
/// This library is unable to set the program name (`argv[0]`), which will cause unexpected | ||
/// behavior for multi-call binaries and other programs that use the program name. | ||
/// | ||
/// # Errors | ||
/// | ||
/// An error is returned if `/proc/self/exe` fails to open, `memfd_create(2)` fails, the `fcntl(2)` | ||
|
@@ -72,9 +67,13 @@ pub fn ensure_sealed() -> Result<()> { | |
if is_sealed_inner(&file) { | ||
Ok(()) | ||
} else { | ||
Err(SealedCommand::new(&mut file)? | ||
.args(std::env::args_os().skip(1)) | ||
.exec()) | ||
let mut command = SealedCommand::new(&mut file)?; | ||
let mut args = std::env::args_os().fuse(); | ||
if let Some(arg0) = args.next() { | ||
command.arg0(arg0); | ||
} | ||
command.args(args); | ||
Err(command.exec()) | ||
} | ||
} | ||
|
||
|
@@ -108,10 +107,8 @@ impl SealedCommand { | |
/// The memory-backed file will close on `execve(2)` **unless** the program starts with `#!` | ||
/// (indicating that it is an interpreter script). | ||
/// | ||
/// # Compatibility | ||
/// | ||
/// This library is unable to set the program name (`argv[0]`), which will cause unexpected | ||
/// behavior for multi-call binaries and other programs that use the program name. | ||
/// `argv[0]` of the program will default to the file descriptor path in procfs (for example, | ||
/// `/proc/self/fd/3`). [`CommandExt::arg0`] can override this. | ||
/// | ||
/// # Errors | ||
/// | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2019 iliana destroyer of worlds <[email protected]> | ||
// Copyright (c) iliana destroyer of worlds <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
// syscall returns a c_long but memfd_create(2) and fcntl(2) are documented as returning c_int. The | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2019 iliana destroyer of worlds <[email protected]> | ||
// Copyright (c) iliana destroyer of worlds <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
// Smoke test for the two pub functions in pentacle. | ||
|
@@ -12,4 +12,5 @@ | |
fn main() { | ||
pentacle::ensure_sealed().unwrap(); | ||
assert_eq!(pentacle::is_sealed(), true); | ||
assert!(std::env::args().next().unwrap().contains("ensure_sealed")); | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2019 iliana destroyer of worlds <[email protected]> | ||
// Copyright (c) iliana destroyer of worlds <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
#![warn(clippy::pedantic)] | ||
|