From 423169e635c222e549e3c8d989d3f1f3576c117d Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Thu, 10 Jun 2021 07:37:09 +0200 Subject: Some fixes for Bullseye htop 3.0.5-x --- debian/patches/0100-update-uid-on-change.patch | 62 ++++++++++++++++++++++++++ debian/patches/0101-drop-o-path-usage.patch | 38 ++++++++++++++++ debian/patches/series | 2 + 3 files changed, 102 insertions(+) create mode 100644 debian/patches/0100-update-uid-on-change.patch create mode 100644 debian/patches/0101-drop-o-path-usage.patch diff --git a/debian/patches/0100-update-uid-on-change.patch b/debian/patches/0100-update-uid-on-change.patch new file mode 100644 index 0000000..04a7d8f --- /dev/null +++ b/debian/patches/0100-update-uid-on-change.patch @@ -0,0 +1,62 @@ +From ca8ae00cbe03924f05903ec432f91c73893472d4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= +Date: Wed, 9 Jun 2021 11:13:39 +0200 +Subject: [PATCH] Linux: update process uid on change + +Always check if the user of a process changed, e.g. by using setuid(2). +--- + Process.c | 1 + + linux/LinuxProcessList.c | 17 ++++++++++------- + 2 files changed, 11 insertions(+), 7 deletions(-) + +--- a/linux/LinuxProcessList.c ++++ b/linux/LinuxProcessList.c +@@ -366,7 +366,7 @@ + } + + +-static bool LinuxProcessList_statProcessDir(Process* process, openat_arg_t procFd) { ++static bool LinuxProcessList_updateUser(ProcessList* processList, Process* process, openat_arg_t procFd) { + struct stat sstat; + #ifdef HAVE_OPENAT + int statok = fstat(procFd, &sstat); +@@ -375,7 +375,12 @@ + #endif + if (statok == -1) + return false; +- process->st_uid = sstat.st_uid; ++ ++ if (process->st_uid != sstat.st_uid) { ++ process->st_uid = sstat.st_uid; ++ process->user = UsersTable_getRef(processList->usersTable, sstat.st_uid); ++ } ++ + return true; + } + +@@ -1383,12 +1388,10 @@ + proc->percent_cpu = CLAMP(percent_cpu, 0.0F, cpus * 100.0F); + proc->percent_mem = proc->m_resident / (double)(pl->totalMem) * 100.0; + +- if (!preExisting) { +- +- if (! LinuxProcessList_statProcessDir(proc, procFd)) +- goto errorReadingProcess; ++ if (! LinuxProcessList_updateUser(pl, proc, procFd)) ++ goto errorReadingProcess; + +- proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid); ++ if (!preExisting) { + + #ifdef HAVE_OPENVZ + if (settings->flags & PROCESS_FLAG_LINUX_OPENVZ) { +--- a/Process.c ++++ b/Process.c +@@ -436,6 +436,7 @@ + this->show = true; + this->updated = false; + this->basenameOffset = -1; ++ this->st_uid = (uid_t)-1; + + if (Process_getuid == (uid_t)-1) { + Process_getuid = getuid(); diff --git a/debian/patches/0101-drop-o-path-usage.patch b/debian/patches/0101-drop-o-path-usage.patch new file mode 100644 index 0000000..969d727 --- /dev/null +++ b/debian/patches/0101-drop-o-path-usage.patch @@ -0,0 +1,38 @@ +From d8e81ab747e96cb687e8d6981ef4a0fb58050884 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= +Date: Wed, 9 Jun 2021 10:55:22 +0200 +Subject: [PATCH] Linux: drop O_PATH usage + +O_PATH is available since Linux 2.6.39, but we are using fstat(2) on the +returned file descriptor in LinuxProcessList_statProcessDir(), which +is only supported since Linux 3.6. + +Fixes #534 +--- + linux/LinuxProcessList.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +--- a/linux/LinuxProcessList.c ++++ b/linux/LinuxProcessList.c +@@ -58,12 +58,6 @@ + #endif + + +-// CentOS 6's kernel doesn't provide a definition of O_PATH +-// based on definition taken from uapi/asm-generic/fcnth.h in Linux kernel tree +-#ifndef O_PATH +-# define O_PATH 010000000 +-#endif +- + static long long btime = -1; + + static long jiffy; +@@ -1313,7 +1307,7 @@ + proc->tgid = parent ? parent->pid : pid; + + #ifdef HAVE_OPENAT +- int procFd = openat(dirFd, entry->d_name, O_PATH | O_DIRECTORY | O_NOFOLLOW); ++ int procFd = openat(dirFd, entry->d_name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (procFd < 0) + goto errorReadingProcess; + #else diff --git a/debian/patches/series b/debian/patches/series index 9ab8f3d..f8e08e4 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -14,3 +14,5 @@ 0014-fix-zfs-coloring.patch 0015-clean-infoscreen-before-new-scan.patch 0016-fix-div-by-zero-zfscompressedarcmeter.patch +0100-update-uid-on-change.patch +0101-drop-o-path-usage.patch -- cgit v1.2.3