]> git.pld-linux.org Git - packages/SysVinit.git/blame - sysvinit-chroot.patch
- /etc/logrotate.d/sysvinit should be configuration file
[packages/SysVinit.git] / sysvinit-chroot.patch
CommitLineData
8c09d4df
AM
1--- sysvinit-2.86/man/pidof.8.chroot 1998-09-02 08:49:33.000000000 -0400
2+++ sysvinit-2.86/man/pidof.8 2005-12-19 15:37:40.000000000 -0500
3@@ -4,6 +4,7 @@
4 .SH SYNOPSIS
5 .B pidof
6 .RB [ \-s ]
7+.RB [ \-c ]
8 .RB [ \-x ]
9 .RB [ \-o
10 .IR omitpid ]
11@@ -24,6 +25,10 @@
12 .SH OPTIONS
13 .IP -s
14 Single shot - this instructs the program to only return one \fIpid\fP.
15+.IP -c
16+Only return process ids that are running with the same root directory.
17+This option is ignored for non-root users, as they will be unable to check
18+the current root directory of processes they do not own.
19 .IP -x
20 Scripts too - this causes the program to also return process id's of
21 shells running the named scripts.
22--- sysvinit-2.86/src/killall5.c.chroot 2004-07-30 08:16:23.000000000 -0400
23+++ sysvinit-2.86/src/killall5.c 2005-12-19 15:38:47.000000000 -0500
24@@ -476,16 +476,22 @@
25 int f;
26 int first = 1;
27 int i, oind, opt, flags = 0;
28+ int chroot_check = 0;
29+ struct stat st;
30+ char tmp[512];
31
32 for (oind = PIDOF_OMITSZ-1; oind > 0; oind--)
33 opid[oind] = 0;
34 opterr = 0;
35
36- while ((opt = getopt(argc,argv,"ho:sx")) != EOF) switch (opt) {
37+ while ((opt = getopt(argc,argv,"hco:sx")) != EOF) switch (opt) {
38 case '?':
39 nsyslog(LOG_ERR,"invalid options on command line!\n");
40 closelog();
41 exit(1);
42+ case 'c':
43+ if (geteuid() == 0) chroot_check = 1;
44+ break;
45 case 'o':
46 if (oind >= PIDOF_OMITSZ -1) {
47 nsyslog(LOG_ERR,"omit pid buffer size %d "
48@@ -518,6 +524,16 @@
49 argc -= optind;
50 argv += optind;
51
52+ /* Check if we are in a chroot */
53+ if (chroot_check) {
54+ snprintf(tmp, 512, "/proc/%d/root", getpid());
55+ if (stat(tmp, &st) < 0) {
56+ nsyslog(LOG_ERR, "stat failed for %s!\n", tmp);
57+ closelog();
58+ exit(1);
59+ }
60+ }
61+
62 /* Print out process-ID's one by one. */
63 readproc();
64 for(f = 0; f < argc; f++) {
65@@ -541,6 +557,16 @@
66 else
67 spid = 1;
68 }
69+ if (chroot_check) {
70+ struct stat st2;
71+ snprintf(tmp, 512, "/proc/%d/root",
72+ p->pid);
73+ if (stat(tmp, &st2) < 0 ||
74+ st.st_dev != st2.st_dev ||
75+ st.st_ino != st2.st_ino) {
76+ continue;
77+ }
78+ }
79 if (!first)
80 printf(" ");
81 printf("%d", p->pid);
This page took 0.255424 seconds and 4 git commands to generate.