Dr. Werner Fink 2012-03-13 15:28:38 +00:00 committed by Git OBS Bridge
parent 881a7e1f57
commit d574467049
4 changed files with 115 additions and 110 deletions

View File

@ -1,113 +1,87 @@
--- src/Makefile.am diff --git a/ChangeLog b/ChangeLog
+++ src/Makefile.am 2012-02-27 00:00:00.000000000 +0000 index b42a4d7..baba19e 100644
@@ -23,7 +23,7 @@ if WANT_PEEKFD_MIPS --- a/ChangeLog
AM_CFLAGS += -DMIPS +++ 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 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 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 +if WANT_TIMEOUT_STAT
+ fuser_SOURCES += timeout.c timeout.h
+endif
fuser_LDADD = @LIBINTL@ fuser_LDADD = @LIBINTL@
--- src/Makefile.in diff --git a/src/fuser.c b/src/fuser.c
+++ src/Makefile.in 2012-02-27 17:19:33.626434528 +0000 index e4081eb..09548ff 100644
@@ -68,7 +68,7 @@ CONFIG_CLEAN_VPATH_FILES = --- a/src/fuser.c
@WANT_PEEKFD_MIPS_TRUE@am__EXEEXT_5 = peekfd$(EXEEXT) +++ b/src/fuser.c
am__installdirs = "$(DESTDIR)$(bindir)" @@ -111,9 +111,13 @@ static dev_t device(const char *path);
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);
#endif #endif
static char *expandpath(const char *path); static char *expandpath(const char *path);
-typedef int (*stat_t)(const char*, struct stat*); -typedef int (*stat_t)(const char*, struct stat*);
#ifdef WITH_TIMEOUT_STAT #ifdef WITH_TIMEOUT_STAT
-static int timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds); +# if (WITH_TIMEOUT_STAT == 2)
+#include "timeout.h" +# 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 #else
#define timeout(func,path,buf,dummy) (func)((path),(buf)) #define timeout(func,path,buf,dummy) (func)((path),(buf))
#endif /* WITH_TIMEOUT_STAT */ #endif /* WITH_TIMEOUT_STAT */
@@ -1779,72 +1778,6 @@ scan_swaps(struct names *names_head, str @@ -1783,7 +1787,7 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head,
fclose(fp); * Execute stat(2) system call with timeout to avoid deadlock
} * on network based file systems.
*/
-/*
- * Execute stat(2) system call with timeout to avoid deadlock
- * on network based file systems.
- */
-#ifdef HAVE_TIMEOUT_STAT -#ifdef HAVE_TIMEOUT_STAT
- +#if defined(WITH_TIMEOUT_STAT) && (WITH_TIMEOUT_STAT == 1)
-static sigjmp_buf jenv;
- static sigjmp_buf jenv;
-static void
-sigalarm(int sig) diff --git a/src/timeout.c b/src/timeout.c
-{ new file mode 100644
- if (sig == SIGALRM) index 0000000..1fe0354
- siglongjmp(jenv, 1); --- /dev/null
-} +++ b/src/timeout.c
-
-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
@@ -0,0 +1,267 @@ @@ -0,0 +1,267 @@
+/* +/*
+ * timout.c Advanced timeout handling for file system calls + * timout.c Advanced timeout handling for file system calls
@ -376,8 +350,11 @@
+/* +/*
+ * End of timeout.c + * End of timeout.c
+ */ + */
--- src/timeout.h diff --git a/src/timeout.h b/src/timeout.h
+++ src/timeout.h 2012-02-27 00:00:00.000000000 +0000 new file mode 100644
index 0000000..546c13b
--- /dev/null
+++ b/src/timeout.h
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
+/* +/*
+ * timout.h Advanced timeout handling for file system calls + * timout.h Advanced timeout handling for file system calls

View File

@ -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 Mon Feb 27 17:43:46 UTC 2012 - werner@suse.de

View File

@ -16,7 +16,6 @@
# #
Name: psmisc Name: psmisc
BuildRequires: automake BuildRequires: automake
BuildRequires: gcc-c++ BuildRequires: gcc-c++
@ -24,19 +23,19 @@ BuildRequires: glibc-devel
BuildRequires: libselinux-devel BuildRequires: libselinux-devel
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
Url: http://sourceforge.net/projects/psmisc/ Url: http://sourceforge.net/projects/psmisc/
License: GPL-2.0+
Group: System/Monitoring
PreReq: %fillup_prereq %insserv_prereq PreReq: %fillup_prereq %insserv_prereq
Version: 22.16 Version: 22.16
Release: 1 Release: 0
Provides: ps:/usr/bin/killall Provides: ps:/usr/bin/killall
Summary: Utilities for managing processes on your system 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 Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz
Patch0: %name-22.16.dif Patch0: %name-22.16.dif
Patch1: %name-22.12-tigetstr.patch Patch1: %name-22.12-tigetstr.patch
Patch2: %name-22.12-pstree.patch Patch2: %name-22.12-pstree.patch
Patch3: pstree-segfault.patch Patch42: pstree-segfault.patch
Patch42: %name-22.16-timeout.patch Patch43: %name-22.16-timeout.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
%define nopeek s390 s390x ia64 %sparc hppa %define nopeek s390 s390x ia64 %sparc hppa
@ -51,10 +50,10 @@ processes that are using specified files or filesystems.
%prep %prep
%setup -q %setup -q
%patch42 -p0 -b .to %patch42 -p1 -b .to
%patch43 -p1 -b .comm
%patch1 -p0 -b .tigetstr %patch1 -p0 -b .tigetstr
%patch2 -p0 -b .pstree %patch2 -p0 -b .pstree
%patch3 -p0 -b .comm
%patch0 -p0 -b .0 %patch0 -p0 -b .0
%build %build

View File

@ -1,11 +1,32 @@
--- src/pstree.c diff --git a/ChangeLog b/ChangeLog
+++ src/pstree.c 2012-02-27 17:15:05.418433600 +0000 index 45f6c04..b42a4d7 100644
@@ -376,7 +376,7 @@ add_proc(const char *comm, pid_t pid, pi --- 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 */ #endif /*WITH_SELINUX */
else { else {
strncpy(this->comm, comm, COMM_LEN+2); strncpy(this->comm, comm, COMM_LEN+2);
- this->comm[COMM_LEN+1]; - this->comm[COMM_LEN+1];
+ this->comm[COMM_LEN+1]='\0'; + this->comm[COMM_LEN+1] = '\0';
this->uid = uid; this->uid = uid;
} }
if (args) if (args)