Skip to content

Commit

Permalink
Merge #8
Browse files Browse the repository at this point in the history
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
bors[bot] and iliana authored Sep 30, 2020
2 parents 9cc5c27 + c837e32 commit 1596473
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.0.0] - 2020-09-29
### Changed
- Set `argv[0]` to the original `argv[0]` in `ensure_sealed`
- Minimum supported Rust version (MSRV) now 1.45.0

## [0.2.0] - 2020-06-23
### Changed
- No longer set `MFD_CLOEXEC` if `#!` is detected at the beginning of a program
Expand All @@ -18,7 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Everything!

[Unreleased]: https://github.com/iliana/pentacle/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/iliana/pentacle/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/iliana/pentacle/compare/v0.2.0...v1.0.0
[0.2.0]: https://github.com/iliana/pentacle/compare/v0.1.1...v0.2.0
[0.1.1]: https://github.com/iliana/pentacle/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/iliana/pentacle/releases/tag/v0.1.0
4 changes: 2 additions & 2 deletions Cargo.toml
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"]
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion LICENSE
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
Expand Down
23 changes: 10 additions & 13 deletions src/lib.rs
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
Expand Down Expand Up @@ -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)`
Expand All @@ -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())
}
}

Expand Down Expand Up @@ -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
///
Expand Down
2 changes: 1 addition & 1 deletion src/syscall.rs
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
Expand Down
3 changes: 2 additions & 1 deletion tests/ensure_sealed.rs
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.
Expand All @@ -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"));
}
2 changes: 1 addition & 1 deletion tests/spawn.rs
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)]
Expand Down

0 comments on commit 1596473

Please sign in to comment.