[Pkg-sysvinit-commits] r1383 - in sysvinit/trunk/debian: . patches

Petter Reinholdtsen pere at alioth.debian.org
Wed Jul 8 14:55:51 UTC 2009


Author: pere
Date: 2009-07-08 14:55:49 +0000 (Wed, 08 Jul 2009)
New Revision: 1383

Added:
   sysvinit/trunk/debian/patches/47_pidof_chroot.dpatch
Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/patches/00list
Log:
Add -c option to pidof, for only checking processes with the same
file system root.  Patch by Thomas Woerner and Fedora.

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2009-07-08 13:46:56 UTC (rev 1382)
+++ sysvinit/trunk/debian/changelog	2009-07-08 14:55:49 UTC (rev 1383)
@@ -37,6 +37,8 @@
   * New patch 17_doc_halt changing halt(8) to make it clear that sync
     might happen even when -n is used.  Patch from Bill Nottingham and
     Fedora.
+  * Add -c option to pidof, for only checking processes with the same
+    file system root.  Patch by Thomas Woerner and Fedora.
 
  -- Petter Reinholdtsen <pere at debian.org>  Wed, 01 Jul 2009 20:04:20 +0200
 

Modified: sysvinit/trunk/debian/patches/00list
===================================================================
--- sysvinit/trunk/debian/patches/00list	2009-07-08 13:46:56 UTC (rev 1382)
+++ sysvinit/trunk/debian/patches/00list	2009-07-08 14:55:49 UTC (rev 1383)
@@ -18,6 +18,7 @@
 42_utmpdump_retval
 45_pidof_symlink
 46_pidof_symlinkman
+47_pidof_chroot
 50_bootlogd_exitcode
 51_bootlogd_syncalot
 52_bootlogd_createlogfile

Added: sysvinit/trunk/debian/patches/47_pidof_chroot.dpatch
===================================================================
--- sysvinit/trunk/debian/patches/47_pidof_chroot.dpatch	                        (rev 0)
+++ sysvinit/trunk/debian/patches/47_pidof_chroot.dpatch	2009-07-08 14:55:49 UTC (rev 1383)
@@ -0,0 +1,88 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 47_pidof_chroot.dpatch by Thomas Woerner and Fedora.
+
+Add -c option to pidof for only matching processes with the same
+process root.  Ignore -c when not running as root (RH bug #230829).
+
+ at DPATCH@
+--- sysvinit-2.86/man/pidof.8.chroot	1998-09-02 08:49:33.000000000 -0400
++++ sysvinit-2.86/man/pidof.8	2005-12-19 15:37:40.000000000 -0500
+@@ -4,6 +4,7 @@
+ .SH SYNOPSIS
+ .B pidof
+ .RB [ \-s ]
++.RB [ \-c ]
+ .RB [ \-x ]
+ .RB [ \-o
+ .IR omitpid ]
+@@ -24,6 +25,10 @@
+ .SH OPTIONS
+ .IP -s
+ Single shot - this instructs the program to only return one \fIpid\fP.
++.IP -c
++Only return process ids that are running with the same root directory.
++This option is ignored for non-root users, as they will be unable to check
++the current root directory of processes they do not own.
+ .IP -x
+ Scripts too - this causes the program to also return process id's of
+ shells running the named scripts.
+--- sysvinit-2.86/src/killall5.c.chroot	2004-07-30 08:16:23.000000000 -0400
++++ sysvinit-2.86/src/killall5.c	2005-12-19 15:38:47.000000000 -0500
+@@ -476,16 +476,22 @@
+ 	int		f;
+ 	int		first = 1;
+ 	int		i, oind, opt, flags = 0;
++	int		chroot_check = 0;
++	struct stat	st;
++	char		tmp[512];
+ 
+ 	for (oind = PIDOF_OMITSZ-1; oind > 0; oind--)
+ 		opid[oind] = 0;
+ 	opterr = 0;
+ 
+-	while ((opt = getopt(argc,argv,"ho:sx")) != EOF) switch (opt) {
++	while ((opt = getopt(argc,argv,"hco:sx")) != EOF) switch (opt) {
+ 		case '?':
+ 			nsyslog(LOG_ERR,"invalid options on command line!\n");
+ 			closelog();
+ 			exit(1);
++		case 'c':
++			if (geteuid() == 0) chroot_check = 1;
++			break;
+ 		case 'o':
+ 			if (oind >= PIDOF_OMITSZ -1) {
+ 				nsyslog(LOG_ERR,"omit pid buffer size %d "
+@@ -518,6 +524,16 @@
+ 	argc -= optind;
+ 	argv += optind;
+ 
++	/* Check if we are in a chroot */
++	if (chroot_check) {
++		snprintf(tmp, 512, "/proc/%d/root", getpid());
++		if (stat(tmp, &st) < 0) {
++			nsyslog(LOG_ERR, "stat failed for %s!\n", tmp);
++			closelog();
++			exit(1);
++		}
++	}
++
+ 	/* Print out process-ID's one by one. */
+ 	readproc();
+ 	for(f = 0; f < argc; f++) {
+@@ -541,6 +557,16 @@
+ 					else
+ 						spid = 1;
+ 				}
++				if (chroot_check) {
++					struct stat st2;
++					snprintf(tmp, 512, "/proc/%d/root",
++						 p->pid);
++					if (stat(tmp, &st2) < 0 ||
++					    st.st_dev != st2.st_dev ||
++					    st.st_ino != st2.st_ino) {
++						continue;
++					}
++				}
+ 				if (!first)
+ 					printf(" ");
+ 				printf("%d", p->pid);


Property changes on: sysvinit/trunk/debian/patches/47_pidof_chroot.dpatch
___________________________________________________________________
Added: svn:executable
   + *




More information about the Pkg-sysvinit-commits mailing list