Commit Graph

2273 Commits

Author SHA1 Message Date
Jim Warner
d93609225c ps: eliminated inadvertent trailing double semi-colons
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-10 14:35:17 +10:00
Jim Warner
2d94282224 top: eliminate inadvertent trailing double semi-colons
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-10 14:35:17 +10:00
Craig Small
4c23fcfd3c docs: Mention stime in ps.1
References:
 procps-ng/procps#164
2020-04-07 19:35:27 +10:00
Craig Small
0afe595a44 NEWS: Fix location of sysctl update
The previous commit put the sysctl directory order entries in
the wrong place.
2020-02-27 22:03:12 +11:00
Craig Small
24a1574f0a sysctl: config directory order
Matches the systemd directory order (/run is after /etc) and
document what directories are used better.
2020-02-27 21:58:07 +11:00
Jim Warner
5cd29e5093 top: restore configuration file backward compatibility
The Debian bug referenced below has nothing to do with
locales. In fact, top was made locale independent back
in release 3.3.13 (April, 2018). However, that bug did
reveal some misplaced logic which this patch corrects.

Prompted by the Qualys audit, all rcfile field strings
were checked for potential duplicates which could only
have resulted from some user's manual/malicious edits.

Unfortunately, that code was executed before top had a
chance to enforce the proper/maximum string length (in
the event an extremely old rcfile had just been read).
This created some potential string overrun references.

In top's original 3.3.15 implementation, the potential
overrun extended for 15 characters. That is the number
of field characters added with 3.3.9 (December, 2013).
But, since strchr() was used, no error exit was taken.

In the revised 3.3.16 implementation, the strchr() was
replaced with '&w->rc.fieldscur[n]'. This held overrun
to a single position while producing an error message.

So, this commit just moves that logic to a point where
fieldscur is guaranteed to be longer than EU_MAXPFLGS.

Reference(s):
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951335
. revised 3.3.16 validation logic
commit 291d98ee50
. original 3.3.15 validation logic
commit fdb58974e2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-02-18 11:20:58 +11:00
Jim Warner
ed34b1228e top: restore one line of code to sig_endpgm() function
When that potential abend at program end was addressed
in the patch shown below, one line of code was removed
in error. That line served to suppress some end-of-job
reports should ATEOJ_RPTSTD or ATEOJ_RPTHSH be active.

So, this patch restores that previously deleted logic.

Reference(s):
. potential SEGV fix, master branch
commit d37f85c269

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-02-18 11:20:58 +11:00
Craig Small
6164fbb829 NEWS: Add missing pgrep note 2020-02-06 22:09:56 +11:00
Jim Warner
7db65421d0 ps: for abnormal end allow core dumps (fix qualys bug)
A Qualys audit patch, represented in the commit below,
added the _exit() call to our abnormal signal handler.
Unfortunately, that disabled the associated core dump.

This patch restores expected behavior of those signals
whose default produces a core dump file + termination.

Reference(s):
commit 2e4a594221

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-01-06 09:13:29 +11:00
Jim Warner
9e4c2cca39 top: at abnormal end allow core dumps (fix qualys bug)
A Qualys audit patch, represented in the commit below,
added the _exit() call to our abnormal signal handler.
Unfortunately, that disabled the associated core dump.

This patch restores expected behavior of those signals
whose default produces a core dump file + termination.

Reference(s):
commit 0847390b83

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-01-06 09:13:29 +11:00
Jim Warner
ba5f1e5449 top: reposition some data due to a translation comment
In a translator hint, under a caution, a reference was
made to the "next three items". Unfortunately however,
there was one intervening 'item' to which that caution
did not apply. This commit just relocates that 'item'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-01-06 09:13:29 +11:00
Jim Warner
00028aa237 top: whack insidious bug surrounding auto-sized fields
This commit duplicates a change to that newlib branch.
However, it should be noted that such a change was not
really necessary under this master branch since proc_t
data remains valid much longer. It is being duplicated
here as documentation only. Below is the original msg.

------------------------------------------------------
This patch will eliminate a bug which is unique to our
newlib branch. It's extremely rare and only happens if
a search ('L'/'&') is initiated during the period when
fields are currently being auto-sized (AUTOX_MODE on).

This bug surfaces as either all zero results for tasks
displayed or a segmentation fault, depending upon what
fields were activated. It is caused by the timing of a
call to the <pids> 'reset' function. When called after
a task refresh, but before do_key(), this bug appears.

So this patch just ensures that 'reset' will be called
after do_key() & before the tasks have been refreshed.
------------------------------------------------------

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-01-06 09:13:29 +11:00
Craig Small
bb96fc4295 pgrep: check sanity of SC_ARG_MAX
A kernel change means we cannot trust what sysconf(SC_ARG_MAX)
returns. We clamp it so its more than 4096 and less than 128*1024
which is what findutils does.

References:
 procps-ng/procps#152
 https://git.savannah.gnu.org/cgit/findutils.git/tree/lib/buildcmd.c#n535
 https://lwn.net/Articles/727862/
2020-01-05 15:05:55 +11:00
Craig Small
59c88e18f2 v3.3.16 release 2019-12-08 15:06:03 +11:00
Craig Small
d063bfc59e library: Adjust version for release
Previous release incremented the age instead of incrementing the
revision. The age can only increment if revision (internal changes
only) or current (API changes) also increments.

A C:R:A of 8.0.2 means its the latest revision of 8.0 library and
any binary linked against 8.0 will work. This is our third revision
of the 8.0 library.

References:
 https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
2019-12-08 14:56:53 +11:00
Craig Small
216477e247 nls: sync translations with make diatcheck 2019-12-08 14:44:07 +11:00
Craig Small
0e9e30e6ae build-sys: update man translation makefile
This is based upon the Makefile.am for psmisc
2019-11-28 21:53:43 +11:00
Craig Small
bfada70a8a docs: more Makefile updates
The install target was using the wrong directory and would throw
some errors where a language couldn't translate man pages. This
one should be hopefully more robust.
2019-11-12 21:15:33 +11:00
Craig Small
7bea203ab0 docs: Update translations
Downloaded the updated translations of the binaries and the manpages
from translation project. Then fixed the typos that caused po4a to
fail, mainly errant spaces.
2019-11-11 21:52:21 +11:00
Craig Small
2590e3be42 build-sys: Use po4a for manpage translations
Using the newer po4a tool for manpage translations. Also removing
the manpage po file update from dist target because it should be
something the is explicitly done.

The git repository will hold the original man pages and the
po translation files. The distribution tarball will hold those
and the translated manpages. This means most people won't need po4a
as the distribution fill will have these translated manpages.
2019-11-11 21:41:00 +11:00
Craig Small
e79095ddcc build-sys: Install translated manpages
References:
 procps-ng/procps#146
2019-10-31 20:48:15 +11:00
Craig Small
d9a485e39e docs: skill.1 - Remove trailing ^Z
skill.1 man page had trailing ^Z which cause the translation
engine all sorts of problems.
2019-10-31 14:24:17 +11:00
Craig Small
bf26c683d8 nls: minor reference updates 2019-10-29 07:59:15 +11:00
Craig Small
d5e3650fc3 nls: Add all man pages to pot file
The previous Makefile rule would only put the first required file
into the pot file because it used $< Unfortunately, due to how
po4a tools work, its not just a simple matter of changing it to $^
and you're done, but needs a foreach loop to add -m to each manpage
file.

This is a temporary fix, after some more work looking into po4a the
unified tool (called po4a) will be used.
2019-10-29 07:48:50 +11:00
Jim Warner
fead750c67 top: update copyright notations & fix a man page error
Beyond the copyrights, the single oops in the man page
was introduced in the commit which is referenced below
dealing with some cleanup following that Qualys audit.

Reference(s):
. man page error introduced
commit e531c78140

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-10-27 22:17:27 +11:00
Craig Small
a2b7106793 snice: Fix matching on PID
@MarsChan correctly pointed out that the read() always returns 128
bytes, so skipping on >= 128 will always mean we skip. Their suggestion
was to remove the equality, but read will never go past 128 bytes so
I just removed that part of the check.

References:
 procps-ng/procps!89
2019-10-22 08:14:35 +11:00
Craig Small
52364d548a Merge branch 'ylecuyer/procps-patch-1'
References:
  procps-ng/procps!86
2019-09-21 17:08:53 +10:00
Yoann Lecuyer
41805d8d89 top: fix out-of-band read when using -p with exactly 20 pids 2019-09-21 17:07:41 +10:00
Craig Small
8145700899 Merge branch 'cbaenziger/procps-pgrep_more_than_4k'
References:
 procps-ng/procps!85
2019-09-21 16:43:50 +10:00
Clay Baenziger
f5fbbdbef8 testsuite: pgrep: Provide test for matching a more than 4k command line; beware as TCL does not seem to match on strings >4k 2019-09-21 16:39:13 +10:00
Clay Baenziger
f9e56d3c66 pgrep: Use POSIX _SC_ARG_MAX for maximum full command line length 2019-09-21 16:39:13 +10:00
Craig Small
c660dbae1b pidof: Fix separator option
Short separator option used 's' instead of 'S' which
meant it pidof would use the single-shot option when you
meant separator.

Added alias for -S using -d to give some sysvinit pidof
compatibility.

References:
    commit 73492b182d
    procps-ng/procps#141
2019-09-21 16:17:05 +10:00
Craig Small
bdce977a4e watch: fix unsetting of COLOR flag
watch used to check if COLOR was required, check if color was
possible then.. set the flag again.

It should have been cleared after failing to get colors out of
ncurses.

References:
 procps-ng/procps#143
2019-09-21 16:03:28 +10:00
Craig Small
7af88da373 sysctl: ignore errors from lines starting with -
The systemd sysctl ignores errors from preload files that start
with a hyphen.  This change brings the procps sysctl into line with
their change.

References:
    procps-ng/procps#138
    https://github.com/systemd/systemd/pull/13191
    https://github.com/systemd/systemd/pull/13141
2019-09-21 15:50:53 +10:00
Jim Warner
4c4d8b2464 NEWS: add a new item (top), fix one other item (pgrep)
Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-08-25 10:35:50 +10:00
Jim Warner
d37f85c269 top: avoid a potential SEGV during program termination
The backtrace shown in the bug report referenced below
illustrates a 'normal' program termination interrupted
with some signal, ultimately then causing a top crash.

So this commit just rearranges a little code such that
all signals will be blocked during that rather lengthy
end of program processing regardless of how initiated.

[ in that report, ignore the assertion regarding the ]
[ '-n' option. it obviously was not '1' since do_key ]
[ had been called, which otherwise wouldn't be true. ]

[ and when it is '1' the -d option would be ignored. ]

Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=1737552

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-08-25 10:35:50 +10:00
Jim Warner
dd95e865de top: tweak logic associated with keyboard translations
This commit most significant change is the elimination
of the kbd_ENTER entry from that tinfo_tab in iokey().

That entry was a useless artifact left from the commit
which is shown below. It makes no sense to 'translate'
a keystroke into something it already was (i.e. '\n').

The remaining changes just reorder those table entries
for a progression consistent with vim keys: h,j,k & l.

Reference(s):
. fix 'iokey()' flaw preventing proper translations
commit 42f0a341ba

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-08-25 10:35:49 +10:00
Jim Warner
ac83617d4f top: standardize PgUp/PgDn management within task area
This commit standardizes the behavior of the PgUp/PgDn
keys when on the main top display. With PgDn, the last
process will become the first process. With PgUp, that
first task will now appear as the last task displayed.

[ this also eliminates some quirks that were evident ]
[ when paging at or near the end of the process list ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-07-04 20:42:27 +10:00
Jim Warner
e7aa90a866 top: attempt to provide missing xterm vim keys support
A recent issue (and merge request) reminded me of gaps
in top's alternate 'vim' navigation keys support. Some
xterm emulators do not pass the customary strings when
keys were used with the <Ctrl> and/or <Alt> modifiers.

While it was a known problem, this issue/merge request
prompted research into the root cause. As it turns out
the problem is traceable to an X resource known by the
name 'eightBitInput'. When 'true' (the default), a key
pressed in combination with <Alt> will not be preceded
by the <Esc> character. Rather, a single character was
presented (modified via an 'eightBitMeta' X resource).

The following approaches would eliminate this problem:

. start xterm thus: xterm -xrm '*eightBitInput: false'

. use: ~/.Xresources with 'Xterm*eightBitInput: false'

. build xterm with 'configure --enable-meta-sends-esc'
( apparently used for CentOS, Fedora, openSUSE, etc. )

. enable xterm's menu via 'configure --enable-toolbar'
( so the user can set the 'Meta Sends Escape' option )

Of course, none of the above steps is desirable from a
user's perspective. So, this patch will add additional
entries to the iokey function's tinfo_tab to represent
strings passed when the <Alt> key does not send <Esc>.

[ hopefully they'll be the same across all platforms ]

Lastly, this patch will also eliminate those redundant
<Atl> + '\', '/', '<' & '>' provisions, which now seem
like overkill and suffer from that same 'eightBitMeta'
xterm problem. And we might as well say goodbye to the
4 '<Alt> + arrow key' table entries (which do not seem
to currently work with any emulator which I can find).

[ what in the world was I thinking way back in 2011? ]

Reference(s):
. issue
https://gitlab.com/procps-ng/procps/issues/135
. merge request
https://gitlab.com/procps-ng/procps/merge_requests/84

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-07-04 20:42:27 +10:00
Jim Warner
2e7f38707a library: tweak that lxc container support a final time
Since the patch referenced below traded a compile-time
'sizeof' directive for a run-time 'strlen' call, there
is no need to declare lxc patterns as explicit arrays.

We'll also use the actual lxc patterns by omitting the
beginning slashes ('/') for both of those definitions.

And, looking to the future when most/all lxc users are
using the most recent lxc release, we will make things
slightly more efficient by reversing those two pattern
literals so the most recent pattern was checked first.

Of course, such a change only benefits tasks which are
running in a container. For the majority of processes,
both literals will be compared in that 'if' statement,
assuming the 'LXC' field is currently being displayed.

[ plus, a leftover parenthesis pair has been removed ]

Reference(s):
commit f67127e728

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-03-26 19:13:42 +11:00
Jim Warner
07ae79a1ed top: just correct a couple of misspellings in comments
Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-03-26 19:13:42 +11:00
Craig Small
2fa3bb0669 misc: update for pgrep runstate
Added some minor fixes and notes
2019-03-05 07:59:48 +11:00
Craig Small
2b40d5d839 Merge branch 'edneville/procps-issue_109_match_state'
References:
 https://bugs.debian.org/919381
 procps-ng/procps!81
2019-03-05 07:55:01 +11:00
ed
e13eb8b75e pgrep.c: Match based on process run state for issue 109 2019-03-05 07:53:59 +11:00
Craig Small
6e8d124a3b Merge branch 'pks-t/procps-pks/sysctl-handle-close-errors'
References:
 procps-ng/procps!65
2019-03-04 21:46:18 +11:00
Patrick Steinhardt
da82fe49b1 sysctl: do not report set key in case close_stream fails
As we're using buffered I/O when writing kernel parameters, write errors
may get delayed until we close the `FILE` stream. As we are currently
outputting the key that is to be set disregarding the return value of
`close_stream`, we may end up in a situation where we report error and
success:

    $ sysctl kernel.printk_ratelimit=100000000000000
    sysctl: setting key "kernel.printk_ratelimit": error code 22
    kernel.printk_ratelimit = 100000000000000

Fix the issue by only outputting the updated value in case
`close_stream` does not report an error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-03-04 21:44:52 +11:00
Patrick Steinhardt
3eb4b5375f procio: fix potential out-of-bounds access when write fails
When writing to procfs via `proc_write` fails, we try to chunk the
buffer into smaller pieces to work around that issue. When searching for
the next location to split the buffer, though, we can underflow the
buffer in case the current offset is smaller than `LINELEN`. Fix the
issue by passing `cookie->offset` instead of `LINELEN` into `memrchr` in
case `cookie->offset` is smaller than `LINELEN`.

This bug can be triggered on musl-based systems, e.g. by executing

    $ sysctl kernel.printk_ratelimit=1000000000000000

As the value is out-of-range, `write` will return an error and set
`errno` to `EINVAL`. As we're only trying to write a smallish buffer
with a length smaller than `LINELEN` and as the buffer does not contain
any newlines, the call

    token = (char*)memrchr(cookie->buf+offset, '\n', LINELEN);

will underflow the buffer and crash the program.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-03-04 21:44:52 +11:00
Patrick Steinhardt
32720b2ee6 procio: use the user-supplied delimiter to split large input
The `fprocopen` function allows users to specify a delimiter chacter
that is used to split very large input lines into smaller chunks. While
the code checks that the caller did actually supply the delimiter, it is
in fact never used to split the string. Instead, the hardcoded default
character ',' is always used to split the string.

Fix the issue by using `cookie->delim` instead.
2019-03-04 21:44:52 +11:00
Patrick Steinhardt
9b9aa9a6e9 docs: fix "delimeter" typo in fprocopen man page 2019-03-04 21:44:52 +11:00
Jim Warner
893793a8c4 top: improve logic surrounding 'smp_num_cpus' variable
I thank Guido Jäkel for raising the issue cited in the
merge request referenced below. While restoring 1 line
of code would produce the desired results, it does not
address the root cause of that problem he experienced.

The variable 'smp_num_cpus' was set by libprocps via a
sysconf(_SC_NPROCESSORS_ONLN) call. It was supposed to
represent total number of processors currently online.
It also served as the position in the Cpu_tics[] array
where the /proc/stat line #1 (cpu summary) was stored.

The variable 'Cpu_faux_tot' was valued by top based on
total individual cpus parsed from the /proc/stat file.
It serves as a fence post for Cpu_tics[] array access.

The problem Guido experienced results from a disparity
between those 2 variables, plus one instance where the
wrong variable was used in the summary_show() routine.

. Here is the real culprit, the actual incorrect code:
. summary_hlp(&Cpu_tics[Cpu_faux_tot], N_txt(WORD_a...

Which always should have been represented in this way:
. summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_a...

------------------------------------------------------
The above 'disparity' might arise in any system when a
cpu is taken offline since there's a 3 second delay in
cpu and memory refreshes in an effort to reduce costs.
Usually this particular condition will be short lived.

However, there is a more persistent problem under lxc.

If a host cpu is taken offline and then brought online
again, within the container sysconf returns the proper
number of online processors. But, /proc/stat does not!
Sadly, I've yet to find a way to coax a container into
refreshing its /proc/stat, short of reboting the host.

[ might that represent a potential bug in lxc logic? ]

Reference(s):
https://gitlab.com/procps-ng/procps/merge_requests/82

Signed-off-by: Jim Warner <james.warner@comcast.net>
With-thanks-to: Guido Jäkel <G.Jaekel@DNB.DE>
2019-01-22 22:46:53 +11:00