diff --git a/CHANGELOG.md b/CHANGELOG.md index d7377764e..ecc58e6b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [0.2.3] - 2024-07-11 + +### Changed +- Portability: sudo-rs now is compatible with s390x-unknown-linux-gnu +- Removed unneeded code & fix hints given by newer Rust version + +### Fixed +- `visudo` would not properly truncate a `sudoers` file +- high CPU load when child process did not terminate after closure of a terminal + ## [0.2.2] - 2024-02-02 ### Changed @@ -111,6 +121,7 @@ - Use canonicalized paths for the executed binaries - Simplified CLI help to only display supported actions +[0.2.3]: https://github.com/trifectatechfoundation/sudo-rs/compare/v0.2.2...v0.2.3 [0.2.2]: https://github.com/trifectatechfoundation/sudo-rs/compare/v0.2.1...v0.2.2 [0.2.1]: https://github.com/trifectatechfoundation/sudo-rs/compare/v0.2.0...v0.2.1 [0.2.0]: https://github.com/trifectatechfoundation/sudo-rs/compare/v0.2.0-dev.20230711...v0.2.0 diff --git a/Cargo.lock b/Cargo.lock index 7155b9f28..76c4ac033 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,15 +16,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "pretty_assertions" @@ -38,7 +38,7 @@ dependencies = [ [[package]] name = "sudo-rs" -version = "0.2.2" +version = "0.2.3" dependencies = [ "glob", "libc", diff --git a/Cargo.toml b/Cargo.toml index 0ad576048..377a321c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sudo-rs" description = "A memory safe implementation of sudo and su." -version = "0.2.2" +version = "0.2.3" license = "Apache-2.0 OR MIT" edition = "2021" repository = "https://github.com/trifectatechfoundation/sudo-rs" diff --git a/docs/man/su.1.md b/docs/man/su.1.md index 7623f84cf..86b6567ab 100644 --- a/docs/man/su.1.md +++ b/docs/man/su.1.md @@ -1,5 +1,5 @@ # NAME diff --git a/docs/man/sudo.8.md b/docs/man/sudo.8.md index 2d7e40c3a..218688f71 100644 --- a/docs/man/sudo.8.md +++ b/docs/man/sudo.8.md @@ -1,5 +1,5 @@ # NAME diff --git a/docs/man/visudo.8.md b/docs/man/visudo.8.md index 9fea0c46f..f2de127a1 100644 --- a/docs/man/visudo.8.md +++ b/docs/man/visudo.8.md @@ -1,5 +1,5 @@ # NAME diff --git a/util/Dockerfile-release b/util/Dockerfile-release index b507f5be5..020bdfc02 100644 --- a/util/Dockerfile-release +++ b/util/Dockerfile-release @@ -1,2 +1,2 @@ -FROM rust:1-slim-bullseye +FROM rust:1.79-slim-bullseye RUN apt-get update -y && apt-get install -y clang libclang-dev libpam0g-dev diff --git a/util/build-release.sh b/util/build-release.sh index 849893563..30ba01130 100755 --- a/util/build-release.sh +++ b/util/build-release.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -DATE="2023-09-21" SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) PROJECT_DIR=$(dirname "$SCRIPT_DIR") SUDO_RS_VERSION="$(cargo metadata --format-version 1 --manifest-path "$PROJECT_DIR/Cargo.toml" | jq '.packages[] | select(.name=="sudo-rs") | .version' -r)" @@ -9,6 +8,9 @@ TARGET_DIR_BASE="$PROJECT_DIR/target/pkg" set -eo pipefail +# Fetch the date from the changelog +DATE=$(grep -m1 '^##' "$PROJECT_DIR"/CHANGELOG.md | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}') + # Build binaries docker build --pull --tag "$BUILDER_IMAGE_TAG" --file "$SCRIPT_DIR/Dockerfile-release" "$SCRIPT_DIR" docker run --rm --user "$(id -u):$(id -g)" -v "$PROJECT_DIR:/build" -w "/build" "$BUILDER_IMAGE_TAG" cargo clean diff --git a/util/update-version.sh b/util/update-version.sh index a8b79f298..bbce9d1f6 100755 --- a/util/update-version.sh +++ b/util/update-version.sh @@ -1,16 +1,32 @@ #!/usr/bin/env bash -if [ "$#" -lt 1 ]; then - echo "Missing new version" - exit 1 -fi - SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) PROJECT_DIR=$(dirname "$SCRIPT_DIR") NEW_VERSION="$1" -echo "Updating version in Cargo.toml" -sed -i 's/^version\s*=\s*".*"/version = "'"$NEW_VERSION"'"/' "$PROJECT_DIR/Cargo.toml" +# Fetch current version +CURRENT_VERSION=$(sed -n '/version\s*=\s*"\([^"]*\)"/{s//\1/p;q}' "$PROJECT_DIR/Cargo.toml") + +# Fetch new version from changelog +NEW_VERSION=$(grep -m1 '^##' "$PROJECT_DIR"/CHANGELOG.md | grep -o "\[[0-9]\+.[0-9]\+.[0-9]\+\]" | tr -d '[]') + +if [ -z "$NEW_VERSION" ]; then + echo "Could not fetch version from CHANGELOG.md; you probably made a mistake." + exit 1 +fi + +if [ "$CURRENT_VERSION" \> "$NEW_VERSION" ]; then + echo "New version number must be higher than current version: $CURRENT_VERSION" + echo "Create a new changelog entry before running this script!" + exit 1 +fi + +if [ "$CURRENT_VERSION" == "$NEW_VERSION" ]; then + echo "Cargo.toml was already at $NEW_VERSION" +else + echo "Updating version in Cargo.toml to $NEW_VERSION" + sed -i 's/^version\s*=\s*".*"/version = "'"$NEW_VERSION"'"/' "$PROJECT_DIR/Cargo.toml" +fi echo "Updating version in man pages" sed -i 's/^title: SU(1) sudo-rs .*/title: SU(1) sudo-rs '"$NEW_VERSION"' | sudo-rs/' "$PROJECT_DIR"/docs/man/su.1.md @@ -19,5 +35,3 @@ sed -i 's/^title: VISUDO(8) sudo-rs .*/title: VISUDO(8) sudo-rs '"$NEW_VERSION"' echo "Rebuilding project" (cd $PROJECT_DIR && cargo build --release) - -echo "Version changes complete, you must still fill in the changelog entries"