upg procps-ng
This commit is contained in:
parent
c38a10c487
commit
22681594dd
4 changed files with 196 additions and 13 deletions
176
procps-ng/0002-ps-Don-t-crash-when-using-short-option.patch
Normal file
176
procps-ng/0002-ps-Don-t-crash-when-using-short-option.patch
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
From 79042e07fab9956135a21b1df7a69d1fbde7ef79 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Craig Small <csmall@dropbear.xyz>
|
||||||
|
Date: Tue, 12 Sep 2023 16:59:18 +1000
|
||||||
|
Subject: [PATCH] ps: Don't crash when using short option
|
||||||
|
|
||||||
|
ps would crash with the -si or -sf options with systemd enabled.
|
||||||
|
The issue was the utmp wasn't filled in, the long option checked, the
|
||||||
|
short option did not.
|
||||||
|
|
||||||
|
Refactored the showinfo() function so instead of a branch with duplicate
|
||||||
|
prints for the items in both long and short we just branch on the items
|
||||||
|
for long output.
|
||||||
|
|
||||||
|
Also, made the function prototypes not dependendent on systemd enabled,
|
||||||
|
it was too messy that way and passing a char* NULL is not really going
|
||||||
|
to hurt anything.
|
||||||
|
|
||||||
|
References:
|
||||||
|
#301
|
||||||
|
|
||||||
|
Signed-off-by: Craig Small <csmall@dropbear.xyz>
|
||||||
|
---
|
||||||
|
NEWS | 1 +
|
||||||
|
src/w.c | 61 ++++++++++++++++++++-------------------------------------
|
||||||
|
2 files changed, 22 insertions(+), 40 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/NEWS b/NEWS
|
||||||
|
index 4ad9f74e..883f9139 100644
|
||||||
|
--- a/NEWS
|
||||||
|
+++ b/NEWS
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
procps-ng-NEXT
|
||||||
|
---------------
|
||||||
|
+ * w: Don't segfault with -s option issue #301
|
||||||
|
|
||||||
|
procps-ng-4.0.4
|
||||||
|
---------------
|
||||||
|
diff --git a/src/w.c b/src/w.c
|
||||||
|
index fd6e75f7..e2d754b5 100644
|
||||||
|
--- a/src/w.c
|
||||||
|
+++ b/src/w.c
|
||||||
|
@@ -207,9 +207,7 @@ static void print_display_or_interface(const char *restrict host, int len, int r
|
||||||
|
|
||||||
|
/* This routine prints either the hostname or the IP address of the remote */
|
||||||
|
static void print_from(
|
||||||
|
-#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
const char *session,
|
||||||
|
-#endif
|
||||||
|
const utmp_t *restrict const u, const int ip_addresses, const int fromlen) {
|
||||||
|
#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
if (session) {
|
||||||
|
@@ -508,11 +506,10 @@ static int find_best_proc(
|
||||||
|
#undef PIDS_GETSTR
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
static void showinfo(
|
||||||
|
-#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
const char *session, const char *name,
|
||||||
|
-#endif
|
||||||
|
- utmp_t * u, int formtype, int maxcmd, int from,
|
||||||
|
+ utmp_t * u, const int longform, int maxcmd, int from,
|
||||||
|
const int userlen, const int fromlen, const int ip_addresses,
|
||||||
|
const int pids)
|
||||||
|
{
|
||||||
|
@@ -575,25 +572,20 @@ static void showinfo(
|
||||||
|
/* force NUL term for printf */
|
||||||
|
uname[UT_NAMESIZE] = '\0';
|
||||||
|
|
||||||
|
- if (formtype) {
|
||||||
|
- printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, tty + 5);
|
||||||
|
+ printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, tty + 5);
|
||||||
|
+ if (from)
|
||||||
|
+ print_from(session, NULL, ip_addresses, fromlen);
|
||||||
|
+
|
||||||
|
+ /* login time */
|
||||||
|
+ if (longform) {
|
||||||
|
#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
if (session) {
|
||||||
|
uint64_t ltime;
|
||||||
|
|
||||||
|
- if (from)
|
||||||
|
- print_from(session, NULL, ip_addresses, fromlen);
|
||||||
|
-
|
||||||
|
sd_session_get_start_time(session, <ime);
|
||||||
|
print_logintime(ltime/((uint64_t) 1000000ULL), stdout);
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
- if (from)
|
||||||
|
- print_from(
|
||||||
|
-#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
- NULL,
|
||||||
|
-#endif
|
||||||
|
- u, ip_addresses, fromlen);
|
||||||
|
|
||||||
|
#ifdef HAVE_UTMPX_H
|
||||||
|
print_logintime(u->ut_tv.tv_sec, stdout);
|
||||||
|
@@ -603,11 +595,16 @@ static void showinfo(
|
||||||
|
#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
- if (u && *u->ut_line == ':')
|
||||||
|
- /* idle unknown for xdm logins */
|
||||||
|
- printf(" ?xdm? ");
|
||||||
|
- else
|
||||||
|
- print_time_ival7(idletime(tty), 0, stdout);
|
||||||
|
+ }
|
||||||
|
+ /* idle */
|
||||||
|
+ if (u && *u->ut_line == ':')
|
||||||
|
+ /* idle unknown for xdm logins */
|
||||||
|
+ printf(" ?xdm? ");
|
||||||
|
+ else
|
||||||
|
+ print_time_ival7(idletime(tty), 0, stdout);
|
||||||
|
+
|
||||||
|
+ /* jpcpu/pcpu */
|
||||||
|
+ if (longform) {
|
||||||
|
print_time_ival7(jcpu / hertz, (jcpu % hertz) * (100. / hertz),
|
||||||
|
stdout);
|
||||||
|
if (pcpu > 0)
|
||||||
|
@@ -616,20 +613,8 @@ static void showinfo(
|
||||||
|
stdout);
|
||||||
|
else
|
||||||
|
printf(" ? ");
|
||||||
|
- } else {
|
||||||
|
- printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, tty + 5);
|
||||||
|
- if (from)
|
||||||
|
- print_from(
|
||||||
|
-#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
- NULL,
|
||||||
|
-#endif
|
||||||
|
- u, ip_addresses, fromlen);
|
||||||
|
- if (u && *u->ut_line == ':')
|
||||||
|
- /* idle unknown for xdm logins */
|
||||||
|
- printf(" ?xdm? ");
|
||||||
|
- else
|
||||||
|
- print_time_ival7(idletime(tty), 0, stdout);
|
||||||
|
}
|
||||||
|
+ /* what */
|
||||||
|
if (pids) {
|
||||||
|
pid_t ut_pid = -1;
|
||||||
|
if (u)
|
||||||
|
@@ -798,9 +783,9 @@ int main(int argc, char **argv)
|
||||||
|
* headers. Try to keep alignment intact. */
|
||||||
|
printf(_("%-*s TTY "), userlen, _("USER"));
|
||||||
|
if (from)
|
||||||
|
- printf("%-*s", fromlen - 1, _("FROM"));
|
||||||
|
+ printf("%-*s", fromlen, _("FROM"));
|
||||||
|
if (longform)
|
||||||
|
- printf(_(" LOGIN@ IDLE JCPU PCPU WHAT\n"));
|
||||||
|
+ printf(_(" LOGIN@ IDLE JCPU PCPU WHAT\n"));
|
||||||
|
else
|
||||||
|
printf(_(" IDLE WHAT\n"));
|
||||||
|
}
|
||||||
|
@@ -857,9 +842,7 @@ int main(int argc, char **argv)
|
||||||
|
continue;
|
||||||
|
if (!strncmp(u->ut_user, user, UT_NAMESIZE))
|
||||||
|
showinfo(
|
||||||
|
-#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
NULL, NULL,
|
||||||
|
-#endif
|
||||||
|
u, longform, maxcmd, from, userlen,
|
||||||
|
fromlen, ip_addresses, pids);
|
||||||
|
}
|
||||||
|
@@ -876,9 +859,7 @@ int main(int argc, char **argv)
|
||||||
|
continue;
|
||||||
|
if (*u->ut_user)
|
||||||
|
showinfo(
|
||||||
|
-#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
|
||||||
|
NULL, NULL,
|
||||||
|
-#endif
|
||||||
|
u, longform, maxcmd, from, userlen,
|
||||||
|
fromlen, ip_addresses, pids);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
GitLab
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
pkgname=procps-ng
|
pkgname=procps-ng
|
||||||
pkgver=4.0.4
|
pkgver=4.0.4
|
||||||
pkgrel=01
|
pkgrel=02
|
||||||
pkgdesc='Utilities for monitoring your system and its processes w/o systemd'
|
pkgdesc='Utilities for monitoring your system and its processes w/o systemd'
|
||||||
url='https://gitlab.com/procps-ng/procps'
|
url='https://gitlab.com/procps-ng/procps'
|
||||||
depends=(glibc ncurses libncursesw.so)
|
depends=(glibc ncurses libncursesw.so)
|
||||||
|
@ -16,13 +16,15 @@ provides=(procps sysvinit-tools libproc2.so)
|
||||||
replaces=(procps sysvinit-tools)
|
replaces=(procps sysvinit-tools)
|
||||||
options=('!emptydirs')
|
options=('!emptydirs')
|
||||||
source=(https://downloads.sourceforge.net/project/$pkgname/Production/${pkgname}-${pkgver}.tar.xz{,.asc}
|
source=(https://downloads.sourceforge.net/project/$pkgname/Production/${pkgname}-${pkgver}.tar.xz{,.asc}
|
||||||
'sysctl.conf')
|
'sysctl.conf'
|
||||||
# 0001-build-sys-Add-systemd-elogind-to-w.patch)
|
0001-build-sys-Add-systemd-elogind-to-w.patch
|
||||||
|
0002-ps-Don-t-crash-when-using-short-option.patch)
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
cd procps-ng-$pkgver
|
cd procps-ng-$pkgver
|
||||||
sed 's:<ncursesw/:<:g' -i src/watch.c
|
sed 's:<ncursesw/:<:g' -i src/watch.c
|
||||||
|
patch -Np1 < ../0001-build-sys-Add-systemd-elogind-to-w.patch
|
||||||
|
patch -Np1 < ../0002-ps-Don-t-crash-when-using-short-option.patch
|
||||||
autoreconf -fi
|
autoreconf -fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ validpgpkeys=(5D2FB320B825D93904D205193938F96BDF50FEA5) # Craig Small <csmall@de
|
||||||
|
|
||||||
sha256sums=(22870d6feb2478adb617ce4f09a787addaf2d260c5a8aa7b17d889a962c5e42e # procps-ng-4.0.4.tar.xz
|
sha256sums=(22870d6feb2478adb617ce4f09a787addaf2d260c5a8aa7b17d889a962c5e42e # procps-ng-4.0.4.tar.xz
|
||||||
ff4787b2f45cc99d06e7c6d8e00a55d45ba942a3cc7e1f3ef6720b0dd091e077 # procps-ng-4.0.4.tar.xz.asc
|
ff4787b2f45cc99d06e7c6d8e00a55d45ba942a3cc7e1f3ef6720b0dd091e077 # procps-ng-4.0.4.tar.xz.asc
|
||||||
1bba9d009539f9fe18c19f5c4f4272da276f5c13c8b21e7291baf2374deb5d24) # sysctl.conf
|
1bba9d009539f9fe18c19f5c4f4272da276f5c13c8b21e7291baf2374deb5d24 # sysctl.conf
|
||||||
|
77ed82ad684c71319704080a09c7d65efa1b06db4f35b240de7c30fef4caafc5 # 0001-build-sys-Add-systemd-elogind-to-w.patch
|
||||||
|
2331953f1c859b4973b2f99fbc84495b03a2d5e584370da66adbd45cbbf7825a) # 0002-ps-Don-t-crash-when-using-short-option.patch
|
||||||
|
|
||||||
## e8b208e66a6e7819265b94bc04b97d654b5ac2cc6f345537ccc9054adda80c01 procps-ng-4.0.4-01-x86_64.pkg.tar.lz
|
## 95ee18523f49cddfbb918d09f9f2581a4251738fda9acfca8a7af09a4effe6ee procps-ng-4.0.4-02-x86_64.pkg.tar.lz
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
pkgname=procps-ng
|
pkgname=procps-ng
|
||||||
pkgver=4.0.4
|
pkgver=4.0.4
|
||||||
pkgrel=1
|
pkgrel=2
|
||||||
pkgdesc='Utilities for monitoring your system and its processes'
|
pkgdesc='Utilities for monitoring your system and its processes'
|
||||||
url='https://gitlab.com/procps-ng/procps'
|
url='https://gitlab.com/procps-ng/procps'
|
||||||
license=(GPL LGPL)
|
license=(GPL LGPL)
|
||||||
|
@ -19,18 +19,22 @@ replaces=(procps sysvinit-tools)
|
||||||
options=('!emptydirs')
|
options=('!emptydirs')
|
||||||
validpgpkeys=('5D2FB320B825D93904D205193938F96BDF50FEA5') # Craig Small <csmall@debian.org>
|
validpgpkeys=('5D2FB320B825D93904D205193938F96BDF50FEA5') # Craig Small <csmall@debian.org>
|
||||||
source=(https://downloads.sourceforge.net/project/$pkgname/Production/${pkgname}-${pkgver}.tar.xz{,.asc}
|
source=(https://downloads.sourceforge.net/project/$pkgname/Production/${pkgname}-${pkgver}.tar.xz{,.asc}
|
||||||
0001-build-sys-Add-systemd-elogind-to-w.patch)
|
0001-build-sys-Add-systemd-elogind-to-w.patch
|
||||||
|
0002-ps-Don-t-crash-when-using-short-option.patch)
|
||||||
sha256sums=('22870d6feb2478adb617ce4f09a787addaf2d260c5a8aa7b17d889a962c5e42e'
|
sha256sums=('22870d6feb2478adb617ce4f09a787addaf2d260c5a8aa7b17d889a962c5e42e'
|
||||||
'SKIP'
|
'SKIP'
|
||||||
'77ed82ad684c71319704080a09c7d65efa1b06db4f35b240de7c30fef4caafc5')
|
'77ed82ad684c71319704080a09c7d65efa1b06db4f35b240de7c30fef4caafc5'
|
||||||
|
'2331953f1c859b4973b2f99fbc84495b03a2d5e584370da66adbd45cbbf7825a')
|
||||||
b2sums=('63b972666ef9e92042be96739ffa15c787d0346b2d3ffcb0d240b0a4e999dc90024b2c5b058df683dd9d2c436ceb812abd0b115cc877a6ca1023988b86de443f'
|
b2sums=('63b972666ef9e92042be96739ffa15c787d0346b2d3ffcb0d240b0a4e999dc90024b2c5b058df683dd9d2c436ceb812abd0b115cc877a6ca1023988b86de443f'
|
||||||
'SKIP'
|
'SKIP'
|
||||||
'021b64fac3b48175ec67d180fc294c674088ece483f0ab358c2cfbdbd519ac6dea13274a66624beda79b00c0c770441e7f8369f3a75a90f7cafd469508a81e16')
|
'021b64fac3b48175ec67d180fc294c674088ece483f0ab358c2cfbdbd519ac6dea13274a66624beda79b00c0c770441e7f8369f3a75a90f7cafd469508a81e16'
|
||||||
|
'74a40306c3a1c09d1ad26ae34157803e48e95906febcd4730ac27221e5c6184b9fe1eb7ade77e2da193d4c3491d719b1a1b01f75424722a63602f914aa9db9a8')
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
cd procps-ng-$pkgver
|
cd procps-ng-$pkgver
|
||||||
sed 's:<ncursesw/:<:g' -i src/watch.c
|
sed 's:<ncursesw/:<:g' -i src/watch.c
|
||||||
patch -Np1 < ../0001-build-sys-Add-systemd-elogind-to-w.patch
|
patch -Np1 < ../0001-build-sys-Add-systemd-elogind-to-w.patch
|
||||||
|
patch -Np1 < ../0002-ps-Don-t-crash-when-using-short-option.patch
|
||||||
autoreconf -fi
|
autoreconf -fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
autoconf
|
autoconf
|
||||||
gettext
|
gettext
|
||||||
automake
|
automake
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue