4
|
1 |
Index: Makedefs.in
|
|
2 |
===================================================================
|
|
3 |
--- Makedefs.in (revision 8801)
|
|
4 |
+++ Makedefs.in (working copy)
|
|
5 |
@@ -125,7 +125,7 @@
|
|
6 |
BANNERTOPS = @BANNERTOPS@
|
|
7 |
CFLAGS = @CPPFLAGS@ @CFLAGS@
|
|
8 |
COMMONLIBS = @LIBS@ -lscf
|
|
9 |
-CUPSDLIBS = @CUPSDLIBS@
|
|
10 |
+CUPSDLIBS = @CUPSDLIBS@ @LABELING_LIBS@
|
|
11 |
CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@
|
|
12 |
CXXLIBS = @CXXLIBS@
|
|
13 |
DBUS_NOTIFIER = @DBUS_NOTIFIER@
|
|
14 |
Index: config-scripts/cups-labeling.m4
|
|
15 |
===================================================================
|
|
16 |
--- config-scripts/cups-labeling.m4 (revision 0)
|
|
17 |
+++ config-scripts/cups-labeling.m4 (revision 0)
|
|
18 |
@@ -0,0 +1,38 @@
|
|
19 |
+dnl
|
|
20 |
+dnl Security Labeled environment support for the Common UNIX Printing System (CUPS).
|
|
21 |
+dnl
|
|
22 |
+dnl Copyright 2009 by Sun Microsystems, Inc.
|
|
23 |
+dnl
|
|
24 |
+dnl This program is free software; you can redistribute it and/or modify
|
|
25 |
+dnl it under the terms of the GNU General Public License as published by
|
|
26 |
+dnl the Free Software Foundation; version 2.
|
|
27 |
+dnl
|
|
28 |
+dnl This program is distributed in the hope that it will be useful, but
|
|
29 |
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
30 |
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
31 |
+dnl General Public License for more details.
|
|
32 |
+dnl
|
|
33 |
+dnl You should have received a copy of the GNU General Public License
|
|
34 |
+dnl along with this program; if not, write to the Free Software Foundation,
|
|
35 |
+dnl Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
|
|
36 |
+dnl
|
|
37 |
+
|
|
38 |
+AC_ARG_ENABLE(labeling, [ --enable-labeling enable support for labeled environments like Solaris Trusted Extensions and SELinux, default=auto])
|
|
39 |
+
|
|
40 |
+if test x"$enable_labeling" != xno; then
|
|
41 |
+ case "$uname" in
|
|
42 |
+ SunOS)
|
|
43 |
+ AC_CHECK_LIB(tsol, str_to_label, [LABELING_LIBS="-zlazyload -lbsm -ltsol -znolazyload" AC_SUBST(LABELING_LIBS)
|
|
44 |
+ AC_CHECK_HEADER(tsol/label.h)
|
|
45 |
+ AC_DEFINE(HAVE_TSOL)])
|
|
46 |
+ ;;
|
|
47 |
+ Linux)
|
|
48 |
+ AC_CHECK_LIB(selinux, getpeercon, [LABELING_LIBS="-lselinux" AC_SUBST(LABELING_LIBS)
|
|
49 |
+ AC_CHECK_HEADER(selinux/selinux.h)
|
|
50 |
+ AC_DEFINE(HAVE_SELINUX)])
|
|
51 |
+ ;;
|
|
52 |
+ *)
|
|
53 |
+ # All others
|
|
54 |
+ ;;
|
|
55 |
+ esac
|
|
56 |
+fi
|
|
57 |
Index: data/Makefile
|
|
58 |
===================================================================
|
|
59 |
--- data/Makefile (revision 8857)
|
|
60 |
+++ data/Makefile (working copy)
|
|
61 |
@@ -22,6 +22,7 @@
|
|
62 |
BANNERS = \
|
|
63 |
classified \
|
|
64 |
confidential \
|
|
65 |
+ labeled \
|
|
66 |
secret \
|
|
67 |
standard \
|
|
68 |
topsecret \
|
|
69 |
Index: data/labeled
|
|
70 |
===================================================================
|
|
71 |
--- data/labeled (revision 0)
|
|
72 |
+++ data/labeled (revision 0)
|
|
73 |
@@ -0,0 +1,4 @@
|
|
74 |
+#CUPS-BANNER
|
|
75 |
+Show job-id job-name job-originating-user-name job-originating-host-name job-billing
|
|
76 |
+Image images/cups.png
|
|
77 |
+
|
|
78 |
Index: configure.in
|
|
79 |
===================================================================
|
|
80 |
--- configure.in (revision 8857)
|
|
81 |
+++ configure.in (working copy)
|
|
82 |
@@ -41,6 +41,7 @@
|
|
83 |
sinclude(config-scripts/cups-pap.m4)
|
|
84 |
sinclude(config-scripts/cups-pdf.m4)
|
|
85 |
sinclude(config-scripts/cups-scripting.m4)
|
|
86 |
+sinclude(config-scripts/cups-labeling.m4)
|
|
87 |
|
|
88 |
INSTALL_LANGUAGES=""
|
|
89 |
UNINSTALL_LANGUAGES=""
|
|
90 |
Index: config.h.in
|
|
91 |
===================================================================
|
60
|
92 |
--- config.h.in.orig Thu Aug 12 21:11:46 2010
|
|
93 |
+++ config.h.in Tue Dec 7 01:30:14 2010
|
|
94 |
@@ -665,7 +665,17 @@
|
|
95 |
#undef HAVE_SYS_STATVFS_H
|
|
96 |
#undef HAVE_SYS_VFS_H
|
4
|
97 |
|
|
98 |
+/*
|
|
99 |
+ * Do we have Solaris Trusted Extensions support?
|
|
100 |
+ */
|
|
101 |
|
|
102 |
+#undef HAVE_TSOL
|
|
103 |
+
|
|
104 |
+/*
|
|
105 |
+ * Do we have SELinux support?
|
|
106 |
+ */
|
|
107 |
+#undef HAVE_SELINUX
|
|
108 |
+
|
|
109 |
#endif /* !_CUPS_CONFIG_H_ */
|
|
110 |
|
|
111 |
/*
|
|
112 |
Index: scheduler/ipp.c
|
|
113 |
===================================================================
|
60
|
114 |
--- scheduler/ipp.c.orig Wed Oct 6 13:07:44 2010
|
|
115 |
+++ scheduler/ipp.c Tue Dec 7 01:30:14 2010
|
|
116 |
@@ -856,7 +856,52 @@
|
4
|
117 |
return (0);
|
|
118 |
}
|
|
119 |
|
|
120 |
+static int
|
|
121 |
+compare_labels(char *label1, char *label2)
|
|
122 |
+{
|
|
123 |
+ int result = 0;
|
|
124 |
|
|
125 |
+ if ((label1 != NULL) && (label2 != NULL))
|
|
126 |
+ {
|
|
127 |
+#if defined(HAVE_TSOL)
|
|
128 |
+ if (is_system_labeled())
|
|
129 |
+ {
|
|
130 |
+ result = (strcmp(label1, label2) != 0);
|
|
131 |
+
|
|
132 |
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "compare_labels(%s, %s): %d",
|
|
133 |
+ label1, label2, result);
|
|
134 |
+ }
|
|
135 |
+#elif defined(HAVE_SELINUX)
|
|
136 |
+#endif /* HAVE_TSOL || HAVE_SELINUX */
|
|
137 |
+ }
|
|
138 |
+
|
|
139 |
+ return(result);
|
|
140 |
+}
|
|
141 |
+
|
|
142 |
+static char *
|
|
143 |
+label_to_page_top_bottom_string(char *label)
|
|
144 |
+{
|
|
145 |
+ char *result = label;
|
|
146 |
+
|
|
147 |
+#if defined(HAVE_TSOL)
|
|
148 |
+ if (is_system_labeled())
|
|
149 |
+ {
|
|
150 |
+ m_label_t *sl = NULL;
|
|
151 |
+
|
|
152 |
+ if (str_to_label(label, &sl, USER_CLEAR, L_NO_CORRECTION, NULL) == 0)
|
|
153 |
+ {
|
|
154 |
+ (void) label_to_str(sl, &result, PRINTER_TOP_BOTTOM, DEF_NAMES);
|
|
155 |
+ if (result == NULL)
|
|
156 |
+ result = label;
|
|
157 |
+
|
|
158 |
+ m_label_free(sl);
|
|
159 |
+ }
|
|
160 |
+ }
|
|
161 |
+#endif
|
|
162 |
+
|
|
163 |
+ return (result);
|
|
164 |
+}
|
|
165 |
+
|
|
166 |
/*
|
|
167 |
* 'accept_jobs()' - Accept print jobs to a printer.
|
|
168 |
*/
|
60
|
169 |
@@ -1361,6 +1406,17 @@
|
4
|
170 |
filetype, filetype ? filetype->super : "none",
|
|
171 |
filetype ? filetype->type : "none");
|
|
172 |
|
|
173 |
+ /*
|
|
174 |
+ * Validate that the label associated with the connection is acceptable for
|
|
175 |
+ * printing on the printer.
|
|
176 |
+ */
|
|
177 |
+ if (cupsdInPrinterLabelRange(con->slabel, printer) == 0)
|
|
178 |
+ {
|
|
179 |
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("label violation."));
|
|
180 |
+ return (NULL);
|
|
181 |
+ }
|
|
182 |
+
|
|
183 |
+
|
|
184 |
/*
|
|
185 |
* Check remote printing to non-shared printer...
|
|
186 |
*/
|
60
|
187 |
@@ -1620,6 +1676,19 @@
|
4
|
188 |
return (NULL);
|
|
189 |
}
|
|
190 |
|
|
191 |
+ /*
|
|
192 |
+ * Add the label to the job...
|
|
193 |
+ */
|
|
194 |
+ if (con->slabel)
|
|
195 |
+ {
|
|
196 |
+ job->slabel = strdup(con->slabel);
|
|
197 |
+ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "security-label",
|
|
198 |
+ NULL, job->slabel);
|
|
199 |
+ /* used by filters to add header/footer labels to output */
|
|
200 |
+ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "page-label",
|
|
201 |
+ NULL, label_to_page_top_bottom_string(job->slabel));
|
|
202 |
+ }
|
|
203 |
+
|
|
204 |
job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT |
|
|
205 |
CUPS_PRINTER_REMOTE);
|
|
206 |
job->attrs = con->request;
|
60
|
207 |
@@ -3761,6 +3830,15 @@
|
4
|
208 |
return;
|
|
209 |
}
|
|
210 |
|
|
211 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
212 |
+ {
|
|
213 |
+ /*
|
|
214 |
+ * If the labels don't match, we can't tell them about it.
|
|
215 |
+ */
|
|
216 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
217 |
+ return;
|
|
218 |
+ }
|
|
219 |
+
|
|
220 |
/*
|
|
221 |
* See if the job has been completed...
|
|
222 |
*/
|
60
|
223 |
@@ -4129,6 +4207,16 @@
|
4
|
224 |
return;
|
|
225 |
}
|
|
226 |
|
|
227 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
228 |
+ {
|
|
229 |
+ /*
|
|
230 |
+ * If the labels don't match, we can't tell them about it.
|
|
231 |
+ */
|
|
232 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
233 |
+ return;
|
|
234 |
+ }
|
|
235 |
+
|
|
236 |
+
|
|
237 |
/*
|
|
238 |
* See if the job is owned by the requesting user...
|
|
239 |
*/
|
60
|
240 |
@@ -6389,6 +6477,16 @@
|
4
|
241 |
send_ipp_status(con, IPP_NOT_FOUND, _("Job %d not found!"), jobid);
|
|
242 |
return;
|
|
243 |
}
|
|
244 |
+
|
|
245 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
246 |
+ {
|
|
247 |
+ /*
|
|
248 |
+ * If the labels don't match, we can't tell them about it.
|
|
249 |
+ */
|
|
250 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"),
|
|
251 |
+ jobid);
|
|
252 |
+ return;
|
|
253 |
+ }
|
|
254 |
}
|
|
255 |
else
|
|
256 |
job = NULL;
|
60
|
257 |
@@ -6936,6 +7034,15 @@
|
4
|
258 |
return;
|
|
259 |
}
|
|
260 |
|
|
261 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
262 |
+ {
|
|
263 |
+ /*
|
|
264 |
+ * If the labels don't match, we can't tell them about it.
|
|
265 |
+ */
|
|
266 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
267 |
+ return;
|
|
268 |
+ }
|
|
269 |
+
|
|
270 |
/*
|
|
271 |
* Copy attributes...
|
|
272 |
*/
|
60
|
273 |
@@ -7156,6 +7263,14 @@
|
4
|
274 |
|
|
275 |
cupsdLoadJob(job);
|
|
276 |
|
|
277 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
278 |
+ {
|
|
279 |
+ /*
|
|
280 |
+ * If the labels don't match, we can't tell them about it.
|
|
281 |
+ */
|
|
282 |
+ continue;
|
|
283 |
+ }
|
|
284 |
+
|
|
285 |
if (!job->attrs)
|
|
286 |
{
|
|
287 |
cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d!",
|
60
|
288 |
@@ -8212,6 +8327,15 @@
|
4
|
289 |
return;
|
|
290 |
}
|
|
291 |
|
|
292 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
293 |
+ {
|
|
294 |
+ /*
|
|
295 |
+ * If the labels don't match, we can't tell them about it.
|
|
296 |
+ */
|
|
297 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
298 |
+ return;
|
|
299 |
+ }
|
|
300 |
+
|
|
301 |
/*
|
|
302 |
* See if the job is owned by the requesting user...
|
|
303 |
*/
|
60
|
304 |
@@ -8466,6 +8590,14 @@
|
4
|
305 |
_("Job #%d does not exist!"), jobid);
|
|
306 |
return;
|
|
307 |
}
|
|
308 |
+ else if (compare_labels(con->slabel, job->slabel) != 0)
|
|
309 |
+ {
|
|
310 |
+ /*
|
|
311 |
+ * If the labels don't match, we can't tell them about it.
|
|
312 |
+ */
|
|
313 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
314 |
+ return;
|
|
315 |
+ }
|
|
316 |
else
|
|
317 |
{
|
|
318 |
/*
|
60
|
319 |
@@ -8488,6 +8620,27 @@
|
4
|
320 |
return;
|
|
321 |
}
|
|
322 |
|
|
323 |
+ /*
|
|
324 |
+ * Validate that the label associated with the connection is acceptable for
|
|
325 |
+ * printing on the printer.
|
|
326 |
+ */
|
|
327 |
+ if (cupsdInPrinterLabelRange(con->slabel, dprinter) == 0)
|
|
328 |
+ {
|
|
329 |
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("label violation."));
|
|
330 |
+ return;
|
|
331 |
+ }
|
|
332 |
+
|
|
333 |
+ /*
|
|
334 |
+ * Validate that the label associated with the job is acceptable for
|
|
335 |
+ * printing on the printer.
|
|
336 |
+ */
|
|
337 |
+ if (cupsdInPrinterLabelRange(job->slabel, dprinter) == 0)
|
|
338 |
+ {
|
|
339 |
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("label violation."));
|
|
340 |
+ return;
|
|
341 |
+ }
|
|
342 |
+
|
|
343 |
+
|
|
344 |
/*
|
|
345 |
* Now move the job or jobs...
|
|
346 |
*/
|
60
|
347 |
@@ -9318,6 +9471,16 @@
|
4
|
348 |
return;
|
|
349 |
}
|
|
350 |
|
|
351 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
352 |
+ {
|
|
353 |
+ /*
|
|
354 |
+ * If the labels don't match, we can't tell them about it.
|
|
355 |
+ */
|
|
356 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
357 |
+ return;
|
|
358 |
+ }
|
|
359 |
+
|
|
360 |
+
|
|
361 |
/*
|
|
362 |
* See if job is "held"...
|
|
363 |
*/
|
60
|
364 |
@@ -9544,6 +9707,15 @@
|
4
|
365 |
return;
|
|
366 |
}
|
|
367 |
|
|
368 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
369 |
+ {
|
|
370 |
+ /*
|
|
371 |
+ * If the labels don't match, we can't tell them about it.
|
|
372 |
+ */
|
|
373 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
374 |
+ return;
|
|
375 |
+ }
|
|
376 |
+
|
|
377 |
/*
|
|
378 |
* See if job is in any of the "completed" states...
|
|
379 |
*/
|
60
|
380 |
@@ -9899,6 +10071,15 @@
|
4
|
381 |
return;
|
|
382 |
}
|
|
383 |
|
|
384 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
385 |
+ {
|
|
386 |
+ /*
|
|
387 |
+ * If the labels don't match, we can't tell them about it.
|
|
388 |
+ */
|
|
389 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
390 |
+ return;
|
|
391 |
+ }
|
|
392 |
+
|
|
393 |
printer = cupsdFindDest(job->dest);
|
|
394 |
|
|
395 |
/*
|
60
|
396 |
@@ -10488,6 +10669,15 @@
|
4
|
397 |
return;
|
|
398 |
}
|
|
399 |
|
|
400 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
401 |
+ {
|
|
402 |
+ /*
|
|
403 |
+ * If the labels don't match, we can't tell them about it.
|
|
404 |
+ */
|
|
405 |
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
406 |
+ return;
|
|
407 |
+ }
|
|
408 |
+
|
|
409 |
/*
|
|
410 |
* See if the job has been completed...
|
|
411 |
*/
|
60
|
412 |
@@ -10825,7 +11015,6 @@
|
4
|
413 |
/*
|
|
414 |
* Return a list of attributes that can be set via Set-Printer-Attributes.
|
|
415 |
*/
|
|
416 |
-
|
|
417 |
if ((attr = ippFindAttribute(con->request, "printer-location",
|
|
418 |
IPP_TAG_TEXT)) != NULL)
|
|
419 |
{
|
60
|
420 |
@@ -11584,6 +11773,11 @@
|
4
|
421 |
|
|
422 |
strlcpy(username, get_username(con), userlen);
|
|
423 |
|
|
424 |
+ if (compare_labels(con->slabel, job->slabel) != 0)
|
|
425 |
+ {
|
|
426 |
+ return (0);
|
|
427 |
+ }
|
|
428 |
+
|
|
429 |
/*
|
|
430 |
* Check the username against the owner...
|
|
431 |
*/
|
|
432 |
Index: scheduler/printers.c
|
|
433 |
===================================================================
|
60
|
434 |
--- scheduler/printers.c.orig Wed Sep 22 11:35:07 2010
|
|
435 |
+++ scheduler//printers.c Tue Dec 7 01:30:14 2010
|
|
436 |
@@ -1011,7 +1011,93 @@
|
4
|
437 |
p->users = NULL;
|
|
438 |
}
|
|
439 |
|
|
440 |
+#if defined(HAVE_TSOL)
|
|
441 |
+static char *
|
|
442 |
+log_tsol_str_to_label_error(char *s, int e)
|
|
443 |
+{
|
|
444 |
+ char *mesg = strerror(errno);
|
|
445 |
|
|
446 |
+ if (errno == EINVAL)
|
|
447 |
+ {
|
|
448 |
+ switch (e) {
|
|
449 |
+ case M_BAD_STRING:
|
|
450 |
+ mesg = "bad string";
|
|
451 |
+ break;
|
|
452 |
+ case M_BAD_LABEL:
|
|
453 |
+ mesg = "bad label";
|
|
454 |
+ break;
|
|
455 |
+ case M_OUTSIDE_AR:
|
|
456 |
+ mesg = "outside DIA Accreditation Range";
|
|
457 |
+ break;
|
|
458 |
+ }
|
|
459 |
+ }
|
|
460 |
+
|
|
461 |
+ return (mesg);
|
|
462 |
+}
|
|
463 |
+#endif /* HAVE_TSOL */
|
|
464 |
+
|
|
465 |
+/*
|
|
466 |
+ * 'cupsdInPrinterLabelRange()' - validate that the supplied slabel is in the
|
|
467 |
+ * label range of the supplied printer.
|
|
468 |
+ * 0 - failure, 1 - success
|
|
469 |
+ */
|
|
470 |
+int
|
|
471 |
+cupsdInPrinterLabelRange(char *slabel, cupsd_printer_t *p)
|
|
472 |
+{
|
|
473 |
+ /* unlabeled client objects are always in range. */
|
|
474 |
+ if (slabel == NULL)
|
|
475 |
+ return (1);
|
|
476 |
+
|
|
477 |
+ if (p == NULL) /* this should never happen */
|
|
478 |
+ return (0);
|
|
479 |
+
|
|
480 |
+#if defined(HAVE_TSOL)
|
|
481 |
+ if (is_system_labeled())
|
|
482 |
+ {
|
|
483 |
+ int in_range = 0;
|
|
484 |
+ int err = 0;
|
|
485 |
+ m_range_t *range;
|
|
486 |
+ m_label_t *sl = NULL;
|
|
487 |
+
|
|
488 |
+ if (p->device_uri == 0) /* this should never happen */
|
|
489 |
+ return (0);
|
|
490 |
+
|
|
491 |
+ if (str_to_label(slabel, &sl, USER_CLEAR, L_NO_CORRECTION, &err) < 0)
|
|
492 |
+ {
|
|
493 |
+ cupsdLogMessage(CUPSD_LOG_ERROR, "str_to_label(%s): %s", slabel,
|
|
494 |
+ log_tsol_str_to_label_error(slabel, err));
|
|
495 |
+ return (0);
|
|
496 |
+ }
|
|
497 |
+
|
|
498 |
+ if ((range = getdevicerange((const char *)(p->device_uri))) == NULL)
|
|
499 |
+ {
|
|
500 |
+ cupsdLogMessage(CUPSD_LOG_ERROR,
|
|
501 |
+ "cupsdInPrinterLabelRange(%s, %s): getdevicerange(%s): %s",
|
|
502 |
+ slabel, p->name, p->device_uri, strerror(errno));
|
|
503 |
+ m_label_free(sl);
|
|
504 |
+ return (0);
|
|
505 |
+ }
|
|
506 |
+
|
|
507 |
+ /* is the client supplied object label is within the printer label range? */
|
|
508 |
+ in_range = blinrange(sl, range);
|
|
509 |
+
|
|
510 |
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdInPrinterLabelRange(%s, %s): %d",
|
|
511 |
+ slabel, p->name, in_range);
|
|
512 |
+
|
|
513 |
+ m_label_free(sl);
|
|
514 |
+ m_label_free(range->lower_bound);
|
|
515 |
+ m_label_free(range->upper_bound);
|
|
516 |
+ free(range);
|
|
517 |
+
|
|
518 |
+ return (in_range);
|
|
519 |
+ }
|
|
520 |
+#elif defined(HAVE_SELINUX)
|
|
521 |
+#endif /* HAVE_TSOL || HAVE_SELINUX */
|
|
522 |
+
|
|
523 |
+ /* we should probably never get here */
|
|
524 |
+ return (0);
|
|
525 |
+}
|
|
526 |
+
|
|
527 |
/*
|
|
528 |
* 'cupsdLoadAllPrinters()' - Load printers from the printers.conf file.
|
|
529 |
*/
|
|
530 |
Index: scheduler/job.c
|
|
531 |
===================================================================
|
60
|
532 |
--- scheduler/job.c.orig Sat Oct 16 21:13:56 2010
|
|
533 |
+++ scheduler/job.c Tue Dec 7 01:30:14 2010
|
4
|
534 |
@@ -911,8 +911,14 @@
|
|
535 |
}
|
|
536 |
}
|
|
537 |
|
|
538 |
- if (Classification && !banner_page)
|
|
539 |
+ if (job->slabel != NULL)
|
|
540 |
{
|
|
541 |
+ snprintf(classification, sizeof(classification), "CLASSIFICATION=%s",
|
|
542 |
+ job->slabel);
|
|
543 |
+ envp[envc ++] = classification;
|
|
544 |
+ }
|
|
545 |
+ else if (Classification && !banner_page)
|
|
546 |
+ {
|
|
547 |
if ((attr = ippFindAttribute(job->attrs, "job-sheets",
|
|
548 |
IPP_TAG_NAME)) == NULL)
|
|
549 |
snprintf(classification, sizeof(classification), "CLASSIFICATION=%s",
|
|
550 |
@@ -1276,6 +1282,12 @@
|
|
551 |
job->num_files = 0;
|
|
552 |
}
|
|
553 |
|
|
554 |
+ if (job->slabel)
|
|
555 |
+ {
|
|
556 |
+ free(job->slabel);
|
|
557 |
+ job->slabel = NULL;
|
|
558 |
+ }
|
|
559 |
+
|
|
560 |
if (job->history)
|
|
561 |
free_job_history(job);
|
|
562 |
|
|
563 |
@@ -1562,6 +1574,10 @@
|
|
564 |
goto error;
|
|
565 |
}
|
|
566 |
|
|
567 |
+ if ((attr = ippFindAttribute(job->attrs, "security-label",
|
|
568 |
+ IPP_TAG_NAME)) != NULL)
|
|
569 |
+ cupsdSetString(&job->slabel, attr->values[0].string.text);
|
|
570 |
+
|
|
571 |
job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed",
|
|
572 |
IPP_TAG_INTEGER);
|
|
573 |
job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
|
60
|
574 |
@@ -3977,6 +3993,18 @@
|
4
|
575 |
if (!cupsdLoadJob(job))
|
|
576 |
return;
|
|
577 |
|
|
578 |
+ /*
|
|
579 |
+ * Verify that the job sensitivity label is in range of the printer.
|
|
580 |
+ */
|
|
581 |
+ if (cupsdInPrinterLabelRange(job->slabel, printer) == 0) {
|
|
582 |
+ cupsdLogMessage(CUPSD_LOG_ERROR,
|
|
583 |
+ "start_job(): job label outside of printer label range");
|
|
584 |
+ cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT,
|
|
585 |
+ "job label is outside of printer label range");
|
|
586 |
+ cupsdCheckJobs();
|
|
587 |
+ return;
|
|
588 |
+ }
|
|
589 |
+
|
|
590 |
cupsdSetJobState(job, IPP_JOB_PROCESSING, CUPSD_JOB_DEFAULT, NULL);
|
|
591 |
cupsdSetPrinterState(printer, IPP_PRINTER_PROCESSING, 0);
|
|
592 |
|
|
593 |
Index: scheduler/printers.h
|
|
594 |
===================================================================
|
60
|
595 |
--- scheduler/printers.h.orig Tue Mar 30 15:07:33 2010
|
|
596 |
+++ scheduler/printers.h Tue Dec 7 01:30:14 2010
|
|
597 |
@@ -151,6 +151,8 @@
|
4
|
598 |
const char *username);
|
|
599 |
extern void cupsdFreePrinterUsers(cupsd_printer_t *p);
|
|
600 |
extern void cupsdFreeQuotas(cupsd_printer_t *p);
|
|
601 |
+extern int cupsdInPrinterLabelRange(char *slabel,
|
|
602 |
+ cupsd_printer_t *p);
|
|
603 |
extern void cupsdLoadAllPrinters(void);
|
|
604 |
extern void cupsdRenamePrinter(cupsd_printer_t *p,
|
|
605 |
const char *name);
|
|
606 |
Index: scheduler/job.h
|
|
607 |
===================================================================
|
|
608 |
--- scheduler/job.h (revision 8857)
|
|
609 |
+++ scheduler/job.h (working copy)
|
|
610 |
@@ -83,6 +83,8 @@
|
|
611 |
krb5_ccache ccache; /* Kerberos credential cache */
|
|
612 |
char *ccname; /* KRB5CCNAME environment variable */
|
|
613 |
#endif /* HAVE_GSSAPI */
|
|
614 |
+ char *slabel; /* security context for security
|
|
615 |
+ labeled environments */
|
|
616 |
};
|
|
617 |
|
|
618 |
typedef struct cupsd_joblog_s /**** Job log message ****/
|
|
619 |
Index: scheduler/client.c
|
|
620 |
===================================================================
|
60
|
621 |
--- scheduler/client.c.orig Sat Oct 16 21:13:56 2010
|
|
622 |
+++ scheduler/client.c Tue Dec 7 01:30:14 2010
|
|
623 |
@@ -90,7 +90,12 @@
|
4
|
624 |
# include <tcpd.h>
|
|
625 |
#endif /* HAVE_TCPD_H */
|
|
626 |
|
|
627 |
+#ifdef HAVE_TSOL
|
|
628 |
+#include <ucred.h>
|
|
629 |
+#include <tsol/label.h>
|
|
630 |
+#endif /* HAVE_TSOL */
|
|
631 |
|
|
632 |
+
|
|
633 |
/*
|
|
634 |
* Local functions...
|
|
635 |
*/
|
60
|
636 |
@@ -123,7 +128,40 @@
|
4
|
637 |
struct stat *filestats);
|
|
638 |
static void write_pipe(cupsd_client_t *con);
|
|
639 |
|
|
640 |
+#ifdef HAVE_TSOL
|
|
641 |
+/*
|
|
642 |
+ * Retrieve the sensitivity label from the peer connection.
|
|
643 |
+ */
|
|
644 |
+static int
|
|
645 |
+getpeerseclabel(int fd, char **label)
|
|
646 |
+{
|
|
647 |
+ if ((fd < 0) || (label == NULL)) {
|
|
648 |
+ errno = EINVAL;
|
|
649 |
+ return (-1);
|
|
650 |
+ }
|
|
651 |
|
|
652 |
+ *label = NULL; /* default to unlabeled */
|
|
653 |
+
|
|
654 |
+ if (is_system_labeled()) {
|
|
655 |
+ ucred_t *cred = NULL;
|
|
656 |
+ m_label_t *slabel;
|
|
657 |
+
|
|
658 |
+ if (getpeerucred(fd, &cred) == -1)
|
|
659 |
+ return (-1);
|
|
660 |
+
|
|
661 |
+ slabel = ucred_getlabel(cred);
|
|
662 |
+ *label = NULL;
|
|
663 |
+ if (label_to_str(slabel, label, M_INTERNAL, DEF_NAMES) != 0)
|
|
664 |
+ cupsdLogMessage(CUPSD_LOG_ERROR, "getpeercon(%d, 0x%8.8x): %s",
|
|
665 |
+ fd, (int)label, strerror(errno));
|
|
666 |
+ ucred_free(cred);
|
|
667 |
+ }
|
|
668 |
+
|
|
669 |
+ return (0);
|
|
670 |
+}
|
|
671 |
+#endif /* HAVE_TSOL */
|
|
672 |
+
|
|
673 |
+
|
|
674 |
/*
|
|
675 |
* 'cupsdAcceptClient()' - Accept a new client.
|
|
676 |
*/
|
60
|
677 |
@@ -391,6 +429,21 @@
|
4
|
678 |
}
|
|
679 |
#endif /* HAVE_TCPD_H */
|
|
680 |
|
|
681 |
+#if defined(HAVE_TSOL) || defined(HAVE_SELINUX)
|
|
682 |
+ /*
|
|
683 |
+ * Get the sensitivity label from the peer connection.
|
|
684 |
+ */
|
|
685 |
+ if (getpeerseclabel(con->http.fd, &con->slabel))
|
|
686 |
+ {
|
|
687 |
+ cupsdLogMessage(CUPSD_LOG_ERROR,
|
|
688 |
+ "cupsdAcceptClient: failed to retrieve label from peer: %s",
|
|
689 |
+ con->http.hostname);
|
|
690 |
+ con->slabel = NULL;
|
|
691 |
+ }
|
|
692 |
+ else
|
|
693 |
+ cupsdLogMessage(CUPSD_LOG_INFO, "cupsdAcceptClient: label=%s", con->slabel);
|
|
694 |
+#endif /* HAVE_TSOL || HAVE_SELINUX */
|
|
695 |
+
|
|
696 |
#ifdef AF_INET6
|
|
697 |
if (con->http.hostaddr->addr.sa_family == AF_INET6)
|
|
698 |
cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAcceptClient: %d from %s:%d (IPv6)",
|
60
|
699 |
@@ -680,6 +733,12 @@
|
4
|
700 |
}
|
|
701 |
}
|
|
702 |
|
|
703 |
+ if (con->slabel != NULL)
|
|
704 |
+ {
|
|
705 |
+ free(con->slabel);
|
|
706 |
+ con->slabel = NULL;
|
|
707 |
+ }
|
|
708 |
+
|
|
709 |
if (!partial)
|
|
710 |
{
|
|
711 |
/*
|
|
712 |
Index: scheduler/client.h
|
|
713 |
===================================================================
|
|
714 |
--- scheduler/client.h (revision 8857)
|
|
715 |
+++ scheduler/client.h (working copy)
|
|
716 |
@@ -64,6 +64,8 @@
|
|
717 |
#ifdef HAVE_AUTHORIZATION_H
|
|
718 |
AuthorizationRef authref; /* Authorization ref */
|
|
719 |
#endif /* HAVE_AUTHORIZATION_H */
|
|
720 |
+ char *slabel; /* security context for security
|
|
721 |
+ labeled environments */
|
|
722 |
};
|
|
723 |
|
|
724 |
#define HTTP(con) &((con)->http)
|
|
725 |
Index: scheduler/cupsd.h
|
|
726 |
===================================================================
|
|
727 |
--- scheduler/cupsd.h (revision 8857)
|
|
728 |
+++ scheduler/cupsd.h (working copy)
|
|
729 |
@@ -50,7 +50,19 @@
|
|
730 |
# include <CoreFoundation/CoreFoundation.h>
|
|
731 |
#endif /* HAVE_CDSASSL */
|
|
732 |
|
|
733 |
+#if defined(HAVE_TSOL)
|
|
734 |
+#include <tsol/label.h>
|
|
735 |
+#endif /* HAVE_TSOL */
|
|
736 |
|
|
737 |
+#if defined(HAVE_SELINUX)
|
|
738 |
+#include <selinux/selinux.h>
|
|
739 |
+#include <selinux/context.h>
|
|
740 |
+#include <selinux/avc.h>
|
|
741 |
+#include <selinux/flask.h>
|
|
742 |
+#include <selinux/av_permissions.h>
|
|
743 |
+#include <selinux/get_context_list.h>
|
|
744 |
+#endif /* HAVE_SELINUX */
|
|
745 |
+
|
|
746 |
/*
|
|
747 |
* Some OS's don't have hstrerror(), most notably Solaris...
|
|
748 |
*/
|