aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2021-11-22 18:57:35 -0600
committerAriadne Conill <ariadne@dereferenced.org>2021-11-22 18:57:35 -0600
commit2493d4c71a0bd6bbccf8a966c0a9cb25d17882a3 (patch)
treea350bf46328e93dde981c63e24bfacd709b80764
parentd206261d3031d1f359370a5f7c363d8623a1487f (diff)
downloadaports-2493d4c71a0bd6bbccf8a966c0a9cb25d17882a3.tar.gz
aports-2493d4c71a0bd6bbccf8a966c0a9cb25d17882a3.tar.bz2
aports-2493d4c71a0bd6bbccf8a966c0a9cb25d17882a3.tar.xz
main/busybox: add UID matching support to pgrep/pkill (ref aports!27668)
-rw-r--r--main/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch138
-rw-r--r--main/busybox/APKBUILD5
2 files changed, 142 insertions, 1 deletions
diff --git a/main/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch b/main/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch
new file mode 100644
index 0000000000..7abfb09b76
--- /dev/null
+++ b/main/busybox/0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch
@@ -0,0 +1,138 @@
+From 648255c510f9a3f668651842b58798f07ad4c64a Mon Sep 17 00:00:00 2001
+From: Ariadne Conill <ariadne@dereferenced.org>
+Date: Mon, 22 Nov 2021 18:33:02 -0600
+Subject: [PATCH] pgrep: add support for matching against UID and RUID
+
+This is standard functionality on every other pgrep implementation I
+found, namely the ones in Illumos, FreeBSD, Linux procps, and macOS.
+
+Additionally, real world scripts like pipewire-session are dependent
+on it being present.
+
+function old new delta
+pgrep_main 818 1007 +189
+packed_usage 26001 26032 +31
+.rodata 78544 78548 +4
+------------------------------------------------------------------------------
+(add/remove: 0/0 grow/shrink: 3/0 up/down: 224/0) Total: 224 bytes
+
+Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
+---
+ procps/pgrep.c | 37 +++++++++++++++++++++++++++++++++----
+ 1 file changed, 33 insertions(+), 4 deletions(-)
+
+diff --git a/procps/pgrep.c b/procps/pgrep.c
+index 6d25c247e..6a12ac23b 100644
+--- a/procps/pgrep.c
++++ b/procps/pgrep.c
+@@ -42,6 +42,8 @@
+ //usage: "\n -x Match whole name (not substring)"
+ //usage: "\n -s Match session ID (0 for current)"
+ //usage: "\n -P Match parent process ID"
++//usage: "\n -u EUID Match against effective UID"
++//usage: "\n -U UID Match against UID"
+ //usage:
+ //usage:#define pkill_trivial_usage
+ //usage: "[-l|-SIGNAL] [-xfvno] [-s SID|-P PPID|PATTERN]"
+@@ -55,6 +57,8 @@
+ //usage: "\n -v Negate the match"
+ //usage: "\n -n Signal the newest process only"
+ //usage: "\n -o Signal the oldest process only"
++//usage: "\n -u EUID Match against effective UID"
++//usage: "\n -U UID Match against UID"
+
+ #include "libbb.h"
+ #include "xregex.h"
+@@ -64,7 +68,7 @@
+ #define pkill (ENABLE_PKILL && (!ENABLE_PGREP || applet_name[1] == 'k'))
+
+ enum {
+- /* "vlafxons:+P:+" */
++ /* "vlafxonu:U:s:+P:+" */
+ OPTBIT_V = 0, /* must be first, we need OPT_INVERT = 0/1 */
+ OPTBIT_L,
+ OPTBIT_A,
+@@ -72,6 +76,8 @@ enum {
+ OPTBIT_X,
+ OPTBIT_O,
+ OPTBIT_N,
++ OPTBIT_U,
++ OPTBIT_UL,
+ OPTBIT_S,
+ OPTBIT_P,
+ };
+@@ -85,6 +91,8 @@ enum {
+ #define OPT_LAST (opt & (1 << OPTBIT_N))
+ #define OPT_SID (opt & (1 << OPTBIT_S))
+ #define OPT_PPID (opt & (1 << OPTBIT_P))
++#define OPT_EUID (opt & (1 << OPTBIT_UL))
++#define OPT_RUID (opt & (1 << OPTBIT_U))
+
+ static void act(unsigned pid, char *cmd, int signo)
+ {
+@@ -105,7 +113,8 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
+ unsigned opt;
+ int scan_mask;
+ int matched_pid;
+- int sid2match, ppid2match;
++ int sid2match, ppid2match, uid2match, euid2match;
++ char *uid_arg = NULL, *euid_arg = NULL;
+ char *cmd_last;
+ procps_status_t *proc;
+ /* These are initialized to 0 */
+@@ -131,7 +140,9 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
+ /* Parse remaining options */
+ ppid2match = -1;
+ sid2match = -1;
+- opt = getopt32(argv, "vlafxons:+P:+", &sid2match, &ppid2match);
++ uid2match = -1;
++ euid2match = -1;
++ opt = getopt32(argv, "vlafxonu:U:s:+P:+", &euid_arg, &uid_arg, &sid2match, &ppid2match);
+ argv += optind;
+
+ if (pkill && OPT_LIST) { /* -l: print the whole signal list */
+@@ -147,8 +158,18 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
+ if (OPT_FULL)
+ scan_mask |= PSSCAN_ARGVN;
+
++ if (euid_arg) {
++ scan_mask |= PSSCAN_UIDGID;
++ euid2match = get_ug_id(euid_arg, xuname2uid);
++ }
++
++ if (uid_arg) {
++ scan_mask |= PSSCAN_RUIDGID;
++ uid2match = get_ug_id(uid_arg, xuname2uid);
++ }
++
+ /* One pattern is required, if no -s and no -P */
+- if ((sid2match & ppid2match) < 0 && (!argv[0] || argv[1]))
++ if ((sid2match & ppid2match) < 0 && uid2match < 0 && euid2match < 0 && (!argv[0] || argv[1]))
+ bb_show_usage();
+
+ if (argv[0])
+@@ -170,6 +191,10 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
+ continue;
+ if (sid2match >= 0 && sid2match != proc->sid)
+ continue;
++ if (euid2match >= 0 && euid2match != proc->uid)
++ continue;
++ if (uid2match >= 0 && uid2match != proc->ruid)
++ continue;
+ }
+
+ cmdlen = -1;
+@@ -202,6 +227,10 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
+ goto got_it;
+ if (sid2match >= 0 && sid2match != proc->sid)
+ goto got_it;
++ if (euid2match >= 0 && euid2match != proc->uid)
++ goto got_it;
++ if (uid2match >= 0 && uid2match != proc->ruid)
++ goto got_it;
+ }
+
+ match = !argv[0]; /* if no PATTERN, then it's a match, else... */
+--
+2.34.0
+
diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD
index 0c4732e587..40f4eb2b85 100644
--- a/main/busybox/APKBUILD
+++ b/main/busybox/APKBUILD
@@ -4,7 +4,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.34.1
-pkgrel=2
+pkgrel=3
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url="https://busybox.net/"
arch="all"
@@ -42,6 +42,8 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2
0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch
0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch
+ 0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch
+
acpid.logrotate
busyboxconfig
busyboxconfig-extras
@@ -263,6 +265,7 @@ ecbe5c890d966f09280c7eb534109f785c68e292765f17ed7ff62fcc61d20f61443c4155add0a1eb
d12246f1134bbd3993462d27172c4739cc601b251d57ce8e088745773afa965551236e8cb8b9013dfc142fd055e369a771d86c7c54615c89bd30393400bfa390 0001-ash-add-built-in-BB_ASH_VERSION-variable.patch
6f8fa4ec190d64d6c3d5377994be933885ed0b40361c99ca35881684db3b1b79664d6eab56a389df290b9f6c4db502c617ec8e4ffa6d5284bd41cea1f478b26c 0001-cpio-add-support-for-ignore-devno-like-GNU-cpio.patch
97109be04445b7b887c402b7072c1da57212ef11f2eca6d34c24d5a4e3b2866ee79aca7a0ca41043726293d9bed1b2fa8aab100501569f00b8670c280a87a01c 0002-cpio-add-support-for-renumber-inodes-like-GNU-cpio.patch
+e33dbc27d77c4636f4852d5d5216ef60a9a4343484e4559e391c13c813bf65c782b889914eff2e1f038d74cf02cb0d23824ebbb1044b5f8c86260d5a1bbc4e4d 0001-pgrep-add-support-for-matching-against-UID-and-RUID.patch
aa93095e20de88730f526c6f463cef711b290b9582cdbd8c1ba2bd290019150cbeaa7007c2e15f0362d5b9315dd63f60511878f0ea05e893f4fdfb4a54af3fb1 acpid.logrotate
e6549c9d5dbd272fe26b3e1347c84e31dbca3c57f141a345504a334c6f92016f3a3e43f3ee6777d5e382b8e6c8aeb095e11110b96c1aa2dee6c358df72c57ec4 busyboxconfig
2471879bca825af30ab3342e0c3635499f98eeed69ec2353b01c6cea1b07fee8b6f8bd4746fd2944039aa32acdec1e0c93c344a788f2f5ba4056db6182af4c02 busyboxconfig-extras