Sync from SUSE:ALP:Source:Standard:1.0 procps revision 4ce427c82fbf58eedd37dd3607aae2eb

This commit is contained in:
Adrian Schröter 2023-12-21 13:43:04 +01:00
commit 3ab5795613
33 changed files with 4477 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

102
CVE-2023-4016.patch Normal file
View File

@ -0,0 +1,102 @@
From 2c933ecba3bb1d3041a5a7a53a7b4078a6003413 Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Thu, 10 Aug 2023 21:18:38 +1000
Subject: [PATCH] ps: Fix possible buffer overflow in -C option
ps allocates memory using malloc(length of arg * len of struct).
In certain strange circumstances, the arg length could be very large
and the multiplecation will overflow, allocating a small amount of
memory.
Subsequent strncpy() will then write into unallocated memory.
The fix is to use calloc. It's slower but this is a one-time
allocation. Other malloc(x * y) calls have also been replaced
by calloc(x, y)
References:
https://www.freelists.org/post/procps/ps-buffer-overflow-CVE-20234016
https://nvd.nist.gov/vuln/detail/CVE-2023-4016
https://gitlab.com/procps-ng/procps/-/issues/297
https://bugs.debian.org/1042887
Signed-off-by: Craig Small <csmall@dropbear.xyz>
---
ps/parser.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
--- ps/parser.c
+++ ps/parser.c 2023-08-15 12:19:13.375422122 +0000
@@ -183,8 +183,7 @@ static const char *parse_list(const char
int need_item;
const char *err; /* error code that could or did happen */
/*** prepare to operate ***/
- node = malloc(sizeof(selection_node));
- node->u = malloc(strlen(arg)*sizeof(sel_union)); /* waste is insignificant */
+ node = xmalloc(sizeof(selection_node));
node->n = 0;
buf = strdup(arg);
/*** sanity check and count items ***/
@@ -205,6 +204,7 @@ static const char *parse_list(const char
} while (*++walk);
if(need_item) goto parse_error;
node->n = items;
+ node->u = xcalloc(items*sizeof(sel_union));
/*** actually parse the list ***/
walk = buf;
while(items--){
@@ -569,8 +569,8 @@ static const char *parse_bsd_option(void
/* put our tty on a tiny list */
{
selection_node *node;
- node = malloc(sizeof(selection_node));
- node->u = malloc(sizeof(sel_union));
+ node = xmalloc(sizeof(selection_node));
+ node->u = xmalloc(sizeof(sel_union));
node->u[0].tty = cached_tty;
node->typecode = SEL_TTY;
node->n = 1;
@@ -706,8 +706,8 @@ static const char *parse_bsd_option(void
if(!arg){
/* Wow, obsolete BSD syntax. Put our tty on a tiny list. */
selection_node *node;
- node = malloc(sizeof(selection_node));
- node->u = malloc(sizeof(sel_union));
+ node = xmalloc(sizeof(selection_node));
+ node->u = xmalloc(sizeof(sel_union));
node->u[0].tty = cached_tty;
node->typecode = SEL_TTY;
node->n = 1;
@@ -1030,16 +1030,16 @@ static const char *parse_trailing_pids(v
argp = ps_argv + thisarg;
thisarg = ps_argc - 1; /* we must be at the end now */
- pidnode = malloc(sizeof(selection_node));
- pidnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
+ pidnode = xmalloc(sizeof(selection_node));
+ pidnode->u = xcalloc(i*sizeof(sel_union)); /* waste is insignificant */
pidnode->n = 0;
- grpnode = malloc(sizeof(selection_node));
- grpnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
+ grpnode = xmalloc(sizeof(selection_node));
+ grpnode->u = xcalloc(i*sizeof(sel_union)); /* waste is insignificant */
grpnode->n = 0;
- sidnode = malloc(sizeof(selection_node));
- sidnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
+ sidnode = xmalloc(sizeof(selection_node));
+ sidnode->u = xcalloc(i*sizeof(sel_union)); /* waste is insignificant */
sidnode->n = 0;
while(i--){
--- proc/libprocps.sym
+++ proc/libprocps.sym 2023-08-15 12:43:18.905661726 +0000
@@ -67,6 +67,8 @@ global:
unix_print_signals;
uptime;
xalloc_err_handler;
+ xcalloc;
+ xmalloc;
local:
*;
};

33
bsc1195468-23da4f40.patch Normal file
View File

@ -0,0 +1,33 @@
From 23da4f40ea27afe998e92ca317f2dcb48a6ffc1f Mon Sep 17 00:00:00 2001
From: Tommi Rantala <tommi.t.rantala@nokia.com>
Date: Mon, 11 Oct 2021 13:33:18 +0300
Subject: [PATCH] ps: ignore SIGURG
Stop registering signal handler for SIGURG, to avoid ps failure if
someone sends such signal. Without the signal handler, SIGURG will
just be ignored.
Signal 23 (URG) caught by ps (3.3.16).
ps:ps/display.c:66: please report this bug
https://man7.org/linux/man-pages/man7/signal.7.html
https://www.freebsd.org/cgi/man.cgi?sektion=3&query=signal
---
ps/display.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ps/display.c b/ps/display.c
index 04803c3b..346e21a7 100644
--- a/ps/display.c
+++ b/ps/display.c
@@ -673,6 +673,7 @@ int main(int argc, char *argv[]){
case SIGKILL: /* can not catch */
case SIGSTOP: /* can not catch */
case SIGWINCH: /* don't care if window size changes */
+ case SIGURG: /* Urgent condition on socket (4.2BSD) */
;
}
} while (0);
--
GitLab

View File

@ -0,0 +1,45 @@
From 3dd1661a3d91671ca6c977c2e514f47d807be79d Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Mon, 29 Mar 2021 22:11:27 +1100
Subject: [PATCH] docs: psr ps field is last run processor
The ps.1 manpage incorrectly stated that psr field showed the
processor the process was assigned to. However if the assignment
has changed but the process has not run, then the field doesn't
change.
Some digging by @srikard showed it wasn't the processor assigned
but the last one it was run on. The man page now correctly
describes psr in that way.
References:
procps-ng/procps#187
---
ps/ps.1 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git ps/ps.1 ps/ps.1
index 8678123..b433655 100644
--- ps/ps.1
+++ ps/ps.1
|@@ -4,7 +4,7 @@
| .\" Quick hack conversion by Albert Cahalan, 1998.
| .\" Licensed under version 2 of the Gnu General Public License.
| .\"
|-.TH PS "1" "2021-03-05" "procps-ng" "User Commands"
|+.TH PS "1" "2021-03-29" "procps-ng" "User Commands"
| .\"
| .\" To render this page:
| .\" groff -t -b -man -X -P-resolution -P100 -Tps ps.1 &
@@ -1518,7 +1518,7 @@ priority of the process. Higher number means lower priority.
T}
psr PSR T{
-processor that process is currently assigned to.
+processor that process last executed on.
T}
rgid RGID T{
--
2.26.2

View File

@ -0,0 +1,11 @@
--- procps-3.3.17/sysctl.c.old 2021-02-09 11:11:25.000000000 +0100
+++ procps-3.3.17/sysctl.c 2023-12-14 13:56:36.785976315 +0100
@@ -546,6 +546,8 @@
fp = (globbuf.gl_pathv[j][0] == '-' && !globbuf.gl_pathv[j][1])
? stdin : fopen(globbuf.gl_pathv[j], "r");
if (!fp) {
+ if (strcmp ("/usr/lib/sysctl.d/99-sysctl.conf", globbuf.gl_pathv[j]) == 0)
+ continue;
xwarn(_("cannot open \"%s\""), globbuf.gl_pathv[j]);
rc = -1;
goto out;

View File

@ -0,0 +1,41 @@
---
free.1 | 2 +-
proc/sysinfo.c | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
--- free.1
+++ free.1 2022-12-15 09:40:32.807087343 +0000
@@ -19,7 +19,7 @@ columns are:
Total installed memory (MemTotal and SwapTotal in /proc/meminfo)
.TP
\fBused\fR
-Used memory (calculated as \fBtotal\fR - \fBfree\fR - \fBbuffers\fR - \fBcache\fR)
+Used memory (calculated as \fBtotal\fR - \fBavailable\fR)
.TP
\fBfree\fR
Unused memory (MemFree and SwapFree in /proc/meminfo)
--- proc/sysinfo.c
+++ proc/sysinfo.c 2022-06-22 11:29:39.240066488 +0000
@@ -794,10 +794,6 @@ nextline:
where such values will be dramatically distorted over those of the host. */
if (kb_main_available > kb_main_total)
kb_main_available = kb_main_free;
- mem_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
- if (mem_used < 0)
- mem_used = kb_main_total - kb_main_free;
- kb_main_used = (unsigned long)mem_used;
/* zero? might need fallback for 2.6.27 <= kernel <? 3.14 */
if (!kb_main_available) {
@@ -821,6 +817,11 @@ nextline:
kb_main_available = kb_main_free;
#endif /* linux */
}
+
+ mem_used = kb_main_total - kb_main_available;
+ if (mem_used < 0)
+ mem_used = kb_main_total - kb_main_free;
+ kb_main_used = (unsigned long)mem_used;
}
/*****************************************************************/

View File

@ -0,0 +1,37 @@
---
top/top.1 | 4 ++--
top/top.c | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)
--- top/top.1
+++ top/top.1 2022-06-22 12:05:55.572154830 +0000
@@ -565,8 +565,8 @@ visual graphs of those representations.
In the case of \*(MP, the percentage represents the \fBtotal\fR minus the estimated
\fBavail\fR noted above.
-The `Mem' graph itself is divided between \fBused\fR and any remaining memory not
-otherwise accounted for by \fBavail\fR.
+The `Mem' graph itself is divided between the non-cached portion of \fBused\fR and
+any remaining memory not otherwise accounted for by \fBavail\fR.
\*(XT 4b. SUMMARY AREA Commands and the `m' command for additional information
on that special 4-way toggle.
--- top/top.c
+++ top/top.c 2022-06-22 12:03:17.911044097 +0000
@@ -6086,12 +6086,14 @@ numa_nope:
char used[SMLBUFSIZ], util[SMLBUFSIZ], dual[MEDBUFSIZ];
float pct_used, pct_misc, pct_swap;
int ix, num_used, num_misc;
+ unsigned long my_ulong;
- pct_used = (float)kb_main_used * (100.0 / (float)kb_main_total);
+ my_ulong = kb_main_total - kb_main_buffers - kb_main_cached - kb_main_free;
+ pct_used = (float)my_ulong * (100.0 / (float)kb_main_total);
#ifdef MEMGRAPH_OLD
pct_misc = (float)(kb_main_buffers + kb_main_cached) * (100.0 / (float)kb_main_total);
#else
- pct_misc = (float)(kb_main_total - kb_main_available - kb_main_used) * (100.0 / (float)kb_main_total);
+ pct_misc = (float)(kb_main_total - kb_main_available - my_ulong) * (100.0 / (float)kb_main_total);
#endif
if (pct_used + pct_misc > 100.0 || pct_misc < 0) pct_misc = 0;
pct_swap = kb_swap_total ? (float)kb_swap_used * (100.0 / (float)kb_swap_total) : 0;

View File

@ -0,0 +1,61 @@
---
proc/libprocps.sym | 1 +
proc/sysinfo.c | 13 +++++++++++--
proc/sysinfo.h | 2 ++
3 files changed, 14 insertions(+), 2 deletions(-)
--- proc/libprocps.sym
+++ proc/libprocps.sym 2018-04-04 11:30:51.841725161 +0000
@@ -60,6 +60,7 @@ global:
signal_name_to_number;
signal_number_to_name;
smp_num_cpus;
+ __smp_num_cpus;
sprint_uptime;
strtosig;
tty_to_dev;
--- proc/sysinfo.c
+++ proc/sysinfo.c 2018-04-04 11:33:26.306886237 +0000
@@ -47,7 +47,8 @@
#endif
#include <elf.h>
-long smp_num_cpus; /* number of CPUs */
+#undef smp_num_cpus
+long smp_num_cpus=-1; /* number of CPUs */
long page_bytes; /* this architecture's page size */
#define BAD_OPEN_MESSAGE \
@@ -1166,7 +1167,11 @@ out:
///////////////////////////////////////////////////////////////////////////
-void cpuinfo (void) {
+long __smp_num_cpus (void) {
+
+ if (smp_num_cpus != -1)
+ return(smp_num_cpus);
+
// ought to count CPUs in /proc/stat instead of relying
// on glibc, which foolishly tries to parse /proc/cpuinfo
// note: that may have been the case but now /proc/stat
@@ -1181,4 +1186,8 @@ void cpuinfo (void) {
smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
if (smp_num_cpus<1) /* SPARC glibc is buggy */
smp_num_cpus=1;
+
+ return smp_num_cpus;
}
+
+void cpuinfo (void) { (void)__smp_num_cpus(); }
--- proc/sysinfo.h
+++ proc/sysinfo.h 2018-04-04 11:30:51.841725161 +0000
@@ -8,6 +8,8 @@ EXTERN_C_BEGIN
extern unsigned long long Hertz; /* clock tick frequency */
extern long smp_num_cpus; /* number of CPUs */
+extern long __smp_num_cpus(void);
+#define smp_num_cpus __smp_num_cpus()
extern int have_privs; /* boolean, true if setuid or similar */
extern long page_bytes; /* this architecture's bytes per page */

View File

@ -0,0 +1,48 @@
setlocale() sets errno to ENOENT ...
open("/usr/lib/locale/de_DE.UTF-8/LC_NUMERIC", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/de_DE.utf8/LC_NUMERIC", O_RDONLY|O_CLOEXEC) = 3
and this causes a problem later on (bsc#908516)
---
free.c | 5 +++++
1 file changed, 5 insertions(+)
--- free.c
+++ free.c 2018-04-04 12:47:06.360757839 +0000
@@ -197,6 +197,7 @@ int main(int argc, char **argv)
{
int c, flags = 0, unit_set = 0;
struct commandline_arguments args;
+ int errsv;
/*
* For long options that have no equivalent short option, use a
@@ -247,10 +248,12 @@ int main(int argc, char **argv)
#ifdef HAVE_PROGRAM_INVOCATION_NAME
program_invocation_name = program_invocation_short_name;
#endif
+ errsv = errno;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
atexit(close_stdout);
+ errno = errsv;
while ((c = getopt_long(argc, argv, "bkmghltCc:ws:V", longopts, NULL)) != -1)
switch (c) {
@@ -317,11 +320,13 @@ int main(int argc, char **argv)
break;
case 's':
flags |= FREE_REPEAT;
+ errsv = errno;
errno = 0;
args.repeat_interval = (1000000 * strtod_nol_or_err(optarg, "seconds argument failed"));
if (args.repeat_interval < 1)
xerrx(EXIT_FAILURE,
_("seconds argument `%s' is not positive number"), optarg);
+ errno = errsv;
break;
case 'c':
flags |= FREE_REPEAT;

View File

@ -0,0 +1,38 @@
---
vmstat.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
--- vmstat.c
+++ vmstat.c 2018-04-04 11:16:07.577968520 +0000
@@ -40,6 +40,7 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
#include <time.h>
@@ -708,13 +709,12 @@ static void slabheader(void)
static void slabformat(void)
{
- FILE *fSlab;
+ struct stat fSlab;
struct slab_cache *slabs;
unsigned long nSlab, i, j, k;
const char format[] = "%-24s %6u %6u %6u %6u\n";
- fSlab = fopen("/proc/slabinfo", "rb");
- if (!fSlab) {
+ if (stat("/proc/slabinfo", &fSlab) < 0) {
xwarnx(_("your kernel does not support slabinfo or your permissions are insufficient"));
return;
}
@@ -746,7 +746,6 @@ static void slabformat(void)
}
free(slabs);
}
- fclose(fSlab);
}
static void disksum_format(void)

View File

@ -0,0 +1,61 @@
---
free.c | 19 ++++++++++++++++---
proc/sysinfo.c | 5 ++++-
2 files changed, 20 insertions(+), 4 deletions(-)
--- free.c
+++ free.c 2021-02-10 09:58:35.409695062 +0000
@@ -134,7 +134,7 @@ static const char *scale_size(unsigned l
if (args.exponent > 1) {
/* In desired scale. */
snprintf(buf, sizeof(buf), "%ld",
- (long int)((size * 1024.0) / power(base, args.exponent-1))
+ (long int)(((long long int)size * 1024) / power(base, args.exponent-1))
);
return buf;
}
@@ -381,15 +381,28 @@ int main(int argc, char **argv)
* to print the high info, even if it is zero.
*/
if (flags & FREE_LOHI) {
+ unsigned long kb_low_used;
+ unsigned long kb_high_used;
+
+ if (kb_low_total > kb_low_free)
+ kb_low_used = kb_low_total - kb_low_free;
+ else
+ kb_low_used = 0;
+
+ if (kb_high_total > kb_high_free)
+ kb_high_used = kb_high_total - kb_high_free;
+ else
+ kb_high_used = 0;
+
printf("%-9s", _("Low:"));
printf("%11s", scale_size(kb_low_total, flags, args));
- printf(" %11s", scale_size(kb_low_total - kb_low_free, flags, args));
+ printf(" %11s", scale_size(kb_low_used, flags, args));
printf(" %11s", scale_size(kb_low_free, flags, args));
printf("\n");
printf("%-9s", _("High:"));
printf("%11s", scale_size(kb_high_total, flags, args));
- printf(" %11s", scale_size(kb_high_total - kb_high_free, flags, args));
+ printf(" %11s", scale_size(kb_high_used, flags, args));
printf(" %11s", scale_size(kb_high_free, flags, args));
printf("\n");
}
--- proc/sysinfo.c
+++ proc/sysinfo.c 2021-02-10 10:00:35.227385913 +0000
@@ -783,7 +783,10 @@ nextline:
kb_main_cached = kb_page_cache + kb_slab_reclaimable;
if ((ev=getenv("PS_FULL_CACHE")))
kb_main_cached += kb_swap_cached + kb_nfs_unstable;
- kb_swap_used = kb_swap_total - kb_swap_free;
+ if (kb_swap_total > kb_swap_free)
+ kb_swap_used = kb_swap_total - kb_swap_free;
+ else
+ kb_swap_used = 0;
/* if kb_main_available is greater than kb_main_total or our calculation of
mem_used overflows, that's symptomatic of running within a lxc container

View File

@ -0,0 +1,19 @@
---
top/top.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- top/top.c
+++ top/top.c 2018-04-04 12:09:16.087193018 +0000
@@ -2404,7 +2404,11 @@ static void zap_fieldstab (void) {
Cpu_pmax = 99.9;
if (Rc.mode_irixps && smp_num_cpus > 1 && !Thread_mode) {
Cpu_pmax = 100.0 * smp_num_cpus;
- if (smp_num_cpus > 10) {
+ if (smp_num_cpus > 1000) {
+ if (Cpu_pmax > 9999999.0) Cpu_pmax = 9999999.0;
+ } else if (smp_num_cpus > 100) {
+ if (Cpu_pmax > 999999.0) Cpu_pmax = 999999.0;
+ } else if (smp_num_cpus > 10) {
if (Cpu_pmax > 99999.0) Cpu_pmax = 99999.0;
} else {
if (Cpu_pmax > 999.9) Cpu_pmax = 999.9;

115
procps-ng-3.3.10-slab.patch Normal file
View File

@ -0,0 +1,115 @@
---
free.1 | 6 ++++++
free.c | 7 ++++++-
proc/sysinfo.c | 4 ++++
vmstat.c | 6 +++++-
4 files changed, 21 insertions(+), 2 deletions(-)
--- free.1
+++ free.1 2019-12-11 06:20:16.659772479 +0000
@@ -100,6 +100,12 @@ Switch to the wide mode. The wide mode p
than 80 characters. In this mode \fBbuffers\fR and \fBcache\fR
are reported in two separate columns.
.TP
+\fB\-C\fR, \fB\-\-full\-cache\fR
+Add to the plain \fBCached\fR in-memory cache for files also more cache lines as
+the \fBNFS_Unstable\fR pages sent to the server, but not yet committed to stable storage
+and the \fBSwapCached\fR memory that once was swapped out but is swapped back.
+Can be also enabled by the environment variable \fBPS_FULL_CACHE\fR.
+.TP
\fB\-c\fR, \fB\-\-count\fR \fIcount\fR
Display the result
.I count
--- free.c
+++ free.c 2019-12-11 06:20:16.659772479 +0000
@@ -90,6 +90,7 @@ static void __attribute__ ((__noreturn__
fputs(_(" -t, --total show total for RAM + swap\n"), out);
fputs(_(" -s N, --seconds N repeat printing every N seconds\n"), out);
fputs(_(" -c N, --count N repeat printing N times, then exit\n"), out);
+ fputs(_(" -C, --full-cache add further cache lines to main cache\n"), out);
fputs(_(" -w, --wide wide output\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(_(" --help display this help and exit\n"), out);
@@ -231,6 +232,7 @@ int main(int argc, char **argv)
{ "total", no_argument, NULL, 't' },
{ "seconds", required_argument, NULL, 's' },
{ "count", required_argument, NULL, 'c' },
+ { "full-cache",required_argument, NULL, HELP_OPTION },
{ "wide", no_argument, NULL, 'w' },
{ "help", no_argument, NULL, HELP_OPTION },
{ "version", no_argument, NULL, 'V' },
@@ -250,7 +252,7 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
atexit(close_stdout);
- while ((c = getopt_long(argc, argv, "bkmghltc:ws:V", longopts, NULL)) != -1)
+ while ((c = getopt_long(argc, argv, "bkmghltCc:ws:V", longopts, NULL)) != -1)
switch (c) {
case 'b':
check_unit_set(&unit_set);
@@ -333,6 +335,9 @@ int main(int argc, char **argv)
case 'w':
flags |= FREE_WIDE;
break;
+ case 'C':
+ setenv("PS_FULL_CACHE", "yes", 1);
+ break;
case HELP_OPTION:
usage(stdout);
case 'V':
--- proc/sysinfo.c
+++ proc/sysinfo.c 2019-12-11 06:20:16.659772479 +0000
@@ -3,6 +3,7 @@
* Copyright (C) 1992-1998 by Michael K. Johnson, johnsonm@redhat.com
* Copyright 1998-2003 Albert Cahalan
* June 2003, Fabian Frederick, disk and slab info
+ * Copyright (c) 2008 Bart Van Assche.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -700,6 +701,7 @@ void meminfo(void){
int linux_version_code = procps_linux_version();
mem_table_struct findme = { namebuf, NULL};
mem_table_struct *found;
+ const char *ev;
char *head;
char *tail;
static const mem_table_struct mem_table[] = {
@@ -779,6 +781,8 @@ nextline:
kb_inactive = kb_inact_dirty + kb_inact_clean + kb_inact_laundry;
}
kb_main_cached = kb_page_cache + kb_slab_reclaimable;
+ if ((ev=getenv("PS_FULL_CACHE")))
+ kb_main_cached += kb_swap_cached + kb_nfs_unstable;
kb_swap_used = kb_swap_total - kb_swap_free;
/* if kb_main_available is greater than kb_main_total or our calculation of
--- vmstat.c
+++ vmstat.c 2019-12-11 06:22:44.716984764 +0000
@@ -103,6 +103,7 @@ static void __attribute__ ((__noreturn__
fputs(_(" -p, --partition <dev> partition specific statistics\n"), out);
fputs(_(" -S, --unit <char> define display unit\n"), out);
fputs(_(" -w, --wide wide output\n"), out);
+ fputs(_(" -C, --full-cache add further cache lines to main cache\n"), out);
fputs(_(" -t, --timestamp show timestamp\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
@@ -899,7 +900,7 @@ int main(int argc, char *argv[])
atexit(close_stdout);
while ((c =
- getopt_long(argc, argv, "afmnsdDp:S:wthV", longopts,
+ getopt_long(argc, argv, "aCfmnsdDp:S:wthV", longopts,
NULL)) != -1)
switch (c) {
case 'V':
@@ -968,6 +969,9 @@ int main(int argc, char *argv[])
case 't':
t_option = 1;
break;
+ case 'C':
+ setenv("PS_FULL_CACHE", "yes", 1);
+ break;
default:
/* no other aguments defined yet. */
usage(stderr);

29
procps-ng-3.3.10-xen.dif Normal file
View File

@ -0,0 +1,29 @@
--- vmstat.c
+++ vmstat.c 2015-01-27 14:57:19.467491788 +0000
@@ -295,7 +295,7 @@ static void new_format(void)
unsigned int intr[2], ctxt[2];
unsigned int sleep_half;
unsigned long kb_per_page = sysconf(_SC_PAGESIZE) / 1024ul;
- int debt = 0; /* handle idle ticks running backwards */
+ long long debt = 0; /* handle idle ticks running backwards */
struct tm *tm_ptr;
time_t the_time;
char timebuf[32];
@@ -386,12 +386,12 @@ static void new_format(void)
/* idle can run backwards for a moment -- kernel "feature" */
if (debt) {
- didl = (int)didl + debt;
- debt = 0;
+ didl = (long long)didl + debt;
+ debt = 0LL;
}
- if ((int)didl < 0) {
- debt = (int)didl;
- didl = 0;
+ if ((long long)didl < 0) {
+ debt = (long long)didl;
+ didl = 0ULL;
}
Div = duse + dsys + didl + diow + dstl;

View File

@ -0,0 +1,216 @@
---
pmap.c | 47 ++++++++++++++++++++++++++++++++-----------
testsuite/pmap.test/pmap.exp | 17 +++++++--------
2 files changed, 44 insertions(+), 20 deletions(-)
--- pmap.c
+++ pmap.c 2018-06-05 09:37:34.404294888 +0000
@@ -49,7 +49,9 @@ const char *nls_Address,
*nls_Kbytes,
*nls_Mode,
*nls_RSS,
- *nls_Dirty;
+ *nls_PSS,
+ *nls_Dirty,
+ *nls_Swap;
static void nls_initialize(void)
{
@@ -73,7 +75,9 @@ static void nls_initialize(void)
nls_Kbytes = _("Kbytes");
nls_Mode = _("Mode");
nls_RSS = _("RSS");
+ nls_PSS = _("PSS");
nls_Dirty = _("Dirty");
+ nls_Swap = _("Swap");
}
static int justify_print(const char *str, int width, int right)
@@ -141,10 +145,10 @@ static int d_option;
static int n_option;
static int N_option;
static int q_option;
-static int x_option;
+static int x_option = 1;
static int X_option;
-static int map_desc_showpath;
+static int map_desc_showpath = 1;
static unsigned shm_minor = ~0u;
@@ -522,12 +526,17 @@ static int one_proc(const proc_t * p)
char perms[32] = "";
const char *cp2 = NULL;
unsigned long long rss = 0ull;
+ unsigned long long pss = 0ull;
+ unsigned long long swap = 0ull;
unsigned long long private_dirty = 0ull;
unsigned long long shared_dirty = 0ull;
unsigned long long total_rss = 0ull;
+ unsigned long long total_pss = 0ull;
+ unsigned long long total_swap = 0ull;
unsigned long long total_private_dirty = 0ull;
unsigned long long total_shared_dirty = 0ull;
int maxw1=0, maxw2=0, maxw3=0, maxw4=0, maxw5=0;
+ int maxw6=0, maxw7=0;
/* Overkill, but who knows what is proper? The "w" prog uses
* the tty width to determine this.
@@ -557,13 +566,15 @@ static int one_proc(const proc_t * p)
if (x_option) {
maxw1 = 16;
if (sizeof(KLONG) == 4) maxw1 = 8;
- maxw2 = maxw3 = maxw4 = 7;
+ maxw2 = maxw3 = maxw4 = maxw6 = maxw7 = 7;
maxw5 = 5;
if (!q_option) {
maxw1 = justify_print(nls_Address, maxw1, 0);
maxw2 = justify_print(nls_Kbytes, maxw2, 1);
maxw3 = justify_print(nls_RSS, maxw3, 1);
+ maxw6 = justify_print(nls_PSS, maxw6, 1);
maxw4 = justify_print(nls_Dirty, maxw4, 1);
+ maxw7 = justify_print(nls_Swap, maxw7, 1);
maxw5 = justify_print(nls_Mode, maxw5, 0);
justify_print(nls_Mapping, 0, 0);
}
@@ -603,6 +614,11 @@ static int one_proc(const proc_t * p)
total_rss += smap_value;
continue;
}
+ if (strncmp("Pss", smap_key, 3) == 0) {
+ pss = smap_value;
+ total_pss += smap_value;
+ continue;
+ }
if (strcmp("Shared_Dirty", smap_key) == 0) {
shared_dirty = smap_value;
total_shared_dirty += smap_value;
@@ -615,15 +631,19 @@ static int one_proc(const proc_t * p)
}
if (strcmp("Swap", smap_key) == 0) {
/* doesn't matter as long as last */
- if (cp2) printf("%0*" KLF "x %*lu %*llu %*llu %*s %s\n",
+ swap = smap_value;
+ total_swap += smap_value;
+ if (cp2) printf("%0*" KLF "x %*lu %*llu %*llu %*llu %*llu %*s %s\n",
maxw1, start,
maxw2, (unsigned long)(diff >> 10),
maxw3, rss,
+ maxw6, pss,
maxw4, (private_dirty + shared_dirty),
+ maxw7, swap,
maxw5, perms,
cp2);
/* reset some counters */
- rss = shared_dirty = private_dirty = 0ull;
+ rss = pss = shared_dirty = private_dirty = swap = 0ull;
start = diff = end = 0;
perms[0] = '\0';
cp2 = NULL;
@@ -656,7 +676,6 @@ static int one_proc(const proc_t * p)
if (perms[3] == 's')
total_shared += diff;
if (perms[3] == 'p') {
- perms[3] = '-';
if (perms[1] == 'w')
total_private_writeable += diff;
else
@@ -708,17 +727,21 @@ static int one_proc(const proc_t * p)
justify_print("----------------", maxw1, 0);
justify_print("-------", maxw2, 1);
justify_print("-------", maxw3, 1);
+ justify_print("-------", maxw6, 1);
justify_print("-------", maxw4, 1);
+ justify_print("-------", maxw7, 1);
printf("\n");
printf("%-*s ", maxw1, _("total kB"));
- printf("%*ld %*llu %*llu\n",
+ printf("%*ld %*llu %*llu %*llu %*llu\n",
maxw2, (total_shared +
total_private_writeable +
total_private_readonly) >> 10,
maxw3, total_rss,
+ maxw6, total_pss,
maxw4, (total_shared_dirty +
- total_private_dirty));
+ total_private_dirty),
+ maxw7, total_swap);
}
if (d_option) {
printf
@@ -1028,16 +1051,18 @@ int main(int argc, char **argv)
while ((c = getopt_long(argc, argv, "xXrdqA:hVcC:nN:p", longopts, NULL)) != -1)
switch (c) {
case 'x':
- x_option = 1;
+ x_option = !x_option;
break;
case 'X':
X_option++;
+ x_option = 0;
break;
case 'r':
xwarnx(_("option -r is ignored as SunOS compatibility"));
break;
case 'd':
- d_option = 1;
+ d_option = !d_option;
+ x_option = 0;
break;
case 'q':
q_option = 1;
--- testsuite/pmap.test/pmap.exp
+++ testsuite/pmap.test/pmap.exp 2018-06-05 09:23:53.955370363 +0000
@@ -8,16 +8,16 @@ set pmap_procname "${mypid}:\\s+\\S+\[^\
set pmap_initname "1:\\s+\\S+\[^\\r\]+\\s+"
set pmap_std_header $pmap_procname
set pmap_device_header "${pmap_procname}Address\\s+Kbytes\\s+Mode\\s+Offset\\s+Device\\s+Mapping\\s+"
-set pmap_ext_header "${pmap_procname}Address\\s+Kbytes\\s+RSS\\s+Dirty\\s+Mode\\s+Mapping\\s+"
+set pmap_ext_header "${pmap_procname}Address\\s+Kbytes\\s+RSS\\s+PSS\\s+Dirty\\s+Swap\\s+Mode\\s+Mapping\\s+"
set pmap_generic_header "${pmap_procname}\\s+\(?:\[A-Z\]\[a-z\]+ +\)+"
-set pmap_std_items "\(\[0-9a-f\]+\\s+\\d+K \[rwx-\]{5}\\s+\\S+\[^\\r\]+\\s*\)+"
-set pmap_device_items "\(\[0-9a-f\]+\\s+\\d+ \[rwx-\]{5}\\s+\[0-9a-f\]+\\s+\[0-9a-f\]{3}:\[0-9a-f\]{5}\\s+\\S+\[^\\r\]+\\s*\)+"
-set pmap_ext_items "\(\[0-9a-f\]+\\s+\\d+\\s+\\d+\\s+\\d+ \[rwx-\]{5}\\s+\\S+\[^\\r\]+\\s*\)+"
+set pmap_std_items "\(\[0-9a-f\]+\\s+\\d+K \[rwxp-\]{5}\\s+\\S+\[^\\r\]+\\s*\)+"
+set pmap_device_items "\(\[0-9a-f\]+\\s+\\d+ \[rwxp-\]{5}\\s+\[0-9a-f\]+\\s+\[0-9a-f\]{3}:\[0-9a-f\]{5}\\s+\\S+\[^\\r\]+\\s*\)+"
+set pmap_ext_items "\(\[0-9a-f\]+\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+ \[rwxp-\]{5}\\s+\\S+\[^\\r\]+\\s*\)+"
set pmap_std_footer "total\\s+\\d+K\\s*\$"
set pmap_device_footer "mapped:\\s+\\d+K\\s+writeable\/private:\\s+\\d+K\\s+shared:\\s+\\d+K\\s*\$"
-set pmap_ext_footer "\[ -\]+\\s+total kB\\s+\\d+(\\s+\[\\d-\]+){2,3}\\s*\$"
+set pmap_ext_footer "total kB\\s+\\d+(\\s+\[\\d-\]+){4,5}\\s*\$"
set test "pmap with no arguments"
spawn $pmap
@@ -26,17 +26,16 @@ expect_pass "$test" "Usage:\\s+\(lt-\)?p
set test "pmap standard output"
spawn $pmap $mypid
-expect_table $test $pmap_std_header $pmap_std_items $pmap_std_footer
+expect_table $test $pmap_ext_header $pmap_ext_items $pmap_ext_footer
set test "pmap standard output with quiet"
spawn $pmap -q $mypid
-expect_table $test $pmap_procname $pmap_std_items "\$"
+expect_table $test $pmap_procname $pmap_ext_items "\$"
set test "pmap device output"
spawn $pmap -d $mypid
expect_table $test $pmap_device_header $pmap_device_items $pmap_device_footer
-
set test "pmap device output quiet (dq)"
spawn $pmap -dq $mypid
expect_table $test $pmap_procname $pmap_device_items "\$"
@@ -47,7 +46,7 @@ expect_table $test $pmap_procname $pmap_
set test "pmap extended output"
spawn $pmap -x $mypid
-expect_table $test $pmap_ext_header $pmap_ext_items $pmap_ext_footer
+expect_table $test $pmap_std_header $pmap_std_items $pmap_std_footer
# -X and -XX have no real format as its dependent on smaps
set test "pmap extra extended output"

View File

@ -0,0 +1,407 @@
diff -ur procps-3.3.17/configure.ac procps-3.3.17-no-utmp/configure.ac
--- procps-3.3.17/configure.ac 2023-10-27 17:02:55.230522174 +0200
+++ procps-3.3.17-no-utmp/configure.ac 2023-10-27 17:05:56.027565296 +0200
@@ -214,6 +214,13 @@
AS_IF([test "x$with_systemd" != "xno"], [
PKG_CHECK_MODULES([SYSTEMD], [libsystemd])
AC_DEFINE(WITH_SYSTEMD, 1, [enable systemd support])
+
+ # The functions needed to replace utmp with logind are only available
+ # with systemd v254 or later.
+ old_LIBS="$LIBS"
+ LIBS="$LIBS $SYSTEMD_LIBS"
+ AC_CHECK_FUNCS([sd_session_get_leader])
+ LIBS="$old_LIBS"
])
AM_CONDITIONAL([WITH_SYSTEMD], [test x$with_systemd != xno])
diff -ur procps-3.3.17/proc/whattime.c procps-3.3.17-no-utmp/proc/whattime.c
--- procps-3.3.17/proc/whattime.c 2021-02-09 11:11:25.000000000 +0100
+++ procps-3.3.17-no-utmp/proc/whattime.c 2023-10-27 17:05:56.027565296 +0200
@@ -38,6 +38,15 @@
#include "whattime.h"
#include "sysinfo.h"
+#ifdef WITH_SYSTEMD
+#include <systemd/sd-daemon.h>
+#include <systemd/sd-login.h>
+#endif
+#ifdef WITH_ELOGIND
+#include <elogind/sd-daemon.h>
+#include <elogind/sd-login.h>
+#endif
+
static char buf[256];
static double av[3];
@@ -98,6 +107,11 @@
/* count the number of users */
numuser = 0;
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
+ if (sd_booted() > 0)
+ numuser = sd_get_sessions(NULL);
+ else {
+#endif
setutent();
while ((utmpstruct = getutent())) {
if ((utmpstruct->ut_type == USER_PROCESS) &&
@@ -105,6 +119,10 @@
numuser++;
}
endutent();
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
+ }
+#endif
+
pos += sprintf(buf + pos, "%2d user%s, ", numuser, numuser == 1 ? "" : "s");
Datei procps-3.3.17/screen.620TQo/23075..f05 ist ein Socket, während Datei procps-3.3.17-no-utmp/screen.620TQo/23075..f05 ein Socket ist.
diff -ur procps-3.3.17/w.c procps-3.3.17-no-utmp/w.c
--- procps-3.3.17/w.c 2023-10-27 17:02:55.194521966 +0200
+++ procps-3.3.17-no-utmp/w.c 2023-10-27 18:10:00.371042829 +0200
@@ -56,11 +56,22 @@
#include <time.h>
#include <unistd.h>
#ifdef HAVE_UTMPX_H
-# include <utmpx.h>
+#include <utmpx.h>
+#ifndef HAVE_UT_HOSTSIZE_IN_UTMPX
+#include <utmp.h>
+#endif
#else
# include <utmp.h>
#endif
#include <arpa/inet.h>
+#ifdef WITH_SYSTEMD
+# include <systemd/sd-login.h>
+# include <systemd/sd-daemon.h>
+#endif
+#ifdef WITH_ELOGIND
+# include <elogind/sd-login.h>
+# include <elogind/sd-daemon.h>
+#endif
static int ignoreuser = 0; /* for '-u' */
static int oldstyle = 0; /* for '-o' */
@@ -72,12 +83,6 @@
typedef struct utmp utmp_t;
#endif
-#if !defined(UT_HOSTSIZE) || defined(__UT_HOSTSIZE)
-# define UT_HOSTSIZE __UT_HOSTSIZE
-# define UT_LINESIZE __UT_LINESIZE
-# define UT_NAMESIZE __UT_NAMESIZE
-#endif
-
#ifdef W_SHOWFROM
# define FROM_STRING "on"
#else
@@ -198,7 +203,25 @@
/* This routine prints either the hostname or the IP address of the remote */
-static void print_from(const utmp_t *restrict const u, const int ip_addresses, const int fromlen) {
+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) {
+ char *host = NULL;
+ int r;
+
+ r = sd_session_get_remote_host(session, &host);
+ if (r < 0 || host == NULL)
+ print_host("", 0, fromlen);
+ else {
+ print_host(host, strlen(host), fromlen == 0?strlen(host):fromlen);
+ free(host);
+ }
+ } else {
+#endif
char buf[fromlen + 1];
char buf_ipv6[INET6_ADDRSTRLEN];
int len;
@@ -243,6 +266,9 @@
#else
print_host(u->ut_host, UT_HOSTSIZE, fromlen);
#endif
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ }
+#endif
}
@@ -341,7 +367,11 @@
* the user for that login session is doing currently. This the
* essential core of 'w'.
*/
-static const proc_t *getproc(const utmp_t * restrict const u,
+static const proc_t *getproc(
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ const char *session,
+#endif
+ const utmp_t * restrict const u,
const char *restrict const tty,
unsigned long long *restrict const jcpu,
int *restrict const found_utpid)
@@ -351,9 +381,16 @@
const proc_t *best = NULL;
const proc_t *secondbest = NULL;
unsigned uid = ~0U;
+ pid_t ut_pid = -1;
*found_utpid = 0;
if (!ignoreuser) {
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ if (session) {
+ if (sd_session_get_uid(session, &uid) < 0)
+ return 0;
+ } else {
+#endif
char buf[UT_NAMESIZE + 1];
/* pointer to static data */
struct passwd *passwd_data;
@@ -364,12 +401,21 @@
return NULL;
uid = passwd_data->pw_uid;
/* OK to have passwd_data go out of scope here */
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ }
+#endif
}
line = tty_to_dev(tty);
*jcpu = 0;
+ if (u)
+ ut_pid = u->ut_pid;
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ else
+ sd_session_get_leader(session, &ut_pid);
+#endif
for (; *pptr; pptr++) {
- const proc_t *restrict const tmp = *pptr;
- if (unlikely(tmp->tgid == u->ut_pid)) {
+ const proc_t *restrict const tmp = *pptr;
+ if (unlikely(tmp->tgid == ut_pid)) {
*found_utpid = 1;
if (!best)
best = tmp;
@@ -393,7 +439,11 @@
return best ? best : secondbest;
}
-static void showinfo(utmp_t * u, int formtype, int maxcmd, int from,
+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,
int userlen, int fromlen, const int ip_addresses)
{
unsigned long long jcpu;
@@ -402,14 +452,36 @@
char uname[UT_NAMESIZE + 1] = "", tty[5 + UT_LINESIZE + 1] = "/dev/";
const proc_t *best;
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ if (session) {
+ char *sd_tty;
+
+ if (sd_session_get_tty(session, &sd_tty) >= 0) {
+ for (i = 0; i < strlen (sd_tty); i++)
+ /* clean up tty if garbled */
+ if (isalnum(sd_tty[i]) || (sd_tty[i] == '/'))
+ tty[i + 5] = sd_tty[i];
+ else
+ tty[i + 5] = '\0';
+ free(sd_tty);
+ }
+ } else {
+#endif
for (i = 0; i < UT_LINESIZE; i++)
/* clean up tty if garbled */
if (isalnum(u->ut_line[i]) || (u->ut_line[i] == '/'))
tty[i + 5] = u->ut_line[i];
else
tty[i + 5] = '\0';
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ }
+#endif
- best = getproc(u, tty + 5, &jcpu, &ut_pid_found);
+ best = getproc(
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ session,
+#endif
+ u, tty + 5, &jcpu, &ut_pid_found);
/*
* just skip if stale utmp entry (i.e. login proc doesn't
@@ -420,26 +492,56 @@
if (!ut_pid_found)
return;
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ if (name)
+ strncpy(uname, name, UT_NAMESIZE);
+ else
+#endif
+ strncpy(uname, u->ut_user, UT_NAMESIZE);
/* force NUL term for printf */
- strncpy(uname, u->ut_user, UT_NAMESIZE);
+ uname[UT_NAMESIZE] = '\0';
if (formtype) {
- int utlnlen = 8;
- if (formtype > 1) {
- userlen = strnlen(uname, UT_NAMESIZE);
- fromlen = strnlen(u->ut_host, UT_HOSTSIZE);
- utlnlen = strnlen(u->ut_line, UT_LINESIZE);
- maxcmd = MAX_CMD_WIDTH;
+ int utlnlen = 8;
+ if (formtype > 1) {
+ userlen = strnlen(uname, UT_NAMESIZE);
+ if (u) {
+ fromlen = strnlen(u->ut_host, UT_HOSTSIZE);
+ utlnlen = strnlen(u->ut_line, UT_LINESIZE);
+ } else {
+ fromlen = 0;
+ utlnlen = strlen (tty+5);
}
- printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, u->ut_line);
+ maxcmd = MAX_CMD_WIDTH;
+ }
+ printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, tty+5);
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ if (session) {
+ uint64_t ltime;
+
if (from)
- print_from(u, ip_addresses, fromlen);
+ print_from(session, NULL, ip_addresses, fromlen);
+
+ sd_session_get_start_time(session, &ltime);
+ 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);
#else
print_logintime(u->ut_time, stdout);
#endif
- if (*u->ut_line == ':')
+#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
@@ -454,11 +556,15 @@
} else
printf(" ? ");
} else {
- printf("%-*.*s%-9.8s", userlen + 1, userlen, u->ut_user,
- u->ut_line);
+ printf("%-*.*s%-9.8s", userlen + 1, userlen, uname,
+ tty+5);
if (from)
- print_from(u, ip_addresses, fromlen);
- if (*u->ut_line == ':')
+ print_from(
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ session,
+#endif
+ u, ip_addresses, fromlen);
+ if (u && *u->ut_line == ':')
/* idle unknown for xdm logins */
printf(" ?xdm? ");
else
@@ -635,7 +741,40 @@
else
printf(_(" IDLE WHAT\n"));
}
-
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ if (sd_booted() > 0) {
+ char **sessions_list;
+ int sessions;
+ int i;
+
+ sessions = sd_get_sessions (&sessions_list);
+ if (sessions < 0 && sessions != -ENOENT)
+ error(EXIT_FAILURE, -sessions, _("error getting sessions"));
+
+ if (sessions >= 0) {
+ for (int i = 0; i < sessions; i++) {
+ char *name;
+ int r;
+
+ if ((r = sd_session_get_username(sessions_list[i], &name)) < 0)
+ error(EXIT_FAILURE, -r, _("get user name failed"));
+
+ if (user) {
+ if (!strcmp(name, user))
+ showinfo(sessions_list[i], name, NULL, longform,
+ maxcmd, from, userlen, fromlen,
+ ip_addresses);
+ } else {
+ showinfo(sessions_list[i], name, NULL, longform, maxcmd,
+ from, userlen, fromlen, ip_addresses);
+ }
+ free(name);
+ free(sessions_list[i]);
+ }
+ free(sessions_list);
+ }
+ } else {
+#endif
#ifdef HAVE_UTMPX_H
setutxent();
#else
@@ -654,7 +793,11 @@
if (u->ut_type != USER_PROCESS)
continue;
if (!strncmp(u->ut_user, user, UT_NAMESIZE))
- showinfo(u, longform, maxcmd, from, userlen,
+ 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);
}
} else {
@@ -669,7 +812,11 @@
if (u->ut_type != USER_PROCESS)
continue;
if (*u->ut_user)
- showinfo(u, longform, maxcmd, from, userlen,
+ 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);
}
}
@@ -678,6 +825,9 @@
#else
endutent();
#endif
+#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER)
+ }
+#endif
return EXIT_SUCCESS;
}

BIN
procps-ng-3.3.17.tar.xz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,99 @@
---
ps/common.h | 1 +
ps/global.c | 5 ++++-
ps/output.c | 19 ++++++++++---------
3 files changed, 15 insertions(+), 10 deletions(-)
--- ps/common.h
+++ ps/common.h 2018-04-04 11:14:33.915688098 +0000
@@ -303,6 +303,7 @@ extern int running_only;
extern int screen_cols;
extern int screen_rows;
extern time_t seconds_since_boot;
+extern unsigned long long jiffies_since_boot;
extern selection_node *selection_list;
extern unsigned simple_select;
extern sort_node *sort_list;
--- ps/global.c
+++ ps/global.c 2018-04-04 11:14:33.915688098 +0000
@@ -78,6 +78,7 @@ int prefer_bsd_defaults = -1
int screen_cols = -1;
int screen_rows = -1;
time_t seconds_since_boot = -1;
+unsigned long long jiffies_since_boot = -1;
selection_node *selection_list = (selection_node *)0xdeadbeef;
unsigned simple_select = 0xffffffff;
sort_node *sort_list = (sort_node *)0xdeadbeef; /* ready-to-use sort list */
@@ -361,6 +362,7 @@ static const char *set_personality(void)
/************ Call this to reinitialize everything ***************/
void reset_global(void){
static proc_t p;
+ double uptime_secs;
reset_selection_list();
look_up_our_self(&p);
set_screen_size();
@@ -383,7 +385,8 @@ void reset_global(void){
negate_selection = 0;
page_size = getpagesize();
running_only = 0;
- seconds_since_boot = uptime(0,0);
+ seconds_since_boot = uptime(&uptime_secs,0);
+ jiffies_since_boot = ((long double)uptime_secs * Hertz);
selection_list = NULL;
simple_select = 0;
sort_list = NULL;
--- ps/output.c
+++ ps/output.c 2018-04-04 11:14:33.915688098 +0000
@@ -134,6 +134,7 @@ static int sr_ ## NAME (const proc_t* P,
#define cook_time(P) (P->utime + P->stime) / Hertz
#define cook_etime(P) (((unsigned long long)seconds_since_boot >= (P->start_time / Hertz)) ? ((unsigned long long)seconds_since_boot - (P->start_time / Hertz)) : 0)
+#define cook_jtime(P) (((unsigned long long)jiffies_since_boot >= (P->start_time)) ? ((unsigned long long)jiffies_since_boot - (P->start_time)) : 0)
#define CMP_COOKED_TIME(NAME) \
static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \
@@ -507,11 +508,11 @@ static int pr_etimes(char *restrict cons
static int pr_c(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long long total_time; /* jiffies used by this process */
unsigned pcpu = 0; /* scaled %cpu, 99 means 99% */
- unsigned long long seconds; /* seconds of process life */
+ unsigned long long jiffies; /* jiffies of process life */
total_time = pp->utime + pp->stime;
if(include_dead_children) total_time += (pp->cutime + pp->cstime);
- seconds = cook_etime(pp);
- if(seconds) pcpu = (total_time * 100ULL / Hertz) / seconds;
+ jiffies = cook_jtime(pp);
+ if(jiffies) pcpu = (total_time * 100ULL) / jiffies;
if (pcpu > 99U) pcpu = 99U;
return snprintf(outbuf, COLWID, "%2u", pcpu);
}
@@ -519,11 +520,11 @@ static int pr_c(char *restrict const out
static int pr_pcpu(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long long total_time; /* jiffies used by this process */
unsigned pcpu = 0; /* scaled %cpu, 999 means 99.9% */
- unsigned long long seconds; /* seconds of process life */
+ unsigned long long jiffies; /* jiffies of process life */
total_time = pp->utime + pp->stime;
if(include_dead_children) total_time += (pp->cutime + pp->cstime);
- seconds = cook_etime(pp);
- if(seconds) pcpu = (total_time * 1000ULL / Hertz) / seconds;
+ jiffies = cook_jtime(pp);
+ if(jiffies) pcpu = (total_time * 1000ULL) / jiffies;
if (pcpu > 999U)
return snprintf(outbuf, COLWID, "%u", pcpu/10U);
return snprintf(outbuf, COLWID, "%u.%u", pcpu/10U, pcpu%10U);
@@ -532,11 +533,11 @@ static int pr_pcpu(char *restrict const
static int pr_cp(char *restrict const outbuf, const proc_t *restrict const pp){
unsigned long long total_time; /* jiffies used by this process */
unsigned pcpu = 0; /* scaled %cpu, 999 means 99.9% */
- unsigned long long seconds; /* seconds of process life */
+ unsigned long long jiffies; /* jiffies of process life */
total_time = pp->utime + pp->stime;
if(include_dead_children) total_time += (pp->cutime + pp->cstime);
- seconds = cook_etime(pp);
- if(seconds) pcpu = (total_time * 1000ULL / Hertz) / seconds;
+ jiffies = cook_jtime(pp);
+ if(jiffies) pcpu = (total_time * 1000ULL) / jiffies;
if (pcpu > 999U) pcpu = 999U;
return snprintf(outbuf, COLWID, "%3u", pcpu);
}

View File

@ -0,0 +1,29 @@
Do not setup SIGHUP signal handler if we are in the batch mode
Top enables a signal handler for the SIGHUP signal (loss of terminal). While
this makes sense for top's default interactive mode, it doesn't make any sense
for batch mode. If you run top in nohup just to collect data over time and
disconnect top finishes which is not what one would expect.
Index: procps-3.2.8/top.c
---
top/top.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- top/top.c
+++ top/top.c 2018-04-04 11:33:59.278280201 +0000
@@ -3691,7 +3691,13 @@ static void before (char *me) {
sa.sa_flags = 0;
for (i = SIGRTMAX; i; i--) {
switch (i) {
- case SIGALRM: case SIGHUP: case SIGINT:
+ case SIGHUP:
+ if (Batch)
+ sa.sa_handler = SIG_IGN;
+ else
+ sa.sa_handler = sig_endpgm;
+ break;
+ case SIGALRM: case SIGINT:
case SIGPIPE: case SIGQUIT: case SIGTERM:
case SIGUSR1: case SIGUSR2:
sa.sa_handler = sig_endpgm;

View File

@ -0,0 +1,23 @@
From: Takashi Iwai <tiwai@suse.de>
Subject: Ignore scan_unevictable_pages entry in sysctl, too
References: bnc#868888
scan_unevictable_pages sysctl is deprecated in the recent kernel.
Ignore it for avoiding the kernel warning message.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sysctl.c | 1 +
1 file changed, 1 insertion(+)
--- a/sysctl.c
+++ b/sysctl.c
@@ -59,6 +59,7 @@ static const char DEFAULT_PRELOAD[] = "/
static const char *DEPRECATED[] = {
"base_reachable_time",
"retrans_time",
+ "scan_unevictable_pages",
""
};
static bool IgnoreDeprecated;

View File

@ -0,0 +1,27 @@
---
top/top.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- top/top.c
+++ top/top.c 2018-04-04 11:49:56.472660056 +0000
@@ -1626,9 +1626,9 @@ static inline const char *make_str_utf8
static const char *scale_mem (int target, unsigned long num, int width, int justr) {
// SK_Kb SK_Mb SK_Gb SK_Tb SK_Pb SK_Eb
#ifdef BOOST_MEMORY
- static const char *fmttab[] = { "%.0f", "%#.1f%c", "%#.3f%c", "%#.3f%c", "%#.3f%c", NULL };
+ static const char *fmttab[] = { "%.0f", "%#.1f%c", "%#.3f%c", "%#.3f%c", "%#.3f%c", "%#.3f%c", NULL };
#else
- static const char *fmttab[] = { "%.0f", "%.1f%c", "%.1f%c", "%.1f%c", "%.1f%c", NULL };
+ static const char *fmttab[] = { "%.0f", "%.1f%c", "%.1f%c", "%.1f%c", "%.1f%c", "%.1f%c", NULL };
#endif
static char buf[SMLBUFSIZ];
float scaled_num;
@@ -1640,7 +1640,7 @@ static const char *scale_mem (int target
goto end_justifies;
scaled_num = num;
- for (i = SK_Kb, psfx = Scaled_sfxtab; i < SK_Eb; psfx++, i++) {
+ for (i = SK_Kb, psfx = Scaled_sfxtab; i <= SK_Eb; psfx++, i++) {
if (i >= target
&& (width >= snprintf(buf, sizeof(buf), fmttab[i], scaled_num, *psfx)))
goto end_justifies;

View File

@ -0,0 +1,66 @@
---
proc/readproc.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
--- proc/readproc.c
+++ proc/readproc.c 2018-06-05 08:54:06.408030693 +0000
@@ -675,7 +675,7 @@ static int file2str(const char *director
else ub->buf = xcalloc((ub->siz = buffGRW));
len = snprintf(path, sizeof path, "%s/%s", directory, what);
if (len <= 0 || (size_t)len >= sizeof path) return -1;
- if (-1 == (fd = open(path, O_RDONLY, 0))) return -1;
+ if (-1 == (fd = open(path, O_RDONLY, O_NOATIME))) return -1;
while (0 < (num = read(fd, ub->buf + tot_read, ub->siz - tot_read))) {
tot_read += num;
if (tot_read < ub->siz) break;
@@ -695,25 +695,25 @@ static int file2str(const char *director
static char** file2strvec(const char* directory, const char* what) {
char buf[2048]; /* read buf bytes at a time */
char *p, *rbuf = 0, *endbuf, **q, **ret, *strp;
- int fd, tot = 0, n, c, end_of_file = 0;
- int align;
+ int fd, c, end_of_file = 0;
+ ssize_t n, align, tot = 0;
const int len = snprintf(buf, sizeof buf, "%s/%s", directory, what);
if(len <= 0 || (size_t)len >= sizeof buf) return NULL;
- fd = open(buf, O_RDONLY, 0);
+ fd = open(buf, O_RDONLY, O_NOATIME);
if(fd==-1) return NULL;
/* read whole file into a memory buffer, allocating as we go */
while ((n = read(fd, buf, sizeof buf - 1)) >= 0) {
- if (n < (int)(sizeof buf - 1))
+ if (n < sizeof buf - 1)
end_of_file = 1;
- if (n <= 0 && tot <= 0) { /* nothing read now, nothing read before */
+ if (n <= 0 && tot <= 0) /* nothing read now, nothing read before */
break; /* process died between our open and read */
- }
+
/* ARG_LEN is our guesstimated median length of a command-line argument
or environment variable (the minimum is 1, the maximum is 131072) */
#define ARG_LEN 64
- if (tot >= INT_MAX / (ARG_LEN + (int)sizeof(char*)) * ARG_LEN - n) {
+ if (tot >= INT_MAX / (ARG_LEN + sizeof(char*)) * ARG_LEN - n) {
end_of_file = 1; /* integer overflow: null-terminate and break */
n = 0; /* but tot > 0 */
}
@@ -741,7 +741,7 @@ static char** file2strvec(const char* di
c = sizeof(char*); /* one extra for NULL term */
for (p = rbuf; p < endbuf; p++) {
if (!*p || *p == '\n') {
- if (c >= INT_MAX - (tot + (int)sizeof(char*) + align)) break;
+ if (c >= INT_MAX - (tot + sizeof(char*) + align)) break;
c += sizeof(char*);
}
if (*p == '\n')
@@ -753,7 +753,7 @@ static char** file2strvec(const char* di
q = ret = (char**) (endbuf+align); /* ==> free(*ret) to dealloc */
for (strp = p = rbuf; p < endbuf; p++) {
if (!*p) { /* NUL char implies that */
- if (c < 2 * (int)sizeof(char*)) break;
+ if (c < 2 * sizeof(char*)) break;
c -= sizeof(char*);
*q++ = strp; /* point ptrs to the strings */
strp = p+1; /* next string -> next char */

35
procps-ng-3.3.8-tinfo.dif Normal file
View File

@ -0,0 +1,35 @@
---
Makefile.am | 2 +-
configure.ac | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
--- Makefile.am
+++ Makefile.am 2018-04-04 12:28:14.937957527 +0000
@@ -171,7 +171,7 @@ else
slabtop_LDADD = $(LDADD) @NCURSES_LIBS@
endif
-top_top_LDADD = $(LDADD) @NCURSES_LIBS@ $(DL_LIB)
+top_top_LDADD = $(LDADD) @TOP_NCURSES_LIBS@ $(DL_LIB)
endif
if BUILD_SKILL
--- configure.ac
+++ configure.ac 2018-04-04 12:29:23.364676155 +0000
@@ -194,8 +194,16 @@ else
else
WATCH_NCURSES_LIBS="$NCURSES_LIBS"
fi
+ cf_tinfo=""
+ AC_CHECK_LIB(tinfo, setupterm, [cf_tinfo="tinfo"])
+ if test x$cf_tinfo = xtinfo ; then
+ TOP_NCURSES_LIBS="-ltinfo"
+ else
+ TOP_NCURSES_LIBS="$NCURSES_LIBS"
+ fi
fi
AC_SUBST([NCURSES_LIBS])
+AC_SUBST([TOP_NCURSES_LIBS])
AC_SUBST([WATCH_NCURSES_LIBS])
AC_SUBST([WATCH_NCURSES_CFLAGS])

View File

@ -0,0 +1,17 @@
---
vmstat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- vmstat.c
+++ vmstat.c 2016-07-11 13:18:04.993371059 +0000
@@ -273,8 +273,8 @@ static void new_header(void)
static unsigned long unitConvert(unsigned long size)
{
- float cvSize;
- cvSize = (float)size / dataUnit * ((statMode == SLABSTAT) ? 1 : 1024);
+ long double cvSize;
+ cvSize = (long double)size / dataUnit * ((statMode == SLABSTAT) ? 1 : 1024);
return ((unsigned long)cvSize);
}

View File

@ -0,0 +1,80 @@
---
w.1 | 3 +++
w.c | 19 ++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
--- w.1
+++ w.1 2023-08-18 08:21:51.764340794 +0000
@@ -40,6 +40,9 @@ and a
\fB\-s\fR, \fB\-\-short\fR
Use the short format. Don't print the login time, JCPU or PCPU times.
.TP
+\fB\-n\fR, \fB\-\-no\-truncat\fR
+Do not truncate the output format. This option might become renamed in future versions.
+.TP
\fB\-f\fR, \fB\-\-from\fR
Toggle printing the
.B from
--- w.c
+++ w.c 2023-08-18 08:37:32.143482035 +0000
@@ -394,7 +394,7 @@ static const proc_t *getproc(const utmp_
}
static void showinfo(utmp_t * u, int formtype, int maxcmd, int from,
- const int userlen, const int fromlen, const int ip_addresses)
+ int userlen, int fromlen, const int ip_addresses)
{
unsigned long long jcpu;
int ut_pid_found;
@@ -424,7 +424,14 @@ static void showinfo(utmp_t * u, int for
strncpy(uname, u->ut_user, UT_NAMESIZE);
if (formtype) {
- printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, u->ut_line);
+ int utlnlen = 8;
+ if (formtype > 1) {
+ userlen = strnlen(uname, UT_NAMESIZE);
+ fromlen = strnlen(u->ut_host, UT_HOSTSIZE);
+ utlnlen = strnlen(u->ut_line, UT_LINESIZE);
+ maxcmd = MAX_CMD_WIDTH;
+ }
+ printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, u->ut_line);
if (from)
print_from(u, ip_addresses, fromlen);
#ifdef HAVE_UTMPX_H
@@ -478,6 +485,7 @@ static void __attribute__ ((__noreturn__
fputs(_(" -h, --no-header do not print header\n"),out);
fputs(_(" -u, --no-current ignore current process username\n"),out);
fputs(_(" -s, --short short format\n"),out);
+ fputs(_(" -n, --no-truncat non truncated listing (large)\n"),out);
fputs(_(" -f, --from show remote hostname field\n"),out);
fputs(_(" -o, --old-style old style output\n"),out);
fputs(_(" -i, --ip-addr display IP address instead of hostname (if possible)\n"), out);
@@ -514,6 +522,7 @@ int main(int argc, char **argv)
{"no-header", no_argument, NULL, 'h'},
{"no-current", no_argument, NULL, 'u'},
{"short", no_argument, NULL, 's'},
+ {"no-truncat", no_argument, NULL, 'n'},
{"from", no_argument, NULL, 'f'},
{"old-style", no_argument, NULL, 'o'},
{"ip-addr", no_argument, NULL, 'i'},
@@ -535,7 +544,7 @@ int main(int argc, char **argv)
#endif
while ((ch =
- getopt_long(argc, argv, "husfoVi", longopts, NULL)) != -1)
+ getopt_long(argc, argv, "husnfoVi", longopts, NULL)) != -1)
switch (ch) {
case 'h':
header = 0;
@@ -546,6 +555,10 @@ int main(int argc, char **argv)
case 's':
longform = 0;
break;
+ case 'n':
+ longform = 2;
+ header = 0;
+ break;
case 'f':
from = !from;
break;

View File

@ -0,0 +1,14 @@
---
proc/libprocps.sym | 1 +
1 file changed, 1 insertion(+)
--- proc/libprocps.sym
+++ proc/libprocps.sym 2016-07-11 12:45:32.463107052 +0000
@@ -13,6 +13,7 @@ global:
get_ns_id;
get_ns_name;
get_pid_digits;
+ get_proc_stats;
get_slabinfo;
getbtime;
getdiskstat;

1
procps-rpmlintrc Normal file
View File

@ -0,0 +1 @@
addFilter(".*W:.*shared-lib-calls-exit.*libprocps\.so.*")

61
procps-v3.3.3-columns.dif Normal file
View File

@ -0,0 +1,61 @@
---
ps/global.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- ps/global.c
+++ ps/global.c 2016-07-11 13:04:59.600533764 +0000
@@ -147,8 +147,11 @@ static void set_screen_size(void){
screen_cols = ws.ws_col; // hmmm, NetBSD subtracts 1
screen_rows = ws.ws_row;
- // TODO: delete this line
- if(!isatty(STDOUT_FILENO)) screen_cols = OUTBUF_SIZE;
+ if(!isatty(STDOUT_FILENO)){
+ screen_cols = OUTBUF_SIZE;
+ screen_rows = OUTBUF_SIZE;
+ if (personality&PER_UNIX_COLS) return; // SysV/UNIX98 based personality
+ }
columns = getenv("COLUMNS");
if(columns && *columns){
@@ -290,6 +293,7 @@ static const char *set_personality(void)
return NULL;
case_aix:
+ personality |= PER_UNIX_COLS;
bsd_j_format = "FB_j";
bsd_l_format = "FB_l";
/* bsd_s_format not used */
@@ -317,6 +321,7 @@ static const char *set_personality(void)
case_sunos4:
personality = PER_NO_DEFAULT_g;
+ personality |= PER_UNIX_COLS;
prefer_bsd_defaults = 1;
bsd_j_format = "FB_j";
bsd_l_format = "FB_l";
@@ -342,12 +347,14 @@ static const char *set_personality(void)
case_hp:
case_hpux:
personality = PER_HPUX_x;
+ personality |= PER_UNIX_COLS;
return NULL;
case_svr4:
case_sysv:
case_sco:
personality = PER_SVR4_x;
+ personality |= PER_UNIX_COLS;
return NULL;
case_posix:
@@ -365,8 +372,8 @@ void reset_global(void){
double uptime_secs;
reset_selection_list();
look_up_our_self(&p);
- set_screen_size();
set_personality();
+ set_screen_size();
all_processes = 0;
bsd_c_option = 0;

13
procps-v3.3.3-ia64.diff Normal file
View File

@ -0,0 +1,13 @@
--- proc/devname.c
+++ proc/devname.c 2012-06-01 13:35:43.452010553 +0000
@@ -53,6 +53,10 @@
#define minor <-- do not use -->
#endif
+#ifndef PAGE_SIZE
+# define PAGE_SIZE (sysconf(_SC_PAGESIZE))
+#endif
+
typedef struct tty_map_node {
struct tty_map_node *next;
unsigned short devfs_type; // bool

14
procps-v3.3.3-pwdx.patch Normal file
View File

@ -0,0 +1,14 @@
---
pwdx.c | 1 +
1 file changed, 1 insertion(+)
--- pwdx.c
+++ pwdx.c 2016-07-11 13:17:16.154313659 +0000
@@ -109,6 +109,7 @@ int main(int argc, char *argv[])
buflen = 10 + strlen(argv[i]) + 1;
buf = xmalloc(buflen);
+ errno = 0;
if (check_pid_argument(argv[i]))
xerrx(EXIT_FAILURE, _("invalid process id: %s"),
argv[i]);

View File

@ -0,0 +1,51 @@
---
sysctl.8 | 2 ++
sysctl.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
--- sysctl.8
+++ sysctl.8 2021-02-10 10:05:27.781748090 +0000
@@ -81,6 +81,8 @@ directories in the following list in giv
Once a file of a given filename is loaded, any file of the same name
in subsequent directories is ignored.
.br
+/boot/sysctl.conf-<kernelversion>
+.br
/etc/sysctl.d/*.conf
.br
/run/sysctl.d/*.conf
--- sysctl.c
+++ sysctl.c 2021-02-10 10:04:25.290952318 +0000
@@ -39,6 +39,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/utsname.h>
#include <unistd.h>
#include "c.h"
@@ -621,6 +622,7 @@ static int sortpairs(const void *A, cons
static int PreloadSystem(void)
{
unsigned di, i;
+ struct utsname uts;
const char *dirs[] = {
"/etc/sysctl.d",
"/run/sysctl.d",
@@ -685,6 +687,16 @@ static int PreloadSystem(void)
}
qsort(cfgs, ncfgs, sizeof(struct cfg *), sortpairs);
+ if (uname(&uts) == 0) {
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf), "/boot/sysctl.conf-%s", uts.release);
+ if (access(buf, R_OK) == 0) {
+ if (!Quiet)
+ printf("* Applying %s ...\n", buf);
+ Preload(buf);
+ }
+ }
+
for (i = 0; i < ncfgs; ++i) {
if (!Quiet)
printf(_("* Applying %s ...\n"), cfgs[i]->value);

2227
procps.changes Normal file

File diff suppressed because it is too large Load Diff

431
procps.spec Normal file
View File

@ -0,0 +1,431 @@
#
# spec file for package procps
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define somajor 8
%define libname libprocps%{somajor}
%if 0%{?suse_version} < 1550
%bcond_with bin2usr
%else
%bcond_without bin2usr
%endif
%bcond_without pidof
%bcond_without nls
Name: procps
Version: 3.3.17
Release: 0
Summary: The ps utilities for /proc
License: GPL-2.0-or-later AND LGPL-2.1-or-later
Group: System/Monitoring
URL: https://sf.net/projects/procps-ng/
Source: https://downloads.sourceforge.net/project/procps-ng/Production/procps-ng-%{version}.tar.xz
#Alternate: https://gitlab.com/procps-ng/procps/-/archive/v%{version}/procps-v%{version}.tar.gz
Source1: procps-rpmlintrc
Patch0: procps-ng-3.3.9-watch.patch
Patch1: procps-v3.3.3-ia64.diff
Patch3: procps-ng-3.3.9-w-notruncate.diff
Patch7: procps-ng-3.3.8-readeof.patch
Patch8: procps-ng-3.3.10-slab.patch
Patch10: procps-ng-3.3.8-accuracy.dif
Patch11: procps-ng-3.3.10-xen.dif
Patch12: procps-ng-3.3.10-fdleak.dif
Patch13: procps-v3.3.3-columns.dif
Patch14: procps-ng-3.3.10-integer-overflow.patch
Patch15: procps-ng-3.3.10-bnc634071_procstat2.diff
Patch16: procps-ng-3.3.8-bnc634840.patch
Patch17: procps-v3.3.3-read-sysctls-also-from-boot-sysctl.conf-kernelversion.diff
Patch18: procps-ng-3.3.8-petabytes.patch
Patch19: procps-ng-3.3.10-large_pcpu.patch
Patch20: procps-ng-3.3.8-tinfo.dif
Patch21: procps-v3.3.3-pwdx.patch
# PATCH-FIX-OPENSUSE -- trifle rest of the old terabyte patch
Patch28: procps-ng-3.3.8-vmstat-terabyte.dif
# PATCH-FIX-SUSE -- Ignore scan_unevictable_pages in sysctl
Patch31: procps-ng-3.3.8-ignore-scan_unevictable_pages.patch
# PATCH-FIX-SUSE -- Avoid errno set by setlocale()
Patch32: procps-ng-3.3.10-errno.patch
# PATCH-FEATURE-SUSE -- Let upstream pmap behave similar to old suse pmap
Patch33: procps-ng-3.3.11-pmap4suse.patch
# PATCH-FIX-UPSTREAM -- bsc#1181976
Patch34: procps-3.3.17-bsc1181976.patch
# PATCH-FIX-UPSTREAM -- bsc#1195468
Patch35: bsc1195468-23da4f40.patch
# PATCH-FIX-UPSTREAM -- bsc#1214290
Patch36: CVE-2023-4016.patch
# PATCH-BACKPORT-FROM-UPSTREAM -- bsc#1181475: 'free' command reports misleading "used" value
Patch42: procps-3.3.17-library-bsc1181475.patch
Patch43: procps-3.3.17-top-bsc1181475.patch
Patch44: procps-ng-3.3.17-logind.patch
Patch45: procps-3.3.17-ignore-sysctl_conf.patch
BuildRequires: automake
BuildRequires: dejagnu
BuildRequires: diffutils
BuildRequires: libselinux-devel
BuildRequires: libtool
BuildRequires: ncurses-devel
BuildRequires: pkgconfig
BuildRequires: screen
BuildRequires: xz
BuildRequires: pkgconfig(libsystemd)
Provides: ps = %{version}-%{release}
Obsoletes: ps < %{version}-%{release}
Requires: %{libname} = %{version}-%{release}
%ifarch ia64 x86_64 ppc64 ppc %{sparc}
BuildRequires: libnuma-devel
%endif
%lang_package
%description
The procps package contains a set of system utilities that provide
system information. Procps includes ps, free, skill, snice, tload, top,
uptime, vmstat, w, and watch. The ps command displays a snapshot of
running processes. The top command provides a repetitive update of the
statuses of running processes. The free command displays the amounts of
free and used memory on your system. The skill command sends a
terminate command (or another specified signal) to a specified set of
processes. The snice command is used to change the scheduling priority
of specified processes. The tload command prints a graph of the current
system load average to a specified tty. The uptime command displays the
current time, how long the system has been running, how many users are
logged on, and system load averages for the past one, five, and fifteen
minutes. The w command displays a list of the users who are currently
logged on and what they are running. The watch program watches a
running program. The vmstat command displays virtual memory statistics
about processes, memory, paging, block I/O, traps, and CPU activity.
%package devel
Summary: Development files for procps
License: GPL-2.0-or-later AND LGPL-2.1-or-later
Group: Development/Libraries/C and C++
Requires: %{libname} = %{version}
%description devel
The procps library can be used to read informations out from /proc
the process information pseudo-file system.
This subpackage contains the header files for libprocps.
%package -n %{libname}
Summary: The procps library
License: LGPL-2.1-or-later
Group: System/Libraries
%description -n %{libname}
The procps library can be used to read informations out from /proc
the process information pseudo-file system.
%prep
%setup -q
%patch0
%patch1
%patch3 -b .trcate
%patch7 -b .rof
%patch8 -b .cache
%patch10 -b .acc
%patch11
%patch12
%patch13 -b .column
%patch14 -b .ovrflw
%patch15
%patch16
%patch17 -b .sysctl
%patch18
%patch19
%patch20
%patch21
%patch28
%patch31 -p1
%patch32
%patch33 -b .pmap4us
%patch34
%patch35 -p1
%patch36 -p0
%patch42
%patch43
%patch44 -p1
%patch45 -p1
%build
test -s .tarball-version || echo %{version} > .tarball-version
#./autogen.sh
autoreconf -fiv
major=$(sed -rn 's/^#define\s+NCURSES_VERSION_MAJOR\s+([0-9]+)/\1/p' %{_includedir}/ncurses.h)
export NCURSESW_CFLAGS="$(ncursesw${major}-config --cflags)"
export NCURSESW_LIBS="$(ncursesw${major}-config --libs)"
export LFS_CFLAGS="$(getconf LFS_CFLAGS)"
%global optflags %{optflags} -D_GNU_SOURCE $LFS_CFLAGS -DCPU_ZEROTICS -DUSE_X_COLHDR -pipe
%configure \
--disable-static \
%if !%{with nls}
--disable-nls \
%endif
--disable-rpath \
--disable-kill \
%if !%{with pidof}
--disable-pidof \
%endif
--enable-watch8bit \
--enable-shared \
--enable-skill \
--enable-w-from \
--enable-sigwinch \
--enable-wide-percent \
--enable-wide-memory \
--enable-w-from \
--enable-libselinux \
--with-pic=yes \
--with-systemd \
--with-gnu-ld \
--disable-modern-top
%make_build
LD_LIBRARY_PATH=$PWD/proc/.libs \
./pmap $$ || {
uname -a
echo /proc/$$/maps
cat /proc/$$/maps
echo /proc/$$/smaps
cat /proc/$$/smaps
exit 1
}
%install
%make_install
install -d %{buildroot}/bin
install -d %{buildroot}/sbin
# clean unwanted files (e.g. coreutils)
rm -f %{buildroot}%{_bindir}/kill
rm -f %{buildroot}%{_bindir}/uptime
rm -f %{buildroot}%{_mandir}/man1/kill.1
rm -f %{buildroot}%{_mandir}/*/man1/kill.1
rm -f %{buildroot}%{_mandir}/man1/uptime.1
rm -f %{buildroot}%{_mandir}/*/man1/uptime.1
find %{buildroot} -type f -name "*.la" -delete -print
rm -rf %{buildroot}%{_datadir}/doc/procps-ng
if cmp -s %{buildroot}%{_mandir}/man1/procps.1 %{buildroot}%{_mandir}/man1/ps.1
then
rm -vf %{buildroot}%{_mandir}/man1/procps.1
(cat > %{buildroot}%{_mandir}/man1/procps.1)<<-'EOF'
.so man1/ps.1
EOF
fi
%if %{with bin2usr}
#
# Identical binaries
#
if cmp -s %{buildroot}/%{_bindir}/pgrep %{buildroot}/%{_bindir}/pkill
then
rm -vf %{buildroot}/%{_bindir}/pkill
pushd %{buildroot}/%{_bindir}
ln pgrep pkill
popd
fi
if cmp -s %{buildroot}/%{_bindir}/snice %{buildroot}/%{_bindir}/skill
then
rm -vf %{buildroot}/%{_bindir}/skill
pushd %{buildroot}/%{_bindir}
ln snice skill
popd
fi
%if 0%{?suse_version} < 1550
ln -s %{_bindir}/ps %{buildroot}/bin/
ln -s %{_bindir}/pgrep %{buildroot}/bin/
ln -s %{_bindir}/pkill %{buildroot}/bin/
ln -s %{_sbindir}/sysctl %{buildroot}/sbin/
%endif
%else
mv %{buildroot}%{_bindir}/ps %{buildroot}/bin/
mv %{buildroot}%{_bindir}/pgrep %{buildroot}/bin/
mv %{buildroot}%{_bindir}/pkill %{buildroot}/bin/
mv %{buildroot}%{_sbindir}/sysctl %{buildroot}/sbin/
#
# Identical binaries
#
if cmp -s %{buildroot}/bin/pgrep %{buildroot}/bin/pkill
then
rm -vf %{buildroot}/bin/pkill
pushd %{buildroot}/bin
ln pgrep pkill
popd
fi
if cmp -s %{buildroot}/%{_bindir}/snice %{buildroot}/%{_bindir}/skill
then
rm -vf %{buildroot}/%{_bindir}/skill
pushd %{buildroot}/%{_bindir}
ln snice skill
popd
fi
ln -s /bin/ps %{buildroot}%{_bindir}/ps
ln -s /bin/pgrep %{buildroot}%{_bindir}/pgrep
ln -s /bin/pkill %{buildroot}%{_bindir}/pkill
ln -s /sbin/sysctl %{buildroot}%{_sbindir}/sysctl
%endif
%find_lang procps-ng --with-man --all-name
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%check
#
# Skip w test as there is no valid utmp
#
rm -rvf testsuite/w.test
#
# Provide a tty for testing
#
LANG=POSIX
LC_ALL=$LANG
unset LC_CTYPE
SCREENDIR=$(mktemp -d ${PWD}/screen.XXXXXX) || exit 1
SCREENRC=${SCREENDIR}/bash
export SCREENRC SCREENDIR
exec 0< /dev/null
SCREENLOG=${SCREENDIR}/log
cat > $SCREENRC<<-EOF
deflogin off
deflog on
logfile $SCREENLOG
logfile flush 1
logtstamp off
log on
setsid on
scrollback 0
silence on
utf8 on
EOF
TMPDIR=$(mktemp -d /tmp/bash.XXXXXXXXXX) || exit 1
> $SCREENLOG
tail -q -s 0.5 -f $SCREENLOG & pid=$!
env HOME=$PWD TERM=$TERM TMPDIR=$TMPDIR SCREENRC=$SCREENRC SCREENDIR=$SCREENDIR \
screen -D -m make check
kill -TERM $pid
error=no
for log in test-suite.log testsuite/*.log
do
if grep -E '^(XFAIL|FAIL|ERROR):' $log
then
cat $log
error=yes
fi
done
%if 0%{?qemu_user_space_build}
if test -x /usr/bin/qemu-%_build_arch
then
echo Do not fail as pgrep as well as ps will find unexpected qemu-%_build_arch on command lines
exit 0
fi
%endif
test $error = no || exit 1
%files
%defattr (-,root,root,755)
%license COPYING COPYING.LIB
%doc NEWS Documentation/bugs.md Documentation/FAQ
%if %{with bin2usr}
%if 0%{?suse_version} < 1550
%verify(link) /bin/ps
%verify(link) /bin/pgrep
%verify(link) /bin/pkill
%verify(link) /sbin/sysctl
%endif
%{_bindir}/ps
%{_bindir}/pgrep
%{_bindir}/pkill
%{_sbindir}/sysctl
%else
/bin/ps
/bin/pgrep
/bin/pkill
/sbin/sysctl
%verify(link) %{_bindir}/ps
%verify(link) %{_bindir}/pgrep
%verify(link) %{_bindir}/pkill
%verify(link) %{_sbindir}/sysctl
%endif
%{_bindir}/free
%if %{with pidof}
%{_bindir}/pidof
%endif
%{_bindir}/pmap
%{_bindir}/pwait
%{_bindir}/pwdx
%{_bindir}/skill
%{_bindir}/slabtop
%{_bindir}/snice
%{_bindir}/tload
%{_bindir}/top
%{_bindir}/vmstat
%{_bindir}/w
%{_bindir}/watch
%{_mandir}/man1/free.1%{?ext_man}
%{_mandir}/man1/pgrep.1%{?ext_man}
%if %{with pidof}
%{_mandir}/man1/pidof.1%{?ext_man}
%endif
%{_mandir}/man1/pkill.1%{?ext_man}
%{_mandir}/man1/pmap.1%{?ext_man}
%{_mandir}/man1/procps.1%{?ext_man}
%{_mandir}/man1/ps.1%{?ext_man}
%{_mandir}/man1/pwait.1%{?ext_man}
%{_mandir}/man1/pwdx.1%{?ext_man}
%{_mandir}/man1/skill.1%{?ext_man}
%{_mandir}/man1/slabtop.1%{?ext_man}
%{_mandir}/man1/snice.1%{?ext_man}
%{_mandir}/man1/tload.1%{?ext_man}
%{_mandir}/man1/top.1%{?ext_man}
%{_mandir}/man1/w.1%{?ext_man}
%{_mandir}/man1/watch.1%{?ext_man}
%{_mandir}/man5/sysctl.conf.5%{?ext_man}
%{_mandir}/man8/vmstat.8%{?ext_man}
%{_mandir}/man8/sysctl.8%{?ext_man}
%files devel
%defattr (-,root,root,755)
%dir %{_includedir}/proc
%{_includedir}/proc/alloc.h
%{_includedir}/proc/devname.h
%{_includedir}/proc/escape.h
%{_includedir}/proc/numa.h
%{_includedir}/proc/procps.h
%{_includedir}/proc/pwcache.h
%{_includedir}/proc/readproc.h
%{_includedir}/proc/sig.h
%{_includedir}/proc/slab.h
%{_includedir}/proc/sysinfo.h
%{_includedir}/proc/version.h
%{_includedir}/proc/wchan.h
%{_includedir}/proc/whattime.h
%{_libdir}/libprocps.so
%{_libdir}/pkgconfig/libprocps.pc
%{_mandir}/man3/openproc.3%{?ext_man}
%{_mandir}/man3/readproc.3%{?ext_man}
%{_mandir}/man3/readproctab.3%{?ext_man}
%files -n %{libname}
%defattr (-,root,root,755)
%{_libdir}/libprocps.so.%{somajor}*
%files lang -f procps-ng.lang
%if 0%{?suse_version} < 1550
%dir %{_mandir}/uk/
%endif
%changelog