From d57446704946bea79138519c9d11cf8151c99370 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Tue, 13 Mar 2012 15:28:38 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=60 --- psmisc-22.16-timeout.patch | 173 ++++++++++++++++--------------------- psmisc.changes | 8 ++ psmisc.spec | 15 ++-- pstree-segfault.patch | 29 ++++++- 4 files changed, 115 insertions(+), 110 deletions(-) diff --git a/psmisc-22.16-timeout.patch b/psmisc-22.16-timeout.patch index 9ae16bc..d219df0 100644 --- a/psmisc-22.16-timeout.patch +++ b/psmisc-22.16-timeout.patch @@ -1,113 +1,87 @@ ---- src/Makefile.am -+++ src/Makefile.am 2012-02-27 00:00:00.000000000 +0000 -@@ -23,7 +23,7 @@ if WANT_PEEKFD_MIPS - AM_CFLAGS += -DMIPS +diff --git a/ChangeLog b/ChangeLog +index b42a4d7..baba19e 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,10 @@ ++ * Make it possible to use --enable-timeout-stat as well as ++ --enable-timeout-stat=static for a static background process which ++ does the final stat system calls ++ * Do not mix HAVE_TIMEOUT_STAT with WITH_TIMEOUT_STAT ++ * Add timeout.c/timeout.h for static background process which is able ++ to read the file name from pipe, does the stat(2) system call, and ++ writes the result back to a pipe. + * Really add ASCII null at command string in add_proc() of pstree.c + + Changes in 22.16 +diff --git a/configure.ac b/configure.ac +index 0615f5f..9265d82 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -30,12 +30,16 @@ AC_SUBST([SELINUX_LIB]) + # Call fork before all stat calls to stop hanging on NFS mounts + AC_SUBST([WITH_TIMEOUT_STAT]) + AC_ARG_ENABLE([timeout_stat], +- [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls])], ++ [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls (optional with argument "static" for a static background process)])], + [enable_timeout_stat=$enableval], + [enable_timeout_stat="no"]) + if test "$enable_timeout_stat" = "yes"; then + AC_DEFINE([WITH_TIMEOUT_STAT], [1], [Use timeout on stat calls]) + fi ++if test "$enable_timeout_stat" = "static"; then ++ AC_DEFINE([WITH_TIMEOUT_STAT], [2], [Use timeout on stat calls]) ++fi ++AM_CONDITIONAL([WANT_TIMEOUT_STAT], [test "$enable_timeout_stat" = "static"]) + + # Enable hardened compile and link flags + AC_ARG_ENABLE([harden_flags], +diff --git a/src/Makefile.am b/src/Makefile.am +index d511f24..a28af7d 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -24,6 +24,9 @@ if WANT_PEEKFD_MIPS endif --fuser_SOURCES = fuser.c comm.h signals.c signals.h i18n.h fuser.h lists.h -+fuser_SOURCES = fuser.c comm.h signals.c signals.h timeout.c i18n.h fuser.h lists.h timeout.h + fuser_SOURCES = fuser.c comm.h signals.c signals.h i18n.h fuser.h lists.h ++if WANT_TIMEOUT_STAT ++ fuser_SOURCES += timeout.c timeout.h ++endif fuser_LDADD = @LIBINTL@ ---- src/Makefile.in -+++ src/Makefile.in 2012-02-27 17:19:33.626434528 +0000 -@@ -68,7 +68,7 @@ CONFIG_CLEAN_VPATH_FILES = - @WANT_PEEKFD_MIPS_TRUE@am__EXEEXT_5 = peekfd$(EXEEXT) - am__installdirs = "$(DESTDIR)$(bindir)" - PROGRAMS = $(bin_PROGRAMS) --am_fuser_OBJECTS = fuser.$(OBJEXT) signals.$(OBJEXT) -+am_fuser_OBJECTS = fuser.$(OBJEXT) signals.$(OBJEXT) timeout.$(OBJEXT) - fuser_OBJECTS = $(am_fuser_OBJECTS) - fuser_DEPENDENCIES = - am_killall_OBJECTS = killall.$(OBJEXT) signals.$(OBJEXT) ---- src/fuser.c -+++ src/fuser.c 2012-02-27 17:09:23.901933700 +0000 -@@ -111,9 +111,8 @@ static dev_t device(const char *path); +diff --git a/src/fuser.c b/src/fuser.c +index e4081eb..09548ff 100644 +--- a/src/fuser.c ++++ b/src/fuser.c +@@ -111,9 +111,13 @@ static dev_t device(const char *path); #endif static char *expandpath(const char *path); -typedef int (*stat_t)(const char*, struct stat*); #ifdef WITH_TIMEOUT_STAT --static int timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds); -+#include "timeout.h" ++# if (WITH_TIMEOUT_STAT == 2) ++# include "timeout.h" ++# else ++typedef int (*stat_t)(const char*, struct stat*); + static int timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds); ++# endif #else #define timeout(func,path,buf,dummy) (func)((path),(buf)) #endif /* WITH_TIMEOUT_STAT */ -@@ -1779,72 +1778,6 @@ scan_swaps(struct names *names_head, str - fclose(fp); - } - --/* -- * Execute stat(2) system call with timeout to avoid deadlock -- * on network based file systems. -- */ +@@ -1783,7 +1787,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, + * Execute stat(2) system call with timeout to avoid deadlock + * on network based file systems. + */ -#ifdef HAVE_TIMEOUT_STAT -- --static sigjmp_buf jenv; -- --static void --sigalarm(int sig) --{ -- if (sig == SIGALRM) -- siglongjmp(jenv, 1); --} -- --static int --timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds) --{ -- pid_t pid = 0; -- int ret = 0, pipes[4]; -- ssize_t len; -- -- if (pipe(&pipes[0]) < 0) -- goto err; -- switch ((pid = fork ())) { -- case -1: -- close(pipes[0]); -- close(pipes[1]); -- goto err; -- case 0: -- (void) signal(SIGALRM, SIG_DFL); -- close(pipes[0]); -- if ((ret = func(path, buf)) == 0) -- do len = write(pipes[1], buf, sizeof(struct stat)); -- while (len < 0 && errno == EINTR); -- close(pipes[1]); -- exit(ret); -- default: -- close(pipes[1]); -- if (sigsetjmp(jenv, 1)) { -- (void) alarm(0); -- (void) signal(SIGALRM, SIG_DFL); -- if (waitpid(0, (int*)0, WNOHANG) == 0) -- kill(pid, SIGKILL); -- errno = ETIMEDOUT; -- seconds = 1; -- goto err; -- } -- (void) signal(SIGALRM, sigalarm); -- (void) alarm(seconds); -- if (read(pipes[0], buf, sizeof(struct stat)) == 0) { -- errno = EFAULT; -- ret = -1; -- } -- (void) alarm(0); -- (void) signal(SIGALRM, SIG_DFL); -- close(pipes[0]); -- waitpid(pid, NULL, 0); -- break; -- } -- return ret; --err: -- return -1; --} --#endif /* HAVE_TIMEOUT_STAT */ -- - #ifdef _LISTS_H - /* - * Use /proc/self/mountinfo of modern linux system to determine ---- src/timeout.c -+++ src/timeout.c 2012-02-27 00:00:00.000000000 +0000 ++#if defined(WITH_TIMEOUT_STAT) && (WITH_TIMEOUT_STAT == 1) + + static sigjmp_buf jenv; + +diff --git a/src/timeout.c b/src/timeout.c +new file mode 100644 +index 0000000..1fe0354 +--- /dev/null ++++ b/src/timeout.c @@ -0,0 +1,267 @@ +/* + * timout.c Advanced timeout handling for file system calls @@ -376,8 +350,11 @@ +/* + * End of timeout.c + */ ---- src/timeout.h -+++ src/timeout.h 2012-02-27 00:00:00.000000000 +0000 +diff --git a/src/timeout.h b/src/timeout.h +new file mode 100644 +index 0000000..546c13b +--- /dev/null ++++ b/src/timeout.h @@ -0,0 +1,36 @@ +/* + * timout.h Advanced timeout handling for file system calls diff --git a/psmisc.changes b/psmisc.changes index 544d621..0c33651 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Mar 13 15:26:37 UTC 2012 - werner@suse.de + +- Submit ASCII null fix in pstree upsrtream +- Submit support for static background process for stat system call + upstream +- Rebuild package with upstream patches + ------------------------------------------------------------------- Mon Feb 27 17:43:46 UTC 2012 - werner@suse.de diff --git a/psmisc.spec b/psmisc.spec index 1b2e93f..c7b040e 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -16,7 +16,6 @@ # - Name: psmisc BuildRequires: automake BuildRequires: gcc-c++ @@ -24,19 +23,19 @@ BuildRequires: glibc-devel BuildRequires: libselinux-devel BuildRequires: ncurses-devel Url: http://sourceforge.net/projects/psmisc/ -License: GPL-2.0+ -Group: System/Monitoring PreReq: %fillup_prereq %insserv_prereq Version: 22.16 -Release: 1 +Release: 0 Provides: ps:/usr/bin/killall Summary: Utilities for managing processes on your system +License: GPL-2.0+ +Group: System/Monitoring Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz Patch0: %name-22.16.dif Patch1: %name-22.12-tigetstr.patch Patch2: %name-22.12-pstree.patch -Patch3: pstree-segfault.patch -Patch42: %name-22.16-timeout.patch +Patch42: pstree-segfault.patch +Patch43: %name-22.16-timeout.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %define nopeek s390 s390x ia64 %sparc hppa @@ -51,10 +50,10 @@ processes that are using specified files or filesystems. %prep %setup -q -%patch42 -p0 -b .to +%patch42 -p1 -b .to +%patch43 -p1 -b .comm %patch1 -p0 -b .tigetstr %patch2 -p0 -b .pstree -%patch3 -p0 -b .comm %patch0 -p0 -b .0 %build diff --git a/pstree-segfault.patch b/pstree-segfault.patch index 4f3fff9..f80fd95 100644 --- a/pstree-segfault.patch +++ b/pstree-segfault.patch @@ -1,11 +1,32 @@ ---- src/pstree.c -+++ src/pstree.c 2012-02-27 17:15:05.418433600 +0000 -@@ -376,7 +376,7 @@ add_proc(const char *comm, pid_t pid, pi +diff --git a/ChangeLog b/ChangeLog +index 45f6c04..b42a4d7 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,5 @@ ++ * Really add ASCII null at command string in add_proc() of pstree.c ++ + Changes in 22.16 + ================ + * Use strncpy for COMM_LEN and make it 18 characters to cover brackets +diff --git a/src/pstree.c b/src/pstree.c +index 80cfcec..a6c8f6e 100644 +--- a/src/pstree.c ++++ b/src/pstree.c +@@ -265,7 +265,7 @@ static PROC *new_proc(const char *comm, pid_t pid, uid_t uid) + exit(1); + } + strncpy(new->comm, comm, COMM_LEN+2); +- new->comm[COMM_LEN+1]='\0'; /* make sure nul terminated*/ ++ new->comm[COMM_LEN+1] = '\0'; /* make sure nul terminated*/ + new->pid = pid; + new->uid = uid; + new->flags = 0; +@@ -354,7 +354,7 @@ add_proc(const char *comm, pid_t pid, pid_t ppid, uid_t uid, #endif /*WITH_SELINUX */ else { strncpy(this->comm, comm, COMM_LEN+2); - this->comm[COMM_LEN+1]; -+ this->comm[COMM_LEN+1]='\0'; ++ this->comm[COMM_LEN+1] = '\0'; this->uid = uid; } if (args)