Github messages for voidlinux
 help / color / mirror / Atom feed
From: classabbyamp <classabbyamp@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] common/chroot-style/uchroot.sh: check if xbps-uchroot is executable
Date: Sun, 18 Feb 2024 09:19:42 +0100	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-48810@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 724 bytes --]

There is a new pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages this-sign-cant-stop-me-because-i-cant-read
https://github.com/void-linux/void-packages/pull/48810

common/chroot-style/uchroot.sh: check if xbps-uchroot is executable
...and show a friendly error message

This can be a common failure mode when using `-t` if not in the group `xbps-uchroot` is owned by, because it is SUID. Previously, the error was the cryptic message `ERROR: prctl SECBIT_NOROOT (Operation not permitted)`.

#### Testing the changes
- I tested the changes in this PR: **YES**


A patch file from https://github.com/void-linux/void-packages/pull/48810.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-this-sign-cant-stop-me-because-i-cant-read-48810.patch --]
[-- Type: text/x-diff, Size: 1622 bytes --]

From 8317c992cc77f0f63029ccf1a1af0b3db3f50f6a Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Sun, 18 Feb 2024 03:15:55 -0500
Subject: [PATCH] common/chroot-style/uchroot.sh: check if xbps-uchroot is
 executable

... and show a friendly error message

This can be a common failure mode when using `-t` if not in the group
`xbps-uchroot` is owned by, because it is SUID. Previously, the error was
the cryptic message `ERROR: prctl SECBIT_NOROOT (Operation not permitted)`.
---
 common/chroot-style/uchroot.sh | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/common/chroot-style/uchroot.sh b/common/chroot-style/uchroot.sh
index 5fe47eb9f8bcb..e24ceac308be0 100755
--- a/common/chroot-style/uchroot.sh
+++ b/common/chroot-style/uchroot.sh
@@ -9,12 +9,27 @@ readonly EXTRA_ARGS="$4"
 readonly CMD="$5"
 shift 5
 
-if ! command -v xbps-uchroot >/dev/null 2>&1; then
+msg_red() {
+	# error messages in bold/red
+	[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
+	printf "=> ERROR: %s\\n" "$@" >&2
+	[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
+}
+
+readonly XBPS_UCHROOT_CMD="$(command -v xbps-uchroot 2>/dev/null)"
+
+if [ -z "$XBPS_UCHROOT_CMD" ]; then
+	msg_red "could not find xbps-uchroot"
+	exit 1
+fi
+
+if ! [ -x "$XBPS_UCHROOT_CMD" ]; then
+	msg_red "xbps-uchroot is not executable. Are you in the $(stat -c %G "$XBPS_UCHROOT_CMD") group?"
 	exit 1
 fi
 
-if [ -z "$MASTERDIR" -o -z "$DISTDIR" ]; then
-	echo "$0 MASTERDIR/DISTDIR not set"
+if [ -z "$MASTERDIR" ] || [ -z "$DISTDIR" ]; then
+	msg_red "$0: MASTERDIR/DISTDIR not set"
 	exit 1
 fi
 

             reply	other threads:[~2024-02-18  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18  8:19 classabbyamp [this message]
2024-02-18  8:24 ` 0x5c
2024-05-12  3:30 ` [PR PATCH] [Merged]: " classabbyamp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-48810@inbox.vuxu.org \
    --to=classabbyamp@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).