Compare commits

..

No commits in common. "c8" and "c9" have entirely different histories.
c8 ... c9

23 changed files with 1560 additions and 630 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/procps-ng-3.3.15.tar.xz
SOURCES/procps-ng-3.3.17.tar.xz

View File

@ -1 +1 @@
2929bc64f0cf7b2db997eef79b7187658e47230d SOURCES/procps-ng-3.3.15.tar.xz
a52952e8bc6aaab812176c00d25adc4d4e1552e2 SOURCES/procps-ng-3.3.17.tar.xz

View File

@ -0,0 +1,55 @@
commit a1bc3bf207c64e2a26d8a7a3c20dd960e0e5c545
Author: Jan Rybar <jrybar@redhat.com>
Date: Thu May 6 16:30:54 2021 +0200
Coverity scan findings - memleaks, unused vars, potential nullptr dereferences
diff --git a/lib/test_process.c b/lib/test_process.c
index e20b270d..f8ff5ed0 100644
--- a/lib/test_process.c
+++ b/lib/test_process.c
@@ -69,6 +69,7 @@ signal_handler(int signum, siginfo_t *siginfo, void *ucontext)
exit(EXIT_FAILURE);
}
+ free(signame);
}
int main(int argc, char *argv[])
diff --git a/pmap.c b/pmap.c
index 49a2a6a8..d8565fc3 100644
--- a/pmap.c
+++ b/pmap.c
@@ -346,6 +346,9 @@ static void print_extended_maps (FILE *f)
if (listnode == NULL) {
assert(firstmapping == 2);
listnode = calloc(1, sizeof *listnode);
+ if (listnode == NULL)
+ xerrx(EXIT_FAILURE, _("ERROR: memory allocation failed"));
+
if (listhead == NULL) {
assert(listtail == NULL);
listhead = listnode;
diff --git a/watch.c b/watch.c
index 1a95454e..772879cd 100644
--- a/watch.c
+++ b/watch.c
@@ -124,8 +124,6 @@ static void reset_ansi(void)
static void init_ansi_colors(void)
{
- int color;
-
short ncurses_colors[] = {
-1, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
@@ -172,6 +170,9 @@ static int process_ansi_color_escape_sequence(char** escape_sequence) {
// ESC[ 48;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB background color
int num;
+ if (!escape_sequence)
+ return 0; /* avoid NULLPTR dereference, return "not understood" */
+
if ((*escape_sequence)[0] != ';')
return 0; /* not understood */

View File

@ -1,7 +1,7 @@
diff -up ./ps/display.c.ori ./ps/display.c
--- ./ps/display.c.ori 2018-05-18 23:32:21.998979977 +0200
+++ ./ps/display.c 2022-11-24 15:11:26.678314866 +0100
@@ -44,26 +44,31 @@
--- ./ps/display.c.ori 2021-02-09 11:11:25.000000000 +0100
+++ ./ps/display.c 2022-11-29 18:39:13.254573784 +0100
@@ -44,6 +44,8 @@
#define SIGCHLD SIGCLD
#endif
@ -10,7 +10,8 @@ diff -up ./ps/display.c.ori ./ps/display.c
char *myname;
/* just reports a crash */
static void signal_handler(int signo){
@@ -54,20 +56,23 @@ static void signal_handler(int signo){
sigprocmask(SIG_BLOCK, &ss, NULL);
if(signo==SIGPIPE) _exit(0); /* "ps | head" will cause this */
/* fprintf() is not reentrant, but we _exit() anyway */
- fprintf(stderr,
@ -39,5 +40,5 @@ diff -up ./ps/display.c.ori ./ps/display.c
+ if (!SIG_IS_TERM_OR_HUP(signo))
+ error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug"));
signal(signo, SIG_DFL); /* allow core file creation */
kill(getpid(), signo);
_exit(EXIT_FAILURE);
sigemptyset(&ss);
sigaddset(&ss, signo);

View File

@ -0,0 +1,38 @@
diff -up ./proc/sysinfo.c.ori ./proc/sysinfo.c
--- ./proc/sysinfo.c.ori 2021-02-09 11:11:25.000000000 +0100
+++ ./proc/sysinfo.c 2022-07-29 14:08:42.093322509 +0200
@@ -786,10 +786,8 @@ 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;
+ mem_used = kb_main_total - kb_main_available;
+ kb_main_used = mem_used < 0 ? 0 : (unsigned long) mem_used;
/* zero? might need fallback for 2.6.27 <= kernel <? 3.14 */
if (!kb_main_available) {
diff -up ./top/top.c.ori ./top/top.c
--- ./top/top.c.ori 2021-02-09 11:11:25.000000000 +0100
+++ ./top/top.c 2022-07-29 13:59:04.681966019 +0200
@@ -6076,12 +6076,16 @@ 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_used;
- pct_used = (float)kb_main_used * (100.0 / (float)kb_main_total);
+ // upstream kept old calculation of 'used' here for some reason
+ // https://gitlab.com/procps-ng/procps/-/commit/047d16ccfda6638eda78f56b67def196a2002b6f
+ my_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
+ pct_used = (float)my_used * (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_used) * (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

@ -1,7 +1,18 @@
diff -up ./pgrep.c.ori ./pgrep.c
--- ./pgrep.c.ori 2022-08-17 15:38:29.655530551 +0200
+++ ./pgrep.c 2022-08-17 15:38:53.702661752 +0200
@@ -204,8 +204,12 @@ static int strict_atol (const char *rest
From 401d587d2deb78adcf62517654f955a24b2d537d Mon Sep 17 00:00:00 2001
From: Todd Lewis <todd_lewis@unc.edu>
Date: Mon, 25 Oct 2021 19:38:10 -0400
Subject: [PATCH] fix uid/gid > 2^31
---
pgrep.c | 10 +++++++---
proc/readproc.h | 12 ++++++------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/pgrep.c b/pgrep.c
index 1905cd1d..7d731620 100644
--- a/pgrep.c
+++ b/pgrep.c
@@ -229,8 +229,12 @@ static int strict_atol (const char *restrict str, long *restrict value)
for ( ; *str; ++str) {
if (! isdigit (*str))
@ -15,7 +26,7 @@ diff -up ./pgrep.c.ori ./pgrep.c
res += *str - '0';
}
*value = sign * res;
@@ -280,7 +284,7 @@ static int conv_uid (const char *restric
@@ -305,7 +309,7 @@ static int conv_uid (const char *restrict name, struct el *restrict e)
xwarnx(_("invalid user name: %s"), name);
return 0;
}
@ -24,7 +35,7 @@ diff -up ./pgrep.c.ori ./pgrep.c
return 1;
}
@@ -297,7 +301,7 @@ static int conv_gid (const char *restric
@@ -322,7 +326,7 @@ static int conv_gid (const char *restrict name, struct el *restrict e)
xwarnx(_("invalid group name: %s"), name);
return 0;
}
@ -33,9 +44,10 @@ diff -up ./pgrep.c.ori ./pgrep.c
return 1;
}
diff -up ./proc/readproc.h.ori ./proc/readproc.h
--- ./proc/readproc.h.ori 2018-05-19 00:04:15.218532055 +0200
+++ ./proc/readproc.h 2022-08-17 15:38:53.702661752 +0200
diff --git a/proc/readproc.h b/proc/readproc.h
index 7905ea99..8d9ae392 100644
--- a/proc/readproc.h
+++ b/proc/readproc.h
@@ -159,12 +159,12 @@ typedef struct proc_t {
session, // stat session id
nlwp, // stat,status number of threads, or 0 if no clue
@ -55,3 +67,6 @@ diff -up ./proc/readproc.h.ori ./proc/readproc.h
tpgid, // stat terminal process group id
exit_signal, // stat might not be SIGCHLD
processor; // stat current (or most recent?) CPU
--
GitLab

View File

@ -1,28 +0,0 @@
commit c833a6241893c7e566a5eed762661942e4cd90d3
Author: Todd Lewis <utoddl@gmail.com>
Date: Mon Oct 29 18:33:48 2018 +0000
Fix user and group name to number conversion for uid/gid above 2^31.
diff --git a/pgrep.c b/pgrep.c
index bde7448..8b82a54 100644
--- a/pgrep.c
+++ b/pgrep.c
@@ -280,7 +280,7 @@ static int conv_uid (const char *restrict name, struct el *restrict e)
xwarnx(_("invalid user name: %s"), name);
return 0;
}
- e->num = pwd->pw_uid;
+ e->num = (int) pwd->pw_uid;
return 1;
}
@@ -297,7 +297,7 @@ static int conv_gid (const char *restrict name, struct el *restrict e)
xwarnx(_("invalid group name: %s"), name);
return 0;
}
- e->num = grp->gr_gid;
+ e->num = (int) grp->gr_gid;
return 1;
}

View File

@ -1,112 +0,0 @@
From d9b3415d2a761cb7669a67f5309665335d5eb4c4 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Mon, 9 Nov 2020 16:10:22 +0100
Subject: [PATCH] New '-w' option for kernel workers.
---
pidof.1 | 3 +++
pidof.c | 17 ++++++++++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/pidof.1 b/pidof.1
index 1368704..c85c088 100644
--- a/pidof.1
+++ b/pidof.1
@@ -45,6 +45,9 @@ the current root directory of processes they do not own.
.IP \-x
Scripts too - this causes the program to also return process id's of
shells running the named scripts.
+.IP \-w
+Show also processes that do not have visible command line (e.g. kernel
+worker threads).
.IP "-o \fIomitpid\fP"
Tells \fIpidof\fP to omit processes with that process id. The special
pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
diff --git a/pidof.c b/pidof.c
index 94e19bb..7fdf27a 100644
--- a/pidof.c
+++ b/pidof.c
@@ -55,6 +55,8 @@ static char *program = NULL;
static int opt_single_shot = 0; /* -s */
static int opt_scripts_too = 0; /* -x */
static int opt_rootdir_check = 0; /* -c */
+static int opt_with_workers = 0; /* -w */
+
static char *pidof_root = NULL;
@@ -69,6 +71,7 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
fputs(_(" -s, --single-shot return one PID only\n"), fp);
fputs(_(" -c, --check-root omit processes with different root\n"), fp);
fputs(_(" -x also find shells running the named scripts\n"), fp);
+ fputs(_(" -w, --with-workers show kernel workers too\n"), fp);
fputs(_(" -o, --omit-pid <PID,...> omit processes with PID\n"), fp);
fputs(_(" -S, --separator SEP use SEP as separator put between PIDs"), fp);
fputs(USAGE_SEPARATOR, fp);
@@ -142,7 +145,6 @@ static void select_procs (void)
static int size = 0;
char *cmd_arg0, *cmd_arg0base;
char *cmd_arg1, *cmd_arg1base;
- char *stat_cmd;
char *program_base;
char *root_link;
char *exe_link;
@@ -168,10 +170,9 @@ static void select_procs (void)
}
}
- if (!is_omitted(task.XXXID)) {
+ if (!is_omitted(task.XXXID) && ((task.cmdline && *task.cmdline) || opt_with_workers)) {
cmd_arg0 = (task.cmdline && *task.cmdline) ? *task.cmdline : "\0";
- stat_cmd = task.cmd ? task.cmd : "\0";
/* processes starting with '-' are login shells */
if (*cmd_arg0 == '-') {
@@ -193,7 +194,7 @@ static void select_procs (void)
!strcmp(program_base, cmd_arg0) ||
!strcmp(program, cmd_arg0) ||
- !strcmp(program, stat_cmd) ||
+ (opt_with_workers && !strcmp(program, task.cmd)) ||
!strcmp(program, exe_link_base) ||
!strcmp(program, exe_link))
@@ -293,13 +294,14 @@ int main (int argc, char **argv)
int first_pid = 1;
const char *separator = " ";
- const char *opts = "scnxmo:S:?Vh";
+ const char *opts = "scnxwmo:S:?Vh";
static const struct option longopts[] = {
{"check-root", no_argument, NULL, 'c'},
{"single-shot", no_argument, NULL, 's'},
{"omit-pid", required_argument, NULL, 'o'},
{"separator", required_argument, NULL, 's'},
+ {"with-workers", no_argument, NULL, 'w'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
@@ -325,6 +327,9 @@ int main (int argc, char **argv)
case 'x':
opt_scripts_too = 1;
break;
+ case 'w':
+ opt_with_workers = 1;
+ break;
case 'c':
if (geteuid() == 0) {
opt_rootdir_check = 1;
@@ -358,6 +363,8 @@ int main (int argc, char **argv)
program = argv[optind++];
+ if (*program == '\0') continue;
+
select_procs(); /* get the list of matching processes */
if (proc_count) {
--
2.25.4

View File

@ -1,13 +0,0 @@
diff --git a/pidof.c b/pidof.c
index 7fdf27a..2166265 100644
--- a/pidof.c
+++ b/pidof.c
@@ -300,7 +300,7 @@ int main (int argc, char **argv)
{"check-root", no_argument, NULL, 'c'},
{"single-shot", no_argument, NULL, 's'},
{"omit-pid", required_argument, NULL, 'o'},
- {"separator", required_argument, NULL, 's'},
+ {"separator", required_argument, NULL, 'S'},
{"with-workers", no_argument, NULL, 'w'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},

View File

@ -1,54 +0,0 @@
From 7dcb6b8eb6c69584d0d56797935f836bc06642f5 Mon Sep 17 00:00:00 2001
From: Jan Rybar <jrybar@redhat.com>
Date: Tue, 7 Apr 2020 13:41:48 +0200
Subject: [PATCH] pidof: show worker threads
Reimplementation of pidof for procps toolset contains sort of deactivated code and does not return results for processes without task.cmdline entry (usually kernel worker threads). Old pidof and pgrep do that in comparison. Despite all perks provided by using pgrep instead, pidof should show those workers again.
---
pidof.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pidof.c b/pidof.c
index b0d08cc..90ecb13 100644
--- a/pidof.c
+++ b/pidof.c
@@ -142,6 +142,7 @@ static void select_procs (void)
static int size = 0;
char *cmd_arg0, *cmd_arg0base;
char *cmd_arg1, *cmd_arg1base;
+ char *stat_cmd;
char *program_base;
char *root_link;
char *exe_link;
@@ -167,9 +168,10 @@ static void select_procs (void)
}
}
- if (!is_omitted(task.XXXID) && task.cmdline && *task.cmdline) {
+ if (!is_omitted(task.XXXID)) {
- cmd_arg0 = *task.cmdline;
+ cmd_arg0 = (task.cmdline && *task.cmdline) ? *task.cmdline : "\0";
+ stat_cmd = task.cmd ? task.cmd : "\0";
/* processes starting with '-' are login shells */
if (*cmd_arg0 == '-') {
@@ -191,12 +193,14 @@ static void select_procs (void)
!strcmp(program_base, cmd_arg0) ||
!strcmp(program, cmd_arg0) ||
+ !strcmp(program, stat_cmd) ||
+
!strcmp(program, exe_link_base) ||
!strcmp(program, exe_link))
{
match = 1;
- } else if (opt_scripts_too && *(task.cmdline+1)) {
+ } else if (opt_scripts_too && task.cmdline && *(task.cmdline+1)) {
cmd_arg1 = *(task.cmdline+1);
--
2.25.2

View File

@ -1,39 +0,0 @@
From 06995518605fed7a1a29551be0eff01b2f9e89b7 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Tue, 13 Dec 2022 16:02:50 -0500
Subject: [PATCH]
---
ps/common.h | 2 +-
ps/select.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ps/common.h b/ps/common.h
index 905d320..fc4d3a8 100644
--- a/ps/common.h
+++ b/ps/common.h
@@ -189,7 +189,7 @@ typedef union sel_union {
uid_t uid;
gid_t gid;
dev_t tty;
- char cmd[64]; /* this is _not_ \0 terminated */
+ char cmd[16]; /* this is _not_ \0 terminated */
} sel_union;
typedef struct selection_node {
diff --git a/ps/select.c b/ps/select.c
index f58ca25..e12982d 100644
--- a/ps/select.c
+++ b/ps/select.c
@@ -117,7 +117,7 @@ static int proc_was_listed(proc_t *buf){
break; case SEL_SESS: return_if_match(session,pid);
break; case SEL_COMM: i=sn->n; while(i--)
- if(!strncmp( buf->cmd, (*(sn->u+i)).cmd, 63 )) return 1;
+ if(!strncmp( buf->cmd, (*(sn->u+i)).cmd, 15 )) return 1;
--
2.31.1

View File

@ -1,96 +0,0 @@
diff -up ./NEWS.ori ./NEWS
diff -up ./sysctl.8.ori ./sysctl.8
--- ./sysctl.8.ori 2018-03-03 07:59:18.064843718 +0100
+++ ./sysctl.8 2022-07-29 16:33:02.906648974 +0200
@@ -6,7 +6,7 @@
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details."
-.TH SYSCTL "8" "2018-02-19" "procps-ng" "System Administration"
+.TH SYSCTL "8" "2020-02-27" "procps-ng" "System Administration"
.SH NAME
sysctl \- configure kernel parameters at runtime
.SH SYNOPSIS
@@ -81,10 +81,10 @@ 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
-/run/sysctl.d/*.conf
-.br
/etc/sysctl.d/*.conf
.br
+/run/sysctl.d/*.conf
+.br
/usr/local/lib/sysctl.d/*.conf
.br
/usr/lib/sysctl.d/*.conf
@@ -152,6 +152,16 @@ echo 256 > /proc/sys/net/ipv6/neigh/eth0
.SH FILES
.I /proc/sys
.br
+.I /etc/sysctl.d/*.conf
+.br
+.I /run/sysctl.d/*.conf
+.br
+.I /usr/local/lib/sysctl.d/*.conf
+.br
+.I /usr/lib/sysctl.d/*.conf
+.br
+.I /lib/sysctl.d/*.conf
+.br
.I /etc/sysctl.conf
.SH SEE ALSO
.BR sysctl.conf (5)
diff -up ./sysctl.conf.5.ori ./sysctl.conf.5
--- ./sysctl.conf.5.ori 2017-12-22 05:13:14.771653252 +0100
+++ ./sysctl.conf.5 2022-07-29 16:33:02.907648980 +0200
@@ -51,22 +51,22 @@ to list all possible parameters. The des
.RE
.PP
.SH FILES
-.TP
-/run/sysctl.d/*.conf
-.TQ
-/etc/sysctl.d/*.conf
-.TQ
-/usr/local/lib/sysctl.d/*.conf
-.TQ
-/usr/lib/sysctl.d/*.conf
-.TQ
-/lib/sysctl.d/*.conf
-.TQ
-/etc/sysctl.conf
+.I /etc/sysctl.d/*.conf
+.br
+.I /run/sysctl.d/*.conf
+.br
+.I /usr/local/lib/sysctl.d/*.conf
+.br
+.I /usr/lib/sysctl.d/*.conf
+.br
+.I /lib/sysctl.d/*.conf
+.br
+.I /etc/sysctl.conf
+
The paths where
-sysctl
+.B sysctl
preload files usually exist. See also
-sysctl
+.B sysctl
option
.IR \-\-system .
.SH SEE ALSO
diff -up ./sysctl.c.ori ./sysctl.c
--- ./sysctl.c.ori 2018-05-17 13:23:41.574213737 +0200
+++ ./sysctl.c 2022-07-29 16:33:02.907648980 +0200
@@ -614,8 +614,8 @@ static int PreloadSystem(void)
{
unsigned di, i;
const char *dirs[] = {
- "/run/sysctl.d",
"/etc/sysctl.d",
+ "/run/sysctl.d",
"/usr/local/lib/sysctl.d",
"/usr/lib/sysctl.d",
"/lib/sysctl.d",

View File

@ -1,147 +0,0 @@
diff --git a/vmstat.8 b/vmstat.8
index fa0938c..fd1078f 100644
--- a/vmstat.8
+++ b/vmstat.8
@@ -87,6 +87,9 @@ Display version information and exit.
.TP
\fB\-h\fR, \fB\-\-help\fR
Display help and exit.
+.TP
+\fB\-y\fR, \fB\-\-no-first\fR
+Omits first report with statistics since system boot.
.PD
.SH "FIELD DESCRIPTION FOR VM MODE"
.SS
diff --git a/vmstat.c b/vmstat.c
index f2aa2f4..07496cd 100644
--- a/vmstat.c
+++ b/vmstat.c
@@ -75,6 +75,9 @@ static int a_option;
/* "-w" means "wide output" */
static int w_option;
+/* "-y" means "skip first output" */
+static int y_option;
+
/* "-t" means "show timestamp" */
static int t_option;
@@ -104,6 +107,7 @@ static void __attribute__ ((__noreturn__))
fputs(_(" -S, --unit <char> define display unit\n"), out);
fputs(_(" -w, --wide wide output\n"), out);
fputs(_(" -t, --timestamp show timestamp\n"), out);
+ fputs(_(" -y, --no-first skips first line of output\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
@@ -304,43 +308,47 @@ static void new_format(void)
cpu_zzz, pgpgin, pgpgout, pswpin, pswpout, intr, ctxt, &running,
&blocked, &dummy_1, &dummy_2);
- if (t_option) {
- (void) time( &the_time );
- tm_ptr = localtime( &the_time );
- strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr);
- }
+ if (y_option == 0) {
+ if (t_option) {
+ (void) time( &the_time );
+ tm_ptr = localtime( &the_time );
+ strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr);
+ }
- duse = *cpu_use + *cpu_nic;
- dsys = *cpu_sys + *cpu_xxx + *cpu_yyy;
- didl = *cpu_idl;
- diow = *cpu_iow;
- dstl = *cpu_zzz;
- Div = duse + dsys + didl + diow + dstl;
- if (!Div) Div = 1, didl = 1;
- divo2 = Div / 2UL;
- printf(w_option ? wide_format : format,
- running, blocked,
- unitConvert(kb_swap_used), unitConvert(kb_main_free),
- unitConvert(a_option?kb_inactive:kb_main_buffers),
- unitConvert(a_option?kb_active:kb_main_cached),
- (unsigned)( (unitConvert(*pswpin * kb_per_page) * hz + divo2) / Div ),
- (unsigned)( (unitConvert(*pswpout * kb_per_page) * hz + divo2) / Div ),
- (unsigned)( (*pgpgin * hz + divo2) / Div ),
- (unsigned)( (*pgpgout * hz + divo2) / Div ),
- (unsigned)( (*intr * hz + divo2) / Div ),
- (unsigned)( (*ctxt * hz + divo2) / Div ),
- (unsigned)( (100*duse + divo2) / Div ),
- (unsigned)( (100*dsys + divo2) / Div ),
- (unsigned)( (100*didl + divo2) / Div ),
- (unsigned)( (100*diow + divo2) / Div ),
- (unsigned)( (100*dstl + divo2) / Div )
- );
+ duse = *cpu_use + *cpu_nic;
+ dsys = *cpu_sys + *cpu_xxx + *cpu_yyy;
+ didl = *cpu_idl;
+ diow = *cpu_iow;
+ dstl = *cpu_zzz;
+ Div = duse + dsys + didl + diow + dstl;
+ if (!Div) Div = 1, didl = 1;
+ divo2 = Div / 2UL;
+ printf(w_option ? wide_format : format,
+ running, blocked,
+ unitConvert(kb_swap_used), unitConvert(kb_main_free),
+ unitConvert(a_option?kb_inactive:kb_main_buffers),
+ unitConvert(a_option?kb_active:kb_main_cached),
+ (unsigned)( (unitConvert(*pswpin * kb_per_page) * hz + divo2) / Div ),
+ (unsigned)( (unitConvert(*pswpout * kb_per_page) * hz + divo2) / Div ),
+ (unsigned)( (*pgpgin * hz + divo2) / Div ),
+ (unsigned)( (*pgpgout * hz + divo2) / Div ),
+ (unsigned)( (*intr * hz + divo2) / Div ),
+ (unsigned)( (*ctxt * hz + divo2) / Div ),
+ (unsigned)( (100*duse + divo2) / Div ),
+ (unsigned)( (100*dsys + divo2) / Div ),
+ (unsigned)( (100*didl + divo2) / Div ),
+ (unsigned)( (100*diow + divo2) / Div ),
+ (unsigned)( (100*dstl + divo2) / Div )
+ );
- if (t_option) {
- printf(" %s", timebuf);
- }
+ if (t_option) {
+ printf(" %s", timebuf);
+ }
- printf("\n");
+ printf("\n");
+ }
+ else
+ num_updates++;
/* main loop */
for (i = 1; infinite_updates || i < num_updates; i++) {
@@ -865,6 +873,7 @@ int main(int argc, char *argv[])
{"timestamp", no_argument, NULL, 't'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
+ {"no-first", no_argument, NULL, 'y'},
{NULL, 0, NULL, 0}
};
@@ -877,7 +886,7 @@ int main(int argc, char *argv[])
atexit(close_stdout);
while ((c =
- getopt_long(argc, argv, "afmnsdDp:S:wthV", longopts,
+ getopt_long(argc, argv, "afmnsdDp:S:wthVy", longopts,
NULL)) != EOF)
switch (c) {
case 'V':
@@ -946,6 +955,11 @@ int main(int argc, char *argv[])
case 't':
t_option = 1;
break;
+ case 'y':
+ /* Don't display stats since system restart */
+ y_option = 1;
+ break;
+
default:
/* no other aguments defined yet. */
usage(stderr);

View File

@ -1,41 +0,0 @@
commit 354b5a56bf2ea831427ab8268ec7101bd3870f8e
Author: Jan Rybar <jrybar@redhat.com>
Date: Thu Apr 30 17:06:18 2020 +0200
vmstat and watch manpage slight fixes
vmstat - align wording with proc manpage to clarify ambiguities (rhbz#1796043)
watch - manpage presumes ntp tools are present by default (which they're not on rpm and deb distros, rhbz#1583669)
diff --git a/vmstat.8 b/vmstat.8
index e408bca..dcc1b1e 100644
--- a/vmstat.8
+++ b/vmstat.8
@@ -93,7 +93,7 @@ Display help and exit.
.B "Procs"
.nf
r: The number of runnable processes (running or waiting for run time).
-b: The number of processes in uninterruptible sleep.
+b: The number of processes blocked waiting for I/O to complete.
.fi
.PP
.SS
diff --git a/watch.1 b/watch.1
index 256c36b..e06e04e 100644
--- a/watch.1
+++ b/watch.1
@@ -34,7 +34,7 @@ every
.I interval
seconds. Try it with
.B ntptime
-and notice how the fractional seconds stays (nearly) the same, as opposed to
+(if present) and notice how the fractional seconds stays (nearly) the same, as opposed to
normal mode where they continuously increase.
.TP
\fB\-t\fR, \fB\-\-no\-title\fR
@@ -190,4 +190,4 @@ watch uname \-r
.I \-p
isn't guaranteed to work across reboots, especially in the face of
.B ntpdate
-or other bootup time-changing mechanisms)
+(if present) or other bootup time-changing mechanisms)

View File

@ -0,0 +1,286 @@
From 52afb3a8d31871d28b1c39573a7ed5196c2d5023 Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Mon, 15 Feb 2021 21:10:06 +1100
Subject: [PATCH] pidwait: Rename from pwait
pwait is already in at least Debian in a different package
References:
https://bugs.debian.org/982391
---
diff --git a/Makefile.am b/Makefile.am
index e037e4c..de15e13 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,8 +49,8 @@ bin_PROGRAMS = \
uptime \
vmstat \
w
-if BUILD_PWAIT
-bin_PROGRAMS += pwait
+if BUILD_PIDWAIT
+bin_PROGRAMS += pidwait
endif
else
usrbin_exec_PROGRAMS += \
@@ -85,8 +85,8 @@ dist_man_MANS += \
sysctl.conf.5 \
ps/ps.1
-if BUILD_PWAIT
-dist_man_MANS += pwait.1
+if BUILD_PIDWAIT
+dist_man_MANS += pidwait.1
endif
endif
@@ -199,8 +199,8 @@ free_SOURCES = free.c lib/strutils.c lib/fileutils.c
pgrep_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
pkill_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
pmap_SOURCES = pmap.c lib/fileutils.c
-if BUILD_PWAIT
-pwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
+if BUILD_PIDWAIT
+pidwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
endif
if !CYGWIN
pwdx_SOURCES = pwdx.c lib/fileutils.c
diff --git a/NEWS b/NEWS
index da63c9c..5fe6761 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+procps-ng-NEXT
+---------------
+ * Rename pwait to pidwait
+
procps-ng-3.3.17
---------------
* library: Incremented to 8:3:0
diff --git a/configure.ac b/configure.ac
index 56a8669..750c0fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,20 +132,20 @@ AC_TRY_COMPILE([#include <errno.h>],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
-AC_CHECK_FUNC([pidfd_open], [enable_pwait=yes], [
+AC_CHECK_FUNC([pidfd_open], [enable_pidwait=yes], [
AC_MSG_CHECKING([for __NR_pidfd_open])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/syscall.h>
#ifndef __NR_pidfd_open
#error __NR_pidfd_open not defined
#endif
- ])], [enable_pwait=yes], [enable_pwait=no])
- AC_MSG_RESULT([$enable_pwait])
+ ])], [enable_pidwait=yes], [enable_pidwait=no])
+ AC_MSG_RESULT([$enable_pidwait])
])
-if test "$enable_pwait" = yes; then
- AC_DEFINE([ENABLE_PWAIT], [1], [Enable pwait])
+if test "$enable_pidwait" = yes; then
+ AC_DEFINE([ENABLE_PIDWAIT], [1], [Enable pidwait])
fi
-AM_CONDITIONAL([BUILD_PWAIT], [test x$enable_pwait = xyes])
+AM_CONDITIONAL([BUILD_PIDWAIT], [test x$enable_pidwait = xyes])
dnl watch8bit must be before the AC_ARG_WITH set as it sets up ncurses
AC_SUBST([WITH_WATCH8BIT])
diff --git a/pgrep.1 b/pgrep.1
index 4f8907b..af6dcd5 100644
--- a/pgrep.1
+++ b/pgrep.1
@@ -9,7 +9,7 @@
.\"
.TH PGREP "1" "2020-06-04" "procps-ng" "User Commands"
.SH NAME
-pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and other attributes
+pgrep, pkill, pidwait \- look up, signal, or wait for processes based on name and other attributes
.SH SYNOPSIS
.B pgrep
[options] pattern
@@ -17,7 +17,7 @@ pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and
.B pkill
[options] pattern
.br
-.B pwait
+.B pidwait
[options] pattern
.SH DESCRIPTION
.B pgrep
@@ -45,7 +45,7 @@ will send the specified signal (by default
.BR SIGTERM )
to each process instead of listing them on stdout.
.PP
-.B pwait
+.B pidwait
will wait for each process instead of listing them on stdout.
.SH OPTIONS
.TP
@@ -60,7 +60,7 @@ only.)
\fB\-c\fR, \fB\-\-count\fR
Suppress normal output; instead print a count of matching processes. When
count does not match anything, e.g. returns zero, the command will return
-non-zero value. Note that for pkill and pwait, the count is the number of
+non-zero value. Note that for pkill and pidwait, the count is the number of
matching processes, not the processes that were successfully signaled or waited
for.
.TP
@@ -88,7 +88,7 @@ translated into
.BR pgrep 's,
.BR pkill 's,
or
-.BR pwait 's
+.BR pidwait 's
own process group.
.TP
\fB\-G\fR, \fB\-\-group\fR \fIgid\fP,...
@@ -126,7 +126,7 @@ is translated into
.BR pgrep 's,
.BR pkill 's,
or
-.BR pwait 's
+.BR pidwait 's
own session ID.
.TP
\fB\-t\fR, \fB\-\-terminal\fR \fIterm\fP,...
@@ -145,7 +145,7 @@ symbolical value may be used.
Negates the matching. This option is usually used in
.BR pgrep 's
or
-.BR pwait 's
+.BR pidwait 's
context. In
.BR pkill 's
context the short option is disabled to avoid accidental usage of the option.
@@ -154,7 +154,7 @@ context the short option is disabled to avoid accidental usage of the option.
Shows all thread ids instead of pids in
.BR pgrep 's
or
-.BR pwait 's
+.BR pidwait 's
context. In
.BR pkill 's
context this option is disabled.
@@ -167,7 +167,7 @@ match the
.TP
\fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR
Read \fIPID\fRs from \fIfile\fR. This option is more useful for
-.BR pkill or pwait
+.BR pkill or pidwait
than
.BR pgrep .
.TP
@@ -237,7 +237,7 @@ $ renice +4 $(pgrep chrome)
.PD 0
.TP
0
-One or more processes matched the criteria. For pkill and pwait, one or more
+One or more processes matched the criteria. For pkill and pidwait, one or more
processes must also have been successfully signalled or waited for.
.TP
1
@@ -258,7 +258,7 @@ The running
.BR pgrep ,
.BR pkill ,
or
-.B pwait
+.B pidwait
process will never report itself as a
match.
.SH BUGS
diff --git a/pgrep.c b/pgrep.c
index 4fe5e8a..1905cd1 100644
--- a/pgrep.c
+++ b/pgrep.c
@@ -38,7 +38,7 @@
#include <stdbool.h>
#include <time.h>
-#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN)
+#if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
#include <sys/epoll.h>
#include <sys/syscall.h>
#endif
@@ -68,8 +68,8 @@
static enum {
PGREP = 0,
PKILL,
-#ifdef ENABLE_PWAIT
- PWAIT,
+#ifdef ENABLE_PIDWAIT
+ PIDWAIT,
#endif
} prog_mode;
@@ -136,8 +136,8 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
fputs(_(" -q, --queue <value> integer value to be sent with the signal\n"), fp);
fputs(_(" -e, --echo display what is killed\n"), fp);
break;
-#ifdef ENABLE_PWAIT
- case PWAIT:
+#ifdef ENABLE_PIDWAIT
+ case PIDWAIT:
fputs(_(" -e, --echo display PIDs before waiting\n"), fp);
break;
#endif
@@ -687,7 +687,7 @@ static struct el * select_procs (int *num)
xerrx(EXIT_FAILURE, _("internal error"));
}
- // pkill and pwait don't support -w, but this is checked in getopt
+ // pkill and pidwait don't support -w, but this is checked in getopt
if (opt_threads) {
while (readtask(ptp, &task, &subtask)){
// don't add redundant tasks
@@ -742,7 +742,7 @@ static int signal_option(int *argc, char **argv)
return -1;
}
-#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN)
+#if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
static int pidfd_open (pid_t pid, unsigned int flags)
{
return syscall(__NR_pidfd_open, pid, flags);
@@ -793,9 +793,9 @@ static void parse_opts (int argc, char **argv)
{NULL, 0, NULL, 0}
};
-#ifdef ENABLE_PWAIT
- if (strcmp (program_invocation_short_name, "pwait") == 0) {
- prog_mode = PWAIT;
+#ifdef ENABLE_PIDWAIT
+ if (strcmp (program_invocation_short_name, "pidwait") == 0) {
+ prog_mode = PIDWAIT;
strcat (opts, "e");
} else
#endif
@@ -1008,7 +1008,7 @@ int main (int argc, char **argv)
int num;
int i;
int kill_count = 0;
-#ifdef ENABLE_PWAIT
+#ifdef ENABLE_PIDWAIT
int poll_count = 0;
int wait_count = 0;
int epollfd = epoll_create(1);
@@ -1055,8 +1055,8 @@ int main (int argc, char **argv)
fprintf(stdout, "%d\n", num);
return !kill_count;
-#ifdef ENABLE_PWAIT
- case PWAIT:
+#ifdef ENABLE_PIDWAIT
+ case PIDWAIT:
if (opt_count)
fprintf(stdout, "%d\n", num);
diff --git a/pwait.1 b/pidwait.1
similarity index 100%
rename from pwait.1
rename to pidwait.1
--
GitLab

View File

@ -0,0 +1,12 @@
diff -up ./sysctl.c.old ./sysctl.c
--- ./sysctl.c.old 2023-07-20 14:43:10.271856721 +0200
+++ ./sysctl.c 2023-07-21 14:50:39.792368077 +0200
@@ -578,7 +578,7 @@ static int WriteSetting(
}
if ((rc == EXIT_SUCCESS && !Quiet) || DryRun) {
if (NameOnly) {
- printf("%s\n", value);
+ printf("%s\n", dotted_key);
} else {
if (PrintName) {
printf("%s = %s\n", dotted_key, value);

View File

@ -0,0 +1,153 @@
diff -up ./NEWS.ori ./NEWS
--- ./NEWS.ori 2022-08-15 11:59:35.929714848 +0200
+++ ./NEWS 2022-08-15 12:00:12.892937479 +0200
@@ -1,4 +1,14 @@
procps-ng-NEXT
+<<<<<<< HEAD
+=======
+ * library
+ Re-add elogind support merge #151
+ * ps: threads again display when -L is used with -q issue #234
+ * ps: proper aix format string behavior was restored
+ * sysctl: print dotted keys again
+
+procps-ng-4.0.0
+>>>>>>> b159c198 (sysctl: print dotted keys again)
---------------
* Rename pwait to pidwait
diff -up ./sysctl.c.ori ./sysctl.c
--- ./sysctl.c.ori 2022-08-15 11:59:35.934714878 +0200
+++ ./sysctl.c 2022-08-15 12:00:12.893937485 +0200
@@ -152,7 +152,7 @@ static SysctlSetting *setting_new(
strcat(path + proc_len, key+1);
else
strcat(path + proc_len, key);
- /* change . to / */
+ /* change . to / for path */
slashdot(path + proc_len, '.', '/');
s = xmalloc(sizeof(SysctlSetting));
@@ -510,7 +510,8 @@ static int WriteSetting(
int rc = EXIT_SUCCESS;
FILE *fp;
- struct stat ts;
+ struct stat ts;
+ char *dotted_key;
if (!key || !path)
return rc;
@@ -523,13 +524,22 @@ static int WriteSetting(
return rc;
}
- if ((ts.st_mode & S_IWUSR) == 0) {
- xwarn(_("setting key \"%s\""), key);
+ /* Convert the globbed path into a dotted key */
+ if ( (dotted_key = strdup(path + strlen(PROC_PATH))) == NULL) {
+ xerrx(EXIT_FAILURE, _("strdup key"));
+ return EXIT_FAILURE;
+ }
+ slashdot(dotted_key, '/', '.');
+
+ if ((ts.st_mode & S_IWUSR) == 0) {
+ xwarn(_("setting key \"%s\""), dotted_key);
+ free(dotted_key);
return rc;
}
- if (S_ISDIR(ts.st_mode)) {
- xwarn(_("setting key \"%s\""), key);
+ if (S_ISDIR(ts.st_mode)) {
+ xwarn(_("setting key \"%s\""), dotted_key);
+ free(dotted_key);
return rc;
}
@@ -539,7 +549,7 @@ static int WriteSetting(
case ENOENT:
if (!IgnoreError) {
xwarnx(_("\"%s\" is an unknown key%s"),
- key, (ignore_failure?_(", ignoring"):""));
+ dotted_key, (ignore_failure?_(", ignoring"):""));
if (!ignore_failure)
rc = EXIT_FAILURE;
}
@@ -548,11 +558,11 @@ static int WriteSetting(
case EROFS:
case EACCES:
xwarnx(_("permission denied on key \"%s\"%s"),
- key, (ignore_failure?_(", ignoring"):""));
+ dotted_key, (ignore_failure?_(", ignoring"):""));
break;
default:
xwarn(_("setting key \"%s\"%s"),
- key, (ignore_failure?_(", ignoring"):""));
+ dotted_key, (ignore_failure?_(", ignoring"):""));
break;
}
if (!ignore_failure && errno != ENOENT)
@@ -561,7 +571,7 @@ static int WriteSetting(
if (0 < fprintf(fp, "%s\n", value))
rc = EXIT_SUCCESS;
if (close_stream(fp) != 0) {
- xwarn(_("setting key \"%s\""), path);
+ xwarn(_("setting key \"%s\""), dotted_key);
return rc;
}
}
@@ -571,7 +581,7 @@ static int WriteSetting(
printf("%s\n", value);
} else {
if (PrintName) {
- printf("%s = %s\n", path, value);
+ printf("%s = %s\n", dotted_key, value);
} else {
if (PrintNewline)
printf("%s\n", value);
@@ -580,6 +590,7 @@ static int WriteSetting(
}
}
}
+ free(dotted_key);
return rc;
}
diff -up ./testsuite/sysctl_slash_test.conf.ori ./testsuite/sysctl_slash_test.conf
--- ./testsuite/sysctl_slash_test.conf.ori 2022-08-15 12:00:12.894937491 +0200
+++ ./testsuite/sysctl_slash_test.conf 2022-08-15 12:00:12.893937485 +0200
@@ -0,0 +1 @@
+kernel/hostname = procps-test
diff -up ./testsuite/sysctl.test/sysctl_write.exp.ori ./testsuite/sysctl.test/sysctl_write.exp
--- ./testsuite/sysctl.test/sysctl_write.exp.ori 2022-08-15 11:59:35.934714878 +0200
+++ ./testsuite/sysctl.test/sysctl_write.exp 2022-08-15 12:00:12.893937485 +0200
@@ -3,11 +3,19 @@ set sysctl ${topdir}sysctl
set test "sysctl write from command line"
spawn $sysctl --dry-run kernel.hostname=procps-test
-expect_pass "$test" "/proc/sys/kernel/hostname = procps-test"
+expect_pass "$test" "kernel.hostname = procps-test"
+
+set test "sysctl write from command line using slash"
+spawn $sysctl --dry-run kernel/hostname=procps-test
+expect_pass "$test" "kernel.hostname = procps-test"
set test "sysctl write from configuration file"
spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_glob_test.conf
-expect_pass "$test" "/proc/sys/fs/protected_fifos = 2\\s+/proc/sys/fs/protected_symlinks = 2\\s+/proc/sys/fs/protected_hardlinks = 1"
+expect_pass "$test" "fs.protected_fifos = 2\\s+fs.protected_symlinks = 2\\s+fs.protected_hardlinks = 1"
+
+set test "sysctl write from file with slashes"
+spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_slash_test.conf
+expect_pass "$test" "kernel.hostname = procps-test"
set hostname_file "/proc/sys/kernel/hostname"
if {[file exists ${hostname_file}]} {
@@ -25,5 +33,5 @@ if {[file exists ${hostname_file}]} {
expect_spawn_retval "$test" 0
}
} else {
- unsupported "sysctl write: hostname file doe not exist"
+ unsupported "sysctl write: hostname file does not exist"
}

View File

@ -0,0 +1,833 @@
diff -up ./NEWS.ori ./NEWS
diff -up ./sysctl.c.ori ./sysctl.c
--- ./sysctl.c.ori 2021-02-09 11:11:25.000000000 +0100
+++ ./sysctl.c 2022-07-29 15:50:50.767380061 +0200
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * Part of this code comes from systemd, especially sysctl.c
* Changelog:
* v1.01:
* - added -p <preload> to preload values from a file
@@ -40,6 +41,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <ctype.h>
#include "c.h"
#include "fileutils.h"
@@ -66,12 +68,34 @@ static bool PrintName;
static bool PrintNewline;
static bool IgnoreError;
static bool Quiet;
+static bool DryRun;
static char *pattern;
#define LINELEN 4096
static char *iobuf;
static size_t iolen = LINELEN;
+typedef struct SysctlSetting {
+ char *key;
+ char *path;
+ char *value;
+ bool ignore_failure;
+ bool glob_exclude;
+ struct SysctlSetting *next;
+} SysctlSetting;
+
+typedef struct SettingList {
+ struct SysctlSetting *head;
+ struct SysctlSetting *tail;
+} SettingList;
+
+#define GLOB_CHARS "*?["
+static inline bool string_is_glob(const char *p)
+{
+ return !!strpbrk(p, GLOB_CHARS);
+}
+
+
/* Function prototypes. */
static int pattern_match(const char *string, const char *pat);
static int DisplayAll(const char *restrict const path);
@@ -100,6 +124,81 @@ static void slashdot(char *restrict p, c
}
}
+static void setting_free(SysctlSetting *s) {
+ if (!s)
+ return;
+
+ free(s->key);
+ free(s->path);
+ free(s->value);
+ free(s);
+}
+
+static SysctlSetting *setting_new(
+ const char *key,
+ const char *value,
+ bool ignore_failure,
+ bool glob_exclude) {
+
+ SysctlSetting *s = NULL;
+ char *path = NULL;
+ int proc_len;
+
+ proc_len = strlen(PROC_PATH);
+ /* used to open the file */
+ path = xmalloc(strlen(key) + proc_len + 2);
+ strcpy(path, PROC_PATH);
+ if (key[0] == '-')
+ strcat(path + proc_len, key+1);
+ else
+ strcat(path + proc_len, key);
+ /* change . to / */
+ slashdot(path + proc_len, '.', '/');
+
+ s = xmalloc(sizeof(SysctlSetting));
+
+ *s = (SysctlSetting) {
+ .key = strdup(key),
+ .path = path,
+ .value = value? strdup(value): NULL,
+ .ignore_failure = ignore_failure,
+ .glob_exclude = glob_exclude,
+ .next = NULL,
+ };
+
+ return s;
+}
+
+static void settinglist_add(SettingList *l, SysctlSetting *s) {
+ SysctlSetting *old_tail;
+
+ if (!l)
+ return;
+
+ if (l->head == NULL)
+ l->head = s;
+
+ if (l->tail != NULL) {
+ old_tail = l->tail;
+ old_tail->next = s;
+ }
+ l->tail = s;
+}
+
+static SysctlSetting *settinglist_findpath(const SettingList *l, const char *path) {
+ SysctlSetting *node;
+
+ for (node=l->head; node != NULL; node = node->next) {
+ if (strcmp(node->path, path) == 0)
+ return node;
+ }
+ return NULL;
+}
+
+/* Function prototypes. */
+static int pattern_match(const char *string, const char *pat);
+static int DisplayAll(const char *restrict const path);
+
/*
* Display the usage format
*/
@@ -115,6 +214,7 @@ static void __attribute__ ((__noreturn__
fputs(_(" -A alias of -a\n"), out);
fputs(_(" -X alias of -a\n"), out);
fputs(_(" --deprecated include deprecated parameters to listing\n"), out);
+ fputs(_(" --dry-run Print the key and values but do not write\n"), out);
fputs(_(" -b, --binary print value without new line\n"), out);
fputs(_(" -e, --ignore ignore unknown variables errors\n"), out);
fputs(_(" -N, --names print variable names without values\n"), out);
@@ -138,6 +238,39 @@ static void __attribute__ ((__noreturn__
}
/*
+ * Strip left/leading side of a string
+ */
+static char *lstrip(char *line)
+{
+ char *start;
+
+ if (!line || !*line)
+ return line;
+
+ start = line;
+ while(isspace(*start)) start++;
+
+ return start;
+}
+
+/*
+ * Strip right/trailing side of a string
+ * by placing a \0
+ */
+static void rstrip(char *line)
+{
+ char *end;
+
+ if (!line || !*line)
+ return;
+
+ end = line + strlen(line) - 1;
+ while(end > line && isspace(*end)) end--;
+
+ end[1] = '\0';
+}
+
+/*
* Strip the leading and trailing spaces from a string
*/
static char *StripLeadingAndTrailingSpaces(char *oneline)
@@ -166,7 +299,7 @@ static char *StripLeadingAndTrailingSpac
*/
static int ReadSetting(const char *restrict const name)
{
- int rc = 0;
+ int rc = EXIT_SUCCESS;
char *restrict tmpname;
char *restrict outname;
ssize_t rlen;
@@ -198,7 +331,7 @@ static int ReadSetting(const char *restr
if (stat(tmpname, &ts) < 0) {
if (!IgnoreError) {
xwarn(_("cannot stat %s"), tmpname);
- rc = -1;
+ rc = EXIT_FAILURE;
}
goto out;
}
@@ -215,7 +348,7 @@ static int ReadSetting(const char *restr
}
if (pattern && !pattern_match(outname, pattern)) {
- rc = 0;
+ rc = EXIT_SUCCESS;
goto out;
}
@@ -231,19 +364,19 @@ static int ReadSetting(const char *restr
case ENOENT:
if (!IgnoreError) {
xwarnx(_("\"%s\" is an unknown key"), outname);
- rc = -1;
+ rc = EXIT_FAILURE;
}
break;
case EACCES:
xwarnx(_("permission denied on key '%s'"), outname);
- rc = -1;
+ rc = EXIT_FAILURE;
break;
case EIO: /* Ignore stable_secret below /proc/sys/net/ipv6/conf */
- rc = -1;
+ rc = EXIT_FAILURE;
break;
default:
xwarn(_("reading key \"%s\""), outname);
- rc = -1;
+ rc = EXIT_FAILURE;
break;
}
} else {
@@ -279,7 +412,7 @@ static int ReadSetting(const char *restr
case EACCES:
xwarnx(_("permission denied on key '%s'"),
outname);
- rc = -1;
+ rc = EXIT_FAILURE;
break;
case EISDIR: {
size_t len;
@@ -291,11 +424,11 @@ static int ReadSetting(const char *restr
goto out;
}
case EIO: /* Ignore stable_secret below /proc/sys/net/ipv6/conf */
- rc = -1;
+ rc = EXIT_FAILURE;
break;
default:
xwarnx(_("reading key \"%s\""), outname);
- rc = -1;
+ rc = EXIT_FAILURE;
case 0:
break;
}
@@ -323,7 +456,7 @@ static int is_deprecated(char *filename)
*/
static int DisplayAll(const char *restrict const path)
{
- int rc = 0;
+ int rc = EXIT_SUCCESS;
int rc2;
DIR *restrict dp;
struct dirent *restrict de;
@@ -333,7 +466,7 @@ static int DisplayAll(const char *restri
if (!dp) {
xwarnx(_("unable to open directory \"%s\""), path);
- rc = -1;
+ rc = EXIT_FAILURE;
} else {
readdir(dp); /* skip . */
readdir(dp); /* skip .. */
@@ -369,130 +502,183 @@ static int DisplayAll(const char *restri
/*
* Write a sysctl setting
*/
-static int WriteSetting(const char *setting)
-{
- int rc = 0;
- const char *name = setting;
- const char *value;
- const char *equals;
- char *tmpname;
- char *outname;
- char *last_dot;
- bool ignore_failure;
+static int WriteSetting(
+ const char *key,
+ const char *path,
+ const char *value,
+ const bool ignore_failure) {
- FILE *fp;
+ int rc = EXIT_SUCCESS;
+ FILE *fp;
struct stat ts;
- if (!name)
- /* probably don't want to display this err */
- return 0;
-
- equals = strchr(setting, '=');
-
- if (!equals) {
- xwarnx(_("\"%s\" must be of the form name=value"),
- setting);
- return -1;
- }
-
- /* point to the value in name=value */
- value = equals + 1;
-
- if (!*name || name == equals) {
- xwarnx(_("malformed setting \"%s\""), setting);
- return -2;
- }
-
- ignore_failure = name[0] == '-';
- if (ignore_failure)
- name++;
+ if (!key || !path)
+ return rc;
- /* used to open the file */
- tmpname = xmalloc(equals - name + 1 + strlen(PROC_PATH));
- strcpy(tmpname, PROC_PATH);
- strncat(tmpname, name, (int) (equals - name));
- tmpname[equals - name + strlen(PROC_PATH)] = 0;
- /* change . to / */
- slashdot(tmpname + strlen(PROC_PATH), '.', '/');
-
- /* used to display the output */
- outname = xmalloc(equals - name + 1);
- strncpy(outname, name, (int) (equals - name));
- outname[equals - name] = 0;
- /* change / to . */
- slashdot(outname, '/', '.');
- last_dot = strrchr(outname, '.');
- if (last_dot != NULL && is_deprecated(last_dot + 1)) {
- xwarnx(_("%s is deprecated, value not set"), outname);
- goto out;
- }
-
- if (stat(tmpname, &ts) < 0) {
+ if (stat(path, &ts) < 0) {
if (!IgnoreError) {
- xwarn(_("cannot stat %s"), tmpname);
- rc = -1;
+ xwarn(_("cannot stat %s"), path);
+ rc = EXIT_FAILURE;
}
- goto out;
+ return rc;
}
if ((ts.st_mode & S_IWUSR) == 0) {
- xwarn(_("setting key \"%s\""), outname);
- goto out;
+ xwarn(_("setting key \"%s\""), key);
+ return rc;
}
if (S_ISDIR(ts.st_mode)) {
- xwarn(_("setting key \"%s\""), outname);
- goto out;
+ xwarn(_("setting key \"%s\""), key);
+ return rc;
}
- fp = fprocopen(tmpname, "w");
-
- if (!fp) {
- switch (errno) {
- case ENOENT:
- if (!IgnoreError) {
- xwarnx(_("\"%s\" is an unknown key%s"), outname, (ignore_failure?_(", ignoring"):""));
+ if (!DryRun) {
+ if ((fp = fprocopen(path, "w")) == NULL) {
+ switch (errno) {
+ case ENOENT:
+ if (!IgnoreError) {
+ xwarnx(_("\"%s\" is an unknown key%s"),
+ key, (ignore_failure?_(", ignoring"):""));
if (!ignore_failure)
- rc = -1;
+ rc = EXIT_FAILURE;
}
break;
- case EPERM:
- case EROFS:
- case EACCES:
- xwarnx(_("permission denied on key \"%s\"%s"), outname, (ignore_failure?_(", ignoring"):""));
- break;
- default:
- xwarn(_("setting key \"%s\"%s"), outname, (ignore_failure?_(", ignoring"):""));
- break;
- }
- if (!ignore_failure && errno != ENOENT)
- rc = -1;
- } else {
- rc = fprintf(fp, "%s\n", value);
- if (0 < rc)
- rc = 0;
- if (close_stream(fp) != 0)
- xwarn(_("setting key \"%s\""), outname);
- else if (rc == 0 && !Quiet) {
- if (NameOnly) {
- fprintf(stdout, "%s\n", outname);
- } else {
- if (PrintName) {
- fprintf(stdout, "%s = %s\n",
- outname, value);
- } else {
- if (PrintNewline)
- fprintf(stdout, "%s\n", value);
- else
- fprintf(stdout, "%s", value);
- }
- }
- }
- }
- out:
- free(tmpname);
- free(outname);
- return rc;
+ case EPERM:
+ case EROFS:
+ case EACCES:
+ xwarnx(_("permission denied on key \"%s\"%s"),
+ key, (ignore_failure?_(", ignoring"):""));
+ break;
+ default:
+ xwarn(_("setting key \"%s\"%s"),
+ key, (ignore_failure?_(", ignoring"):""));
+ break;
+ }
+ if (!ignore_failure && errno != ENOENT)
+ rc = EXIT_FAILURE;
+ } else {
+ if (0 < fprintf(fp, "%s\n", value))
+ rc = EXIT_SUCCESS;
+ if (close_stream(fp) != 0) {
+ xwarn(_("setting key \"%s\""), path);
+ return rc;
+ }
+ }
+ }
+ if ((rc == EXIT_SUCCESS && !Quiet) || DryRun) {
+ if (NameOnly) {
+ printf("%s\n", value);
+ } else {
+ if (PrintName) {
+ printf("%s = %s\n", path, value);
+ } else {
+ if (PrintNewline)
+ printf("%s\n", value);
+ else
+ printf("%s", value);
+ }
+ }
+ }
+ return rc;
+}
+
+/*
+ * parse each configuration line, there are multiple ways of specifying
+ * a key/value here:
+ *
+ * key = value simple setting
+ * -key = value ignore errors
+ * key.pattern.*.with.glob = value set keys that match glob
+ * -key.pattern.exclude.with.glob dont set this value
+ * key.pattern.override.with.glob = value set this glob match to value
+ *
+ */
+
+static SysctlSetting *parse_setting_line(
+ const char *path,
+ const int linenum,
+ char *line)
+{
+ SysctlSetting *s;
+ char *key;
+ char *value;
+ bool glob_exclude = FALSE;
+ bool ignore_failure = FALSE;
+
+ key = lstrip(line);
+ if (strlen(key) < 2)
+ return NULL;
+
+ /* skip over comments */
+ if (key[0] == '#' || key[0] == ';')
+ return NULL;
+
+ if (pattern && !pattern_match(key, pattern))
+ return NULL;
+
+ value = strchr(key, '=');
+ if (value == NULL) {
+ if (key[0] == '-') {
+ glob_exclude = TRUE;
+ key++;
+ value = NULL;
+ rstrip(key);
+ } else {
+ xwarnx(_("%s(%d): invalid syntax, continuing..."),
+ path, linenum);
+ return NULL;
+ }
+ } else {
+ value[0]='\0';
+ if (key[0] == '-') {
+ ignore_failure = TRUE;
+ key++;
+ }
+ value++; // skip over =
+ value=lstrip(value);
+ rstrip(value);
+ rstrip(key);
+ }
+ return setting_new(key, value, ignore_failure, glob_exclude);
+}
+
+/* Go through the setting list, expand and sort out
+ * setting globs and actually write the settings out
+ */
+static int write_setting_list(const SettingList *sl)
+{
+ SysctlSetting *node;
+ int rc = EXIT_SUCCESS;
+
+ for (node=sl->head; node != NULL; node=node->next) {
+ if (node->glob_exclude)
+ continue;
+
+ if (string_is_glob(node->path)) {
+ char *gl_path;
+ glob_t globbuf;
+ int i;
+
+ if (glob(node->path, 0, NULL, &globbuf) != 0)
+ continue;
+
+ for(i=0; i < globbuf.gl_pathc; i++) {
+ if (settinglist_findpath(sl, globbuf.gl_pathv[i]))
+ continue; // override or exclude
+
+ rc |= WriteSetting(node->key, globbuf.gl_pathv[i], node->value,
+ node->ignore_failure);
+ }
+ } else {
+ rc |= WriteSetting(node->key, node->path, node->value,
+ node->ignore_failure);
+ }
+
+
+ }
+
+ return rc;
}
static int pattern_match(const char *string, const char *pat)
@@ -513,12 +699,12 @@ static int pattern_match(const char *str
* Preload the sysctl's from the conf file. We parse the file and then
* reform it (strip out whitespace).
*/
-static int Preload(const char *restrict const filename)
+static int Preload(SettingList *setlist, const char *restrict const filename)
{
FILE *fp;
char *t;
int n = 0;
- int rc = 0;
+ int rc = EXIT_SUCCESS;
ssize_t rlen;
char *name, *value;
glob_t globbuf;
@@ -547,62 +733,26 @@ static int Preload(const char *restrict
? stdin : fopen(globbuf.gl_pathv[j], "r");
if (!fp) {
xwarn(_("cannot open \"%s\""), globbuf.gl_pathv[j]);
- rc = -1;
- goto out;
+ return EXIT_FAILURE;
}
while ((rlen = getline(&iobuf, &iolen, fp)) > 0) {
size_t offset;
+ SysctlSetting *setting;
n++;
if (rlen < 2)
continue;
- t = StripLeadingAndTrailingSpaces(iobuf);
- if (strlen(t) < 2)
- continue;
-
- if (*t == '#' || *t == ';')
- continue;
-
- name = strtok(t, "=");
- if (!name || !*name) {
- xwarnx(_("%s(%d): invalid syntax, continuing..."),
- globbuf.gl_pathv[j], n);
- continue;
- }
-
- StripLeadingAndTrailingSpaces(name);
-
- if (pattern && !pattern_match(name, pattern))
- continue;
-
- offset = strlen(name);
- memmove(&iobuf[0], name, offset);
- iobuf[offset++] = '=';
-
- value = strtok(NULL, "\n\r");
- if (!value || !*value) {
- xwarnx(_("%s(%d): invalid syntax, continuing..."),
- globbuf.gl_pathv[j], n);
- continue;
- }
-
- while ((*value == ' ' || *value == '\t') && *value != 0)
- value++;
-
- /* should NameOnly affect this? */
- memmove(&iobuf[offset], value, strlen(value));
- offset += strlen(value);
- iobuf[offset] = '\0';
-
- rc |= WriteSetting(iobuf);
+ if ( (setting = parse_setting_line(globbuf.gl_pathv[j], n, iobuf))
+ == NULL)
+ continue;
+ settinglist_add(setlist, setting);
}
fclose(fp);
}
-out:
return rc;
}
@@ -618,7 +768,7 @@ static int sortpairs(const void *A, cons
return strcmp(a->name, b->name);
}
-static int PreloadSystem(void)
+static int PreloadSystem(SettingList *setlist)
{
unsigned di, i;
const char *dirs[] = {
@@ -630,7 +780,7 @@ static int PreloadSystem(void)
};
struct pair **cfgs = NULL;
unsigned ncfgs = 0;
- int rc = 0;
+ int rc = EXIT_SUCCESS;
struct stat ts;
enum { nprealloc = 16 };
@@ -688,14 +838,14 @@ static int PreloadSystem(void)
for (i = 0; i < ncfgs; ++i) {
if (!Quiet)
printf(_("* Applying %s ...\n"), cfgs[i]->value);
- rc |= Preload(cfgs[i]->value);
+ rc |= Preload(setlist, cfgs[i]->value);
}
if (stat(DEFAULT_PRELOAD, &ts) == 0 && S_ISREG(ts.st_mode)) {
if (!Quiet)
printf(_("* Applying %s ...\n"), DEFAULT_PRELOAD);
- rc |= Preload(DEFAULT_PRELOAD);
+ rc |= Preload(setlist, DEFAULT_PRELOAD);
}
/* cleaning */
@@ -717,15 +867,19 @@ int main(int argc, char *argv[])
bool preloadfileOpt = false;
int ReturnCode = 0;
int c;
+ int rc;
const char *preloadfile = NULL;
+ SettingList *setlist;
enum {
DEPRECATED_OPTION = CHAR_MAX + 1,
- SYSTEM_OPTION
+ SYSTEM_OPTION,
+ DRYRUN_OPTION
};
static const struct option longopts[] = {
{"all", no_argument, NULL, 'a'},
{"deprecated", no_argument, NULL, DEPRECATED_OPTION},
+ {"dry-run", no_argument, NULL, DRYRUN_OPTION},
{"binary", no_argument, NULL, 'b'},
{"ignore", no_argument, NULL, 'e'},
{"names", no_argument, NULL, 'N'},
@@ -753,6 +907,10 @@ int main(int argc, char *argv[])
IgnoreError = false;
Quiet = false;
IgnoreDeprecated = true;
+ DryRun = false;
+ setlist = xmalloc(sizeof(SettingList));
+ setlist->head = NULL;
+ setlist->tail = NULL;
if (argc < 2)
Usage(stderr);
@@ -805,7 +963,12 @@ int main(int argc, char *argv[])
break;
case SYSTEM_OPTION:
IgnoreError = true;
- return PreloadSystem();
+ rc |= PreloadSystem(setlist);
+ rc |= write_setting_list(setlist);
+ return rc;
+ case DRYRUN_OPTION:
+ DryRun = true;
+ break;
case 'r':
pattern = xstrdup(optarg);
break;
@@ -833,15 +996,16 @@ int main(int argc, char *argv[])
int ret = EXIT_SUCCESS, i;
if (!preloadfile) {
if (!argc) {
- ret |= Preload(DEFAULT_PRELOAD);
+ ret |= Preload(setlist, DEFAULT_PRELOAD);
}
} else {
/* This happens when -pfile option is
* used without space. */
- ret |= Preload(preloadfile);
+ ret |= Preload(setlist, preloadfile);
}
for (i = 0; i < argc; i++)
- ret |= Preload(argv[i]);
+ ret |= Preload(setlist, argv[i]);
+ ret |= write_setting_list(setlist);
return ret;
}
@@ -855,9 +1019,14 @@ int main(int argc, char *argv[])
program_invocation_short_name);
for ( ; *argv; argv++) {
- if (WriteMode || strchr(*argv, '='))
- ReturnCode += WriteSetting(*argv);
- else
+ if (WriteMode || strchr(*argv, '=')) {
+ SysctlSetting *s;
+ if ( (s = parse_setting_line("command line", 0, *argv)) != NULL)
+ ReturnCode |= WriteSetting(s->key, s->path, s->value,
+ s->ignore_failure);
+ else
+ ReturnCode |= EXIT_FAILURE;
+ } else
ReturnCode += ReadSetting(*argv);
}
return ReturnCode;
diff -up ./testsuite/config/unix.exp.ori ./testsuite/config/unix.exp
--- ./testsuite/config/unix.exp.ori 2021-02-09 11:11:25.000000000 +0100
+++ ./testsuite/config/unix.exp 2022-07-29 15:50:50.768380067 +0200
@@ -136,6 +136,15 @@ proc expect_table_dsc { test match_heade
#}
}
+proc expect_spawn_retval { test retval } {
+ foreach {pid spawnid os_error_flag value} [wait] break
+
+ if {$value == $retval} {
+ return
+ }
+ fail "$test (exit value)"
+}
+
proc make_pipeproc { } {
global pipeproc_pid pipeproc_spawnid topdir
diff -up ./testsuite/sysctl_glob_test.conf.ori ./testsuite/sysctl_glob_test.conf
--- ./testsuite/sysctl_glob_test.conf.ori 2022-07-29 15:50:50.768380067 +0200
+++ ./testsuite/sysctl_glob_test.conf 2022-07-29 15:50:50.768380067 +0200
@@ -0,0 +1,6 @@
+#
+# Test configuration for for glob in sysctl
+#
+fs.protected_* = 2
+fs.protected_hardlinks = 1
+-fs.protected_regular
diff -up ./testsuite/sysctl.test/sysctl_write.exp.ori ./testsuite/sysctl.test/sysctl_write.exp
--- ./testsuite/sysctl.test/sysctl_write.exp.ori 2022-07-29 15:50:50.768380067 +0200
+++ ./testsuite/sysctl.test/sysctl_write.exp 2022-07-29 15:50:50.768380067 +0200
@@ -0,0 +1,29 @@
+
+set sysctl ${topdir}sysctl
+
+set test "sysctl write from command line"
+spawn $sysctl --dry-run kernel.hostname=procps-test
+expect_pass "$test" "/proc/sys/kernel/hostname = procps-test"
+
+set test "sysctl write from configuration file"
+spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_glob_test.conf
+expect_pass "$test" "/proc/sys/fs/protected_fifos = 2\\s+/proc/sys/fs/protected_symlinks = 2\\s+/proc/sys/fs/protected_hardlinks = 1"
+
+set hostname_file "/proc/sys/kernel/hostname"
+if {[file exists ${hostname_file}]} {
+ if {[file writable ${hostname_file}]} {
+ unsupported "sysctl write: hostname file is writable"
+ } else {
+ set test "sysctl write unwritable file"
+ spawn $sysctl -q kernel.hostname=procpstest
+ expect_pass "$test" "sysctl: permission denied on key \"kernel.hostname\"\\s*$"
+ expect_spawn_retval "$test" 1
+
+ set test "sysctl write unwritable file ignored"
+ spawn $sysctl -q -- -kernel.hostname=procpstest
+ expect_pass "$test" "sysctl: permission denied on key \"kernel.hostname\", ignoring\\s*$"
+ expect_spawn_retval "$test" 0
+ }
+} else {
+ unsupported "sysctl write: hostname file doe not exist"
+}

View File

@ -0,0 +1,12 @@
diff --git a/top/top.c b/top/top.c
index 58badaa..21fab42 100644
--- a/top/top.c
+++ b/top/top.c
@@ -5704,6 +5704,7 @@ static void keys_xtra (int ch) {
switch (ch) {
case 'M':
w->rc.sortindx = EU_MEM;
+ mkVIZrow1(w); // we need to avoid hiding tasks if scrolled too much
// xmsg = "Memory";
break;
case 'N':

View File

@ -3,33 +3,33 @@
Summary: System and process monitoring utilities
Name: procps-ng
Version: 3.3.15
Version: 3.3.17
Release: 14%{?dist}
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
Group: Applications/System
URL: https://sourceforge.net/projects/procps-ng/
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
# README files are missing in latest tarball
# wget https://gitlab.com/procps-ng/procps/raw/e0784ddaed30d095bb1d9a8ad6b5a23d10a212c4/README.md
Source1: README.md
# wget https://gitlab.com/procps-ng/procps/raw/e0784ddaed30d095bb1d9a8ad6b5a23d10a212c4/top/README.top
Source2: README.top
Patch1: procps-ng-3.3.15-pidof-show-worker-threads.patch
Patch2: procps-ng-3.3.15-pgrep-uid-conversion-overflow.patch
Patch3: procps-ng-3.3.15-vmstat-watch-manpage.patch
Patch4: procps-ng-3.3.15-pidof-kernel-workers-option.patch
Patch5: procps-ng-3.3.15-pidof-separator-option-backport.patch
Patch6: procps-ng-3.3.15-uptime-pretty-mod.patch
Patch7: procps-ng-3.3.15-vmstat-omit-first-report.patch
Patch8: procps-ng-3.3.15-sysctl-config-dir-order.patch
Patch9: procps-ng-3.3.15-pgrep-uid-gid-overflow.patch
Patch10: procps-ng-3.3.15-display-sig-unsafe.patch
Patch11: procps-ng-3.3.15-ps-select.patch
Patch12: procps-ng-3.3.15-ps-out-of-bonds-read.patch
Patch13: procps-ng-3.3.15-cve-2023-4016.patch
Patch1: pwait-to-pidwait.patch
Patch2: covscan_findings.patch
Patch3: uptime-pretty-mod.patch
Patch4: free-new-used-calc.patch
Patch5: sysctl-support-systemd-globs.patch
Patch6: sysctl-print-dotted-keys-again.patch
Patch7: pgrep-uid-gid-overflow-backport.patch
Patch8: display-sig-unsafe.patch
Patch9: ps-out-of-bonds-read.patch
Patch10: sysctl-nameonly-shows-value.patch
Patch11: cve-2023-4016.patch
Patch12: top-invisible-tasks-if-memsort.patch
BuildRequires: make
BuildRequires: ncurses-devel
BuildRequires: libtool
BuildRequires: autoconf
@ -38,6 +38,7 @@ BuildRequires: gcc
BuildRequires: gettext-devel
BuildRequires: systemd-devel
BuildRequires: git
BuildRequires: po4a
%if %{tests_enabled}
BuildRequires: dejagnu
@ -54,8 +55,8 @@ Provides: /bin/ps
%description
The procps package contains a set of system utilities that provide
system information. Procps includes ps, free, skill, pkill, pgrep,
snice, tload, top, uptime, vmstat, pidof, pmap, slabtop, w, watch
and pwdx.
snice, tload, top, uptime, vmstat, pidof, pmap, slabtop, w, watch,
pwdx and pidwait.
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
@ -71,11 +72,11 @@ 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. The pwdx command reports the current
working directory of a process or processes.
working directory of a process or processes. The pidwait command
waits for processes of specified names.
%package devel
Summary: System and process monitoring utilities
Group: Development/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
Provides: procps-devel = %{version}-%{release}
Obsoletes: procps-devel < 3.2.9-1
@ -85,7 +86,6 @@ System and process monitoring utilities development headers
%package i18n
Summary: Internationalization pack for procps-ng
Group: Applications/System
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
@ -98,11 +98,11 @@ Conflicts: man-pages-pl < 0.7-5
Internationalization pack for procps-ng
%prep
%autosetup -S git
%autosetup -S git -n procps-%{version}
cp -p %{SOURCE1} .
cp -p %{SOURCE2} top/
%build
# The following stuff is needed for git archives only
#echo "%{version}" > .tarball-version
@ -114,14 +114,15 @@ autoreconf --verbose --force --install
--exec-prefix=/ \
--docdir=/unwanted \
--disable-static \
--enable-w-from \
--disable-w-from \
--disable-kill \
--enable-watch8bit \
--enable-skill \
--enable-sigwinch \
--enable-libselinux \
--with-systemd \
--disable-modern-top
--disable-modern-top\
--enable-pidwait
make CFLAGS="%{optflags}"
@ -133,11 +134,10 @@ make check
%install
make DESTDIR=%{buildroot} install
%make_install
# translated man pages
find man-po/ -type d -maxdepth 1 -mindepth 1 | while read dirname; do cp -a $dirname %{buildroot}%{_mandir}/ ; done
rm -f %{buildroot}%{_mandir}/{de,fr,uk}/man1/kill.1
# these are created by make, yet empty. This causes rpmbuild errors.
rm -rf %{buildroot}%{_mandir}/{pl,pt_BR,sv}/man5
%find_lang %{name} --all-name --with-man
@ -147,7 +147,6 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
%files
%doc AUTHORS Documentation/bugs.md Documentation/FAQ NEWS README.md top/README.top Documentation/TODO
%{!?_licensedir:%global license %%doc}
%license COPYING COPYING.LIB
%{_libdir}/libprocps.so.*
%{_bindir}/*
@ -161,7 +160,6 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
%exclude /unwanted/*
%files devel
%{!?_licensedir:%global license %%doc}
%license COPYING COPYING.LIB
%{_libdir}/libprocps.so
%{_libdir}/pkgconfig/libprocps.pc
@ -171,73 +169,130 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
%files i18n -f %{name}.lang
%changelog
* Tue Aug 15 2023 Jan Rybar <jrybar@redhat.com> - 3.3.15-14
- CVE-2023-4016: ps: possible buffer overflow
- Resolves: rhbz#2228503
* Mon Jan 22 2024 Jan Rybar <jrybar@redhat.com> - 3.3.17-14
- top: processes for specific user not displayed if sorted by mem
- Resolves: RHEL-16278
* Tue Jan 17 2023 Jan Rybar <jrybar@redhat.com> - 3.3.15-13
* Fri Aug 11 2023 Jan Rybar <jrybar@redhat.com> - 3.3.17-13
- ps: mitigation of possible buffer overflow
- Resolves: rhbz#2228504
* Tue Jul 25 2023 Jan Rybar <jrybar@redhat.com> - 3.3.17-12
- sysctl: '-N' option shows values instead of names if '-p'
- Resolves: rhbz#2222056
* Thu Jan 26 2023 Jan Rybar <jrybar@redhat.com> - 3.3.17-11
- version bump requested to create -devel subpkg for CRB inclusion
- Resolves: rhbz#2164781
- Resolves: rhbz#2158253
* Tue Jan 17 2023 Jan Rybar <jrybar@redhat.com> - 3.3.15-12
* Wed Jan 18 2023 Jan Rybar <jrybar@redhat.com> - 3.3.17-10
- ps: out-of-bonds read in quick mode
- Resolves: rhbz#2153813
- Resolves: rhbz#2161648
* Tue Dec 13 2022 Kyle Walker <kwalker@redhat.com> - 3.3.15-11
- ps: revert increase command name length to 64 ____ (catch up)
- Resolves: rhbz#2144978
* Wed Nov 23 2022 Jan Rybar <jrybar@redhat.com> - 3.3.15-10
* Tue Nov 29 2022 Jan Rybar <jrybar@redhat.com> - 3.3.17-9
- display.c: backport: async-signal-unsafe handler deadlocks on SIGHUP
- Resolves: rhbz#2141696
- Resolves: rhbz#2141697
* Wed Aug 17 2022 Jan Rybar <jrybar@redhat.com> - 3.3.15-9
- pgrep: backport uid/gid overflow fix
- Resolves: rhbz#1827731
* Thu Aug 18 2022 Jan Rybar <jrybar@redhat.com> - 3.3.17-8
- pgrep: uid/gid overflow fix backport
- Resolves: rhbz#2119083
* Wed Jul 20 2022 Jan Rybar <jrybar@redhat.com> - 3.3.15-8
- vmstat: added -y option to omit first report
- Resolves: rhbz#2027350
- sysctl: backport config directory order, align with systemd
- Resolves: rhbz#2111915
* Mon Aug 15 2022 Jan Rybar <jrybar@redhat.com> - 3.3.17-7
- sysctl: backport - keys with dots instead of slashes again
- Resolves: rhbz#2116977
- Related: rhbz#2052536
* Wed Mar 23 2022 Jan Rybar <jrybar@redhat.com> - 3.3.15-7
* Fri Jul 29 2022 Jan Rybar <jrybar@redhat.com> - 3.3.17-6
- free: backport new 'used' calculation
- sysctl: backport support of systemd glob patterns
- Resolves: rhbz#2003033
- Resolves: rhbz#2052536
* Fri Mar 25 2022 Jan Rybar <jrybar@redhat.com> - 3.3.17-5
- uptime: human readable data not shown if 364 days up
- Resolves: rhbz#1772999
- Resolves: rhbz#2067166
* Tue Dec 01 2020 Jan Rybar <jrybar@redhat.com> - 3.3.15-6
- pidof: option for separator collides with other option
- Resolves: rhbz#1895985
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 3.3.17-4
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Mon Nov 09 2020 Jan Rybar <jrybar@redhat.com> - 3.3.15-5
- version bump due to unspotted malformed backport patch
- Resolves: rhbz#1860486
- Resolves: rhbz#1894526
- Related: rhbz#1803640
* Fri Jul 09 2021 Jan Rybar <jrybar@redhat.com> - 3.3.17-3
- Coverity scan findings fix
- Resolves: rhbz#1938848
* Fri Nov 06 2020 Jan Rybar <jrybar@redhat.com> - 3.3.15-4
- pidof: new option to show kernel worker threads
- pidof: empty input causes to show kernel worker threads
- Resolves: rhbz#1860486
- Resolves: rhbz#1894526
- Related: rhbz#1803640
-
* Wed Jul 08 2020 Jan Rybar <jrybar@redhat.com> - 3.3.15-3
- pgrep: uid/gid conversion overflow
- vmstat: align manpage with procfs wording
- watch: manpage presumes NTP on system
- Resolves: rhbz#1827731
- Resolves: rhbz#1829920
- Resolves: rhbz#1583669
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.3.17-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Apr 14 2020 Jan Rybar <jrybar@redhat.com> - 3.3.15-2
- pidof: show kernel workers
- gating activated
- Resolves: rhbz#1803640
* Thu Feb 18 2021 Jan Rybar <jrybar@redhat.com> - 3.3.17-1
- rebase to procps-ng-3.3.17
- new distribution of i18n manpages
- new pidwait command
* Wed Jul 04 2018 Jan Rybar <jrybar@redhat.com> - 3.3.15-1
- Rebase to 3.3.15
- Translated manual pages moved to -i18n subpackage
* Tue Feb 02 2021 Jan Rybar <jrybar@redhat.com> - 3.3.16-4
- version bump to apply latest specfile changes into build
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.16-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Dec 22 2020 Jan Rybar <jrybar@redhat.com> - 3.3.16-2
- ps: new exe format option to show real path to exe
- pidof: new -w option to show kernel worker threads
- pkill: manpage to document -e option
- Resolves: bz#1629413
- Resolves: bz#1399206
* Tue Aug 18 2020 Jan Rybar <jrybar@redhat.com> - 3.3.16-1
- Rebase to newest upstream version
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.15-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jul 24 2020 Jan Rybar <jrybar@redhat.com> - 3.3.15-8
- pidof: show PIDs for kernel worker threads
* Tue Jul 14 2020 Tom Stellard <tstellar@redhat.com> - 3.3.15-8
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.15-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.15-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.15-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.15-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Mon Jul 02 2018 Jan Rybar <jrybar@redhat.com> - 3.3.15-3
- Translated manual pages moved to i18n subpackage
- Spec file cleanup
* Thu Jun 14 2018 Jan Rybar <jrybar@redhat.com> - 3.3.15-2
- General rebuild after commit revert
* Wed Jun 06 2018 Jan Rybar <jrybar@redhat.com> - 3.3.15-1
- Rebase to 3.3.15 (contains a LOT of CVE fixes)
- Manpage translations temporarily unavailable
* Fri May 18 2018 Kamil Dudka <kdudka@redhat.com> - 3.3.14-2
- fix integer overflows leading to heap overflow (CVE-2018-1124 CVE-2018-1126)
* Mon Apr 16 2018 Jan Rybar <jrybar@redhat.com> - 3.3.14-1
- Rebase to 3.3.14
- Translated man-pages returned
* Thu Apr 05 2018 Jan Rybar <jrybar@redhat.com> - 3.3.13-2
- Build fails due to removal of libio.h from glibc-headers
- Translated manpages deactivated since missing from 3.3.13 tarball
* Tue Apr 03 2018 Jan Rybar <jrybar@redhat.com> - 3.3.13-1
- Rebase to 3.3.13
* Mon Feb 26 2018 Jan Rybar <jrybar@redhat.com> - 3.3.12-2
- ps: LUID (LoginID) format option available
* Wed Feb 21 2018 Michael Cronenworth <mike@cchtml.com> - 3.3.12-1
- Upgrading to 3.3.12