diff options
Diffstat (limited to 'recipes-extended')
-rw-r--r-- | recipes-extended/psmisc/psmisc/pstree-compiles-with-SE-Linux.patch | 265 | ||||
-rw-r--r-- | recipes-extended/psmisc/psmisc_22.20.bbappend | 6 |
2 files changed, 270 insertions, 1 deletions
diff --git a/recipes-extended/psmisc/psmisc/pstree-compiles-with-SE-Linux.patch b/recipes-extended/psmisc/psmisc/pstree-compiles-with-SE-Linux.patch new file mode 100644 index 0000000..8d58a0c --- /dev/null +++ b/recipes-extended/psmisc/psmisc/pstree-compiles-with-SE-Linux.patch | |||
@@ -0,0 +1,265 @@ | |||
1 | From 89fa40f0a55096a62809e852244d7db3f445b0cd Mon Sep 17 00:00:00 2001 | ||
2 | From: Craig Small <csmall@enc.com.au> | ||
3 | Date: Sun, 7 Oct 2012 10:52:46 +1100 | ||
4 | Subject: [PATCH] pstree compiles with SE Linux | ||
5 | |||
6 | Upstream-Status: Backport | ||
7 | |||
8 | pstree failed to compile with SE Linux enabled because one of the | ||
9 | scontext was missed and without it enabled the bug doesn't appear. | ||
10 | |||
11 | pstree is now re-worked so scontext is defined as a dummy meaning | ||
12 | most of the code except the reall SE Linux specific stuff is compilied | ||
13 | meaning this sort of thing shouldn't happen too much again. | ||
14 | |||
15 | Bug-Gentoo: https://bugs.gentoo.org/show_bug.cgi?id=437332 | ||
16 | Bug-Sourceforge: https://sourceforge.net/p/psmisc/bugs/54/ | ||
17 | --- | ||
18 | src/pstree.c | 69 +++++----------------------------------------------------- | ||
19 | 1 file changed, 6 insertions(+), 63 deletions(-) | ||
20 | |||
21 | diff --git a/src/pstree.c b/src/pstree.c | ||
22 | index db57244..b9a01cf 100644 | ||
23 | --- a/src/pstree.c | ||
24 | +++ b/src/pstree.c | ||
25 | @@ -47,6 +47,8 @@ | ||
26 | |||
27 | #ifdef WITH_SELINUX | ||
28 | #include <selinux/selinux.h> | ||
29 | +#else | ||
30 | +typedef void* security_context_t; /* DUMMY to remove most ifdefs */ | ||
31 | #endif /*WITH_SELINUX */ | ||
32 | |||
33 | extern const char *__progname; | ||
34 | @@ -81,9 +83,7 @@ typedef struct _proc { | ||
35 | pid_t pid; | ||
36 | pid_t pgid; | ||
37 | uid_t uid; | ||
38 | -#ifdef WITH_SELINUX | ||
39 | security_context_t scontext; | ||
40 | -#endif /*WITH_SELINUX */ | ||
41 | char flags; | ||
42 | struct _child *children; | ||
43 | struct _proc *parent; | ||
44 | @@ -131,16 +131,14 @@ static int *more = NULL; | ||
45 | |||
46 | static int print_args = 0, compact = 1, user_change = 0, pids = 0, pgids = 0, | ||
47 | show_parents = 0, by_pid = 0, trunc = 1, wait_end = 0; | ||
48 | -#ifdef WITH_SELINUX | ||
49 | static int show_scontext = 0; | ||
50 | -#endif /*WITH_SELINUX */ | ||
51 | static int output_width = 132; | ||
52 | static int cur_x = 1; | ||
53 | static char last_char = 0; | ||
54 | static int dumped = 0; /* used by dump_by_user */ | ||
55 | static int charlen = 0; /* length of character */ | ||
56 | |||
57 | -static void fix_orphans(void); | ||
58 | +static void fix_orphans(security_context_t scontext); | ||
59 | /* | ||
60 | * Allocates additional buffer space for width and more as needed. | ||
61 | * The first call will allocate the first buffer. | ||
62 | @@ -229,15 +227,12 @@ static int out_int(int x) | ||
63 | return digits; | ||
64 | } | ||
65 | |||
66 | -#ifdef WITH_SELINUX | ||
67 | static void out_scontext(security_context_t scontext) | ||
68 | { | ||
69 | out_string("`"); | ||
70 | out_string(scontext); | ||
71 | out_string("'"); | ||
72 | } | ||
73 | -#endif /*WITH_SELINUX */ | ||
74 | - | ||
75 | |||
76 | static void out_newline(void) | ||
77 | { | ||
78 | @@ -259,12 +254,8 @@ static PROC *find_proc(pid_t pid) | ||
79 | return NULL; | ||
80 | } | ||
81 | |||
82 | -#ifdef WITH_SELINUX | ||
83 | static PROC *new_proc(const char *comm, pid_t pid, uid_t uid, | ||
84 | security_context_t scontext) | ||
85 | -#else /*WITH_SELINUX */ | ||
86 | -static PROC *new_proc(const char *comm, pid_t pid, uid_t uid) | ||
87 | -#endif /*WITH_SELINUX */ | ||
88 | { | ||
89 | PROC *new; | ||
90 | |||
91 | @@ -279,9 +270,7 @@ static PROC *new_proc(const char *comm, pid_t pid, uid_t uid) | ||
92 | new->flags = 0; | ||
93 | new->argc = 0; | ||
94 | new->argv = NULL; | ||
95 | -#ifdef WITH_SELINUX | ||
96 | new->scontext = scontext; | ||
97 | -#endif /*WITH_SELINUX */ | ||
98 | new->children = NULL; | ||
99 | new->parent = NULL; | ||
100 | new->next = list; | ||
101 | @@ -364,24 +353,14 @@ rename_proc(PROC *this, const char *comm, uid_t uid) | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | -#ifdef WITH_SELINUX | ||
106 | static void | ||
107 | add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid, | ||
108 | const char *args, int size, char isthread, security_context_t scontext) | ||
109 | -#else /*WITH_SELINUX */ | ||
110 | -static void | ||
111 | -add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid, | ||
112 | - const char *args, int size, char isthread) | ||
113 | -#endif /*WITH_SELINUX */ | ||
114 | { | ||
115 | PROC *this, *parent; | ||
116 | |||
117 | if (!(this = find_proc(pid))) | ||
118 | -#ifdef WITH_SELINUX | ||
119 | this = new_proc(comm, pid, uid, scontext); | ||
120 | -#else /*WITH_SELINUX */ | ||
121 | - this = new_proc(comm, pid, uid); | ||
122 | -#endif /*WITH_SELINUX */ | ||
123 | else { | ||
124 | rename_proc(this, comm, uid); | ||
125 | } | ||
126 | @@ -393,11 +372,7 @@ add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid, | ||
127 | if (isthread) | ||
128 | this->flags |= PFLAG_THREAD; | ||
129 | if (!(parent = find_proc(ppid))) { | ||
130 | -#ifdef WITH_SELINUX | ||
131 | parent = new_proc("?", ppid, 0, scontext); | ||
132 | -#else /*WITH_SELINUX */ | ||
133 | - parent = new_proc("?", ppid, 0); | ||
134 | -#endif | ||
135 | } | ||
136 | if (pid != 0) { | ||
137 | add_child(parent, this); | ||
138 | @@ -494,12 +469,10 @@ dump_tree(PROC * current, int level, int rep, int leaf, int last, | ||
139 | else | ||
140 | (void) out_int(current->uid); | ||
141 | } | ||
142 | -#ifdef WITH_SELINUX | ||
143 | if (show_scontext) { | ||
144 | out_char(info++ ? ',' : '('); | ||
145 | out_scontext(current->scontext); | ||
146 | } | ||
147 | -#endif /*WITH_SELINUX */ | ||
148 | if ((swapped && print_args && current->argc < 0) || (!swapped && info)) | ||
149 | out_char(')'); | ||
150 | if ((current->flags & PFLAG_HILIGHT) && (tmp = tgetstr("me", NULL))) | ||
151 | @@ -520,11 +493,7 @@ dump_tree(PROC * current, int level, int rep, int leaf, int last, | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | -#ifdef WITH_SELINUX | ||
156 | if (show_scontext || print_args || !current->children) | ||
157 | -#else /*WITH_SELINUX */ | ||
158 | - if (print_args || !current->children) | ||
159 | -#endif /*WITH_SELINUX */ | ||
160 | { | ||
161 | while (closing--) | ||
162 | out_char(']'); | ||
163 | @@ -533,11 +502,7 @@ dump_tree(PROC * current, int level, int rep, int leaf, int last, | ||
164 | ensure_buffer_capacity(level); | ||
165 | more[level] = !last; | ||
166 | |||
167 | -#ifdef WITH_SELINUX | ||
168 | if (show_scontext || print_args) | ||
169 | -#else /*WITH_SELINUX */ | ||
170 | - if (print_args) | ||
171 | -#endif /*WITH_SELINUX */ | ||
172 | { | ||
173 | width[level] = swapped + (comm_len > 1 ? 0 : -1); | ||
174 | count=0; | ||
175 | @@ -653,8 +618,8 @@ static void read_proc(void) | ||
176 | pid_t pid, ppid, pgid; | ||
177 | int fd, size; | ||
178 | int empty; | ||
179 | -#ifdef WITH_SELINUX | ||
180 | security_context_t scontext = NULL; | ||
181 | +#ifdef WITH_SELINUX | ||
182 | int selinux_enabled = is_selinux_enabled() > 0; | ||
183 | #endif /*WITH_SELINUX */ | ||
184 | |||
185 | @@ -726,21 +691,12 @@ static void read_proc(void) | ||
186 | while ((dt = readdir(taskdir)) != NULL) { | ||
187 | if ((thread = atoi(dt->d_name)) != 0) { | ||
188 | if (thread != pid) { | ||
189 | -#ifdef WITH_SELINUX | ||
190 | if (print_args) | ||
191 | add_proc(threadname, thread, pid, pgid, st.st_uid, | ||
192 | threadname, strlen (threadname) + 1, 1,scontext); | ||
193 | else | ||
194 | add_proc(threadname, thread, pid, pgid, st.st_uid, | ||
195 | NULL, 0, 1, scontext); | ||
196 | -#else /*WITH_SELINUX */ | ||
197 | - if (print_args) | ||
198 | - add_proc(threadname, thread, pid, pgid, st.st_uid, | ||
199 | - threadname, strlen (threadname) + 1, 1); | ||
200 | - else | ||
201 | - add_proc(threadname, thread, pid, pgid, st.st_uid, | ||
202 | - NULL, 0, 1); | ||
203 | -#endif /*WITH_SELINUX */ | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | @@ -749,11 +705,7 @@ static void read_proc(void) | ||
208 | } | ||
209 | free(taskpath); | ||
210 | if (!print_args) | ||
211 | -#ifdef WITH_SELINUX | ||
212 | add_proc(comm, pid, ppid, pgid, st.st_uid, NULL, 0, 0, scontext); | ||
213 | -#else /*WITH_SELINUX */ | ||
214 | - add_proc(comm, pid, ppid, pgid, st.st_uid, NULL, 0, 0); | ||
215 | -#endif /*WITH_SELINUX */ | ||
216 | else { | ||
217 | sprintf(path, "%s/%d/cmdline", PROC_BASE, pid); | ||
218 | if ((fd = open(path, O_RDONLY)) < 0) { | ||
219 | @@ -770,13 +722,8 @@ static void read_proc(void) | ||
220 | size--; | ||
221 | if (size) | ||
222 | buffer[size++] = 0; | ||
223 | -#ifdef WITH_SELINUX | ||
224 | add_proc(comm, pid, ppid, pgid, st.st_uid, | ||
225 | buffer, size, 0, scontext); | ||
226 | -#else /*WITH_SELINUX */ | ||
227 | - add_proc(comm, pid, ppid, pgid, st.st_uid, | ||
228 | - buffer, size, 0); | ||
229 | -#endif /*WITH_SELINUX */ | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | @@ -787,7 +734,7 @@ static void read_proc(void) | ||
234 | } | ||
235 | } | ||
236 | (void) closedir(dir); | ||
237 | - fix_orphans(); | ||
238 | + fix_orphans(scontext); | ||
239 | if (print_args) | ||
240 | free(buffer); | ||
241 | if (empty) { | ||
242 | @@ -796,7 +743,7 @@ static void read_proc(void) | ||
243 | } | ||
244 | } | ||
245 | |||
246 | -static void fix_orphans(void) | ||
247 | +static void fix_orphans(security_context_t scontext) | ||
248 | { | ||
249 | /* When using kernel 3.3 with hidepid feature enabled on /proc | ||
250 | * then we need fake root pid and gather all the orphan processes | ||
251 | @@ -807,11 +754,7 @@ static void fix_orphans(void) | ||
252 | PROC *root, *walk; | ||
253 | |||
254 | if (!(root = find_proc(ROOT_PID))) { | ||
255 | -#ifdef WITH_SELINUX | ||
256 | root = new_proc("?", ROOT_PID, 0, scontext); | ||
257 | -#else /*WITH_SELINUX */ | ||
258 | - root = new_proc("?", ROOT_PID, 0); | ||
259 | -#endif | ||
260 | } | ||
261 | for (walk = list; walk; walk = walk->next) { | ||
262 | if (walk->pid == 1 || walk->pid == 0) | ||
263 | -- | ||
264 | 1.7.9.5 | ||
265 | |||
diff --git a/recipes-extended/psmisc/psmisc_22.20.bbappend b/recipes-extended/psmisc/psmisc_22.20.bbappend index 5ad8973..d25468e 100644 --- a/recipes-extended/psmisc/psmisc_22.20.bbappend +++ b/recipes-extended/psmisc/psmisc_22.20.bbappend | |||
@@ -1,3 +1,7 @@ | |||
1 | PR .= ".2" | 1 | PR .= ".2" |
2 | 2 | ||
3 | inherit with-selinux | 3 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
4 | |||
5 | SRC_URI += "file://pstree-compiles-with-SE-Linux.patch" | ||
6 | |||
7 | inherit enable-selinux | ||