Github messages for voidlinux
 help / color / mirror / Atom feed
From: sgn <sgn@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] xbps-src: pre-pkg: allow only white-listed directories.
Date: Sat, 23 May 2020 13:48:49 +0200	[thread overview]
Message-ID: <20200523114849.NWFpmR1BPe2nrzWiR7NFfDjC47OEg5YVJAxL2UcwhpU@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-22035@inbox.vuxu.org>

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

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages pkg-lint-allow-only-whitelist
https://github.com/void-linux/void-packages/pull/22035

xbps-src: pre-pkg: allow only white-listed directories.


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pkg-lint-allow-only-whitelist-22035.patch --]
[-- Type: text/x-diff, Size: 3686 bytes --]

From 0e13d68a292e1f23a599e225a840cb7681d2a35b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Sun, 17 May 2020 18:42:43 +0700
Subject: [PATCH 1/2] xbps-src: pre-pkg: allow only white-listed directories.

---
 common/hooks/pre-pkg/99-pkglint.sh | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh
index d2c281e39db..bee6df56394 100644
--- a/common/hooks/pre-pkg/99-pkglint.sh
+++ b/common/hooks/pre-pkg/99-pkglint.sh
@@ -21,13 +21,37 @@ hook() {
 		fi
 	done
 	
-	for f in sys dev home root run var/run tmp usr/local destdir; do
+	for f in var/run usr/local; do
 		if [ -d ${PKGDESTDIR}/${f} ]; then
 			msg_red "${pkgver}: /${f} directory is not allowed, remove it!\n"
 			error=1
 		fi
 	done
 
+	for f in "$PKGDESTDIR"/*; do
+		f="${f##*/}"
+		case "$f" in
+		'*')	# The filename is exactly '*'
+			if [ -e "${PKGDESTDIR}/*" ]; then
+				msg_red "${pkgver}: File /${f} is not allowed\n"
+				error=1
+			fi
+			# Empty meta package is fine
+			;;
+		lib|bin|sbin|lib64|lib32|usr|var|opt|etc|boot|srv) ;;
+		INSTALL|INSTALL.msg|REMOVE|REMOVE.msg|rdeps|shlib-requires|shlib-provides)
+			if [ ! -f "${PKGDESTDIR}/$f" ]; then
+				msg_red "${pkgver}: /${f} is not allowed\n"
+				error=1
+			fi
+			;;
+		*)
+			msg_red "${pkgver}: /${f} directory is not allowed, remove it!\n"
+			error=1
+			;;
+		esac
+	done
+
 	# Check that configuration files really exist.
 	for f in $(expand_destdir "${conf_files}"); do
 		if [ ! -f "${PKGDESTDIR}/${f}" ]; then

From a8b2330f714a194fe84ff688f57326d998e1af47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Wed, 20 May 2020 06:12:02 +0700
Subject: [PATCH 2/2] fixup! xbps-src: pre-pkg: allow only white-listed
 directories.

---
 common/hooks/pre-pkg/99-pkglint.sh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh
index bee6df56394..e60419060ea 100644
--- a/common/hooks/pre-pkg/99-pkglint.sh
+++ b/common/hooks/pre-pkg/99-pkglint.sh
@@ -3,6 +3,7 @@
 hook() {
 	local error=0 filename= rev= libname= conflictPkg= conflictFile=
 	local conflictRev= ignore= found= mapshlibs=$XBPS_COMMONDIR/shlibs
+	local emptypkg=yes
 
 	set +E
 
@@ -36,9 +37,10 @@ hook() {
 				msg_red "${pkgver}: File /${f} is not allowed\n"
 				error=1
 			fi
-			# Empty meta package is fine
 			;;
-		lib|bin|sbin|lib64|lib32|usr|var|opt|etc|boot|srv) ;;
+		lib|bin|sbin|lib64|lib32|usr|var|opt|etc|boot|srv)
+			emptypkg=no
+			;;
 		INSTALL|INSTALL.msg|REMOVE|REMOVE.msg|rdeps|shlib-requires|shlib-provides)
 			if [ ! -f "${PKGDESTDIR}/$f" ]; then
 				msg_red "${pkgver}: /${f} is not allowed\n"
@@ -52,6 +54,12 @@ hook() {
 		esac
 	done
 
+	# Forbid empty packages unless build_style=meta
+	if [ "$build_style" != meta -a "$emptypkg" != no ]; then
+		msg_red "${pkgver}: PKGDESTDIR is empty and build_style != meta\n"
+		error=1
+	fi
+
 	# Check that configuration files really exist.
 	for f in $(expand_destdir "${conf_files}"); do
 		if [ ! -f "${PKGDESTDIR}/${f}" ]; then
@@ -113,14 +121,6 @@ hook() {
 		fi
 	done
 
-	# Forbid empty packages unless build_style=meta
-	if [ "$build_style" != "meta" ]; then
-		if [ "$(find $PKGDESTDIR/* -maxdepth 1 -type d 2>/dev/null)" = "" ]; then
-			msg_red "${pkgver}: PKGDESTDIR is empty and build_style != meta\n"
-			error=1
-		fi
-	fi
-
 	if [ $error -gt 0 ]; then
 		msg_error "${pkgver}: cannot continue with installation!\n"
 	fi

  parent reply	other threads:[~2020-05-23 11:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 11:44 [PR PATCH] " sgn
2020-05-17 12:08 ` [PR PATCH] [Updated] " sgn
2020-05-19 22:50 ` sgn
2020-05-19 22:56 ` Chocimier
2020-05-19 23:07 ` [PR PATCH] [Updated] " sgn
2020-05-19 23:12 ` sgn
2020-05-19 23:12 ` sgn
2020-05-19 23:15 ` jnbr
2020-05-19 23:19 ` q66
2020-05-19 23:23 ` [PR PATCH] [Updated] " sgn
2020-05-19 23:26 ` sgn
2020-05-19 23:27 ` sgn
2020-05-21 15:33 ` [PR PATCH] [Updated] " sgn
2020-05-22 17:35 ` Chocimier
2020-05-23 11:48 ` sgn [this message]
2020-05-23 11:56 ` [PR PATCH] [Updated] " sgn
2020-05-31  2:11 ` [PR PATCH] [Merged]: " sgn

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=20200523114849.NWFpmR1BPe2nrzWiR7NFfDjC47OEg5YVJAxL2UcwhpU@z \
    --to=sgn@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).