killall: issue about checking truncated process names
This commit is contained in:
parent
8d2f3b1f32
commit
08e2f7f913
85
backport-patch-fix-checking-truncated-process-names.patch
Normal file
85
backport-patch-fix-checking-truncated-process-names.patch
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
From fb2a412e086be7169e42b7169292c35f9e3063ce Mon Sep 17 00:00:00 2001
|
||||||
|
From: cielavenir <cielartisan@gmail.com>
|
||||||
|
Date: Fri, 9 Jul 2021 14:27:30 +0900
|
||||||
|
Subject: [PATCH 1/2] killall: call load_proc_cmdline if the length is
|
||||||
|
OLD_COMM_LEN-1 as well
|
||||||
|
|
||||||
|
---
|
||||||
|
src/killall.c | 9 +++++----
|
||||||
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/killall.c b/src/killall.c
|
||||||
|
index 9fab8f5..645aaa1 100644
|
||||||
|
--- a/src/killall.c
|
||||||
|
+++ b/src/killall.c
|
||||||
|
@@ -426,7 +426,7 @@ load_process_name_and_age(char *comm, double *process_age_sec,
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
-load_proc_cmdline(const pid_t pid, const char *comm, char **command, int *got_long)
|
||||||
|
+load_proc_cmdline(const pid_t pid, const char *comm, const int check_comm_length, char **command, int *got_long)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
char *path, *p, *command_buf;
|
||||||
|
@@ -482,7 +482,7 @@ load_proc_cmdline(const pid_t pid, const char *comm, char **command, int *got_lo
|
||||||
|
}
|
||||||
|
p = strrchr(command_buf,'/');
|
||||||
|
p = p ? p+1 : command_buf;
|
||||||
|
- if (strncmp(p, comm, COMM_LEN-1) == 0) {
|
||||||
|
+ if (strncmp(p, comm, check_comm_length) == 0) {
|
||||||
|
okay = 1;
|
||||||
|
if (!(*command = strdup(p))) {
|
||||||
|
free(command_buf);
|
||||||
|
@@ -664,8 +664,9 @@ kill_all(int signal, int name_count, char **namelist, struct passwd *pwent,
|
||||||
|
free(command);
|
||||||
|
command = NULL;
|
||||||
|
}
|
||||||
|
- if (length == COMM_LEN - 1)
|
||||||
|
- if (load_proc_cmdline(pid_table[i], comm, &command, &got_long) < 0)
|
||||||
|
+
|
||||||
|
+ if (length == COMM_LEN - 1 || length == OLD_COMM_LEN - 1)
|
||||||
|
+ if (load_proc_cmdline(pid_table[i], comm, length, &command, &got_long) < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* match by process name */
|
||||||
|
--
|
||||||
|
GitLab
|
||||||
|
|
||||||
|
|
||||||
|
From 43af55f4c4e5972a1354c6cafeca85ecd38dc122 Mon Sep 17 00:00:00 2001
|
||||||
|
From: cielavenir <cielartisan@gmail.com>
|
||||||
|
Date: Fri, 9 Jul 2021 14:30:37 +0900
|
||||||
|
Subject: [PATCH 2/2] killall: match_process_name comparision with got_long
|
||||||
|
should be full-length
|
||||||
|
|
||||||
|
---
|
||||||
|
src/killall.c | 6 ++----
|
||||||
|
1 file changed, 2 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/killall.c b/src/killall.c
|
||||||
|
index 645aaa1..7bfb9a9 100644
|
||||||
|
--- a/src/killall.c
|
||||||
|
+++ b/src/killall.c
|
||||||
|
@@ -564,8 +564,7 @@ static int match_process_name(
|
||||||
|
{
|
||||||
|
if (got_long)
|
||||||
|
{
|
||||||
|
- return (0 == strncmp2 (match_name, proc_cmdline, OLD_COMM_LEN - 1,
|
||||||
|
- ignore_case));
|
||||||
|
+ return (0 == strcmp2 (match_name, proc_cmdline, ignore_case));
|
||||||
|
} else {
|
||||||
|
return (0 == strncmp2 (match_name, proc_comm, OLD_COMM_LEN - 1,
|
||||||
|
ignore_case));
|
||||||
|
@@ -576,8 +575,7 @@ static int match_process_name(
|
||||||
|
{
|
||||||
|
if (got_long)
|
||||||
|
{
|
||||||
|
- return (0 == strncmp2 (match_name, proc_cmdline, COMM_LEN - 1,
|
||||||
|
- ignore_case));
|
||||||
|
+ return (0 == strcmp2 (match_name, proc_cmdline, ignore_case));
|
||||||
|
} else {
|
||||||
|
return (0 == strncmp2 (match_name, proc_comm, COMM_LEN - 1,
|
||||||
|
ignore_case));
|
||||||
|
--
|
||||||
|
GitLab
|
||||||
|
|
||||||
@ -1,10 +1,13 @@
|
|||||||
Name: psmisc
|
Name: psmisc
|
||||||
Version: 23.4
|
Version: 23.4
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: Utilities for managing processes on your system
|
Summary: Utilities for managing processes on your system
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: https://gitlab.com/psmisc/psmisc
|
URL: https://gitlab.com/psmisc/psmisc
|
||||||
Source0: https://sourceforge.net/projects/%{name}/files/%{name}/%{name}-%{version}.tar.xz
|
Source0: https://sourceforge.net/projects/%{name}/files/%{name}/%{name}-%{version}.tar.xz
|
||||||
|
|
||||||
|
Patch6000: backport-patch-fix-checking-truncated-process-names.patch
|
||||||
|
|
||||||
BuildRequires: libselinux-devel gettext ncurses-devel autoconf automake gcc
|
BuildRequires: libselinux-devel gettext ncurses-devel autoconf automake gcc
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -33,6 +36,9 @@ mv $RPM_BUILD_ROOT%{_bindir}/fuser $RPM_BUILD_ROOT%{_sbindir}
|
|||||||
%doc AUTHORS ChangeLog README
|
%doc AUTHORS ChangeLog README
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 11 2022 liutie <liutie4@huawei.com> - 23.4-2
|
||||||
|
- Fix checking truncated process names
|
||||||
|
|
||||||
* Thu Dec 2 2021 zhouwenpei <zhouwenpei1@huawei.com> - 23.4-1
|
* Thu Dec 2 2021 zhouwenpei <zhouwenpei1@huawei.com> - 23.4-1
|
||||||
- upgrade to 23.4
|
- upgrade to 23.4
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user