22cc213
--- cups-1.2.4-orig/config.h.in	2006-06-05 14:42:53.000000000 -0400
22cc213
+++ cups-1.2.4/config.h.in	2006-09-28 16:31:29.000000000 -0400
5dd9863
@@ -443,6 +443,13 @@
5dd9863
 #undef HAVE_APPLETALK_AT_PROTO_H
5dd9863
 
5dd9863
 
5dd9863
+/*
5dd9863
+ * Are we trying to meet LSPP requirements?
5dd9863
+ */
75d0e82
+
5dd9863
+#undef WITH_LSPP
75d0e82
+
5dd9863
+
5dd9863
 #endif /* !_CUPS_CONFIG_H_ */
5dd9863
 
5dd9863
 /*
22cc213
--- cups-1.2.4-orig/configure.in	2006-08-04 12:51:58.000000000 -0400
22cc213
+++ cups-1.2.4/configure.in	2006-09-28 16:31:29.000000000 -0400
75d0e82
@@ -47,6 +47,8 @@
75d0e82
 sinclude(config-scripts/cups-pdf.m4)
75d0e82
 sinclude(config-scripts/cups-scripting.m4)
75d0e82
 
75d0e82
+sinclude(config-scripts/cups-lspp.m4)
75d0e82
+
75d0e82
 INSTALL_LANGUAGES=""
75d0e82
 UNINSTALL_LANGUAGES=""
75d0e82
 LANGFILES=""
22cc213
--- cups-1.2.4-orig/config-scripts/cups-lspp.m4	1969-12-31 19:00:00.000000000 -0500
22cc213
+++ cups-1.2.4/config-scripts/cups-lspp.m4	2006-09-28 16:31:29.000000000 -0400
9ad376b
@@ -0,0 +1,36 @@
9ad376b
+dnl
9ad376b
+dnl   LSPP code for the Common UNIX Printing System (CUPS).
9ad376b
+dnl
9ad376b
+dnl   Copyright 2005-2006 by Hewlett-Packard Development Company, L.P.
9ad376b
+dnl
9ad376b
+dnl   This program is free software; you can redistribute it and/or modify
9ad376b
+dnl   it under the terms of the GNU General Public License as published by
9ad376b
+dnl   the Free Software Foundation; version 2.
9ad376b
+dnl
9ad376b
+dnl   This program is distributed in the hope that it will be useful, but
9ad376b
+dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
9ad376b
+dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9ad376b
+dnl   General Public License for more details.
9ad376b
+dnl
9ad376b
+dnl   You should have received a copy of the GNU General Public License
9ad376b
+dnl   along with this program; if not, write to the Free Software Foundation,
9ad376b
+dnl   Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
9ad376b
+dnl
9ad376b
+
9ad376b
+dnl Are we trying to meet LSPP requirements
9ad376b
+AC_ARG_ENABLE(lspp, [  --enable-lspp           turn on auditing and label support, default=no])
9ad376b
+
9ad376b
+if test x"$enable_lspp" != xno; then
9ad376b
+    case "$uname" in
9ad376b
+        Linux)
9ad376b
+            AC_CHECK_LIB(audit,audit_log_user_message, [LIBAUDIT="-laudit" AC_SUBST(LIBAUDIT)])
9ad376b
+            AC_CHECK_HEADER(libaudit.h)
9ad376b
+            AC_CHECK_LIB(selinux,getpeercon, [LIBSELINUX="-lselinux" AC_SUBST(LIBSELINUX)])
9ad376b
+            AC_CHECK_HEADER(selinux/selinux.h)
9ad376b
+            AC_DEFINE(WITH_LSPP)
9ad376b
+            ;;
9ad376b
+        *)
9ad376b
+            # All others
9ad376b
+            ;;
9ad376b
+    esac
9ad376b
+fi
22cc213
--- cups-1.2.4-orig/cups/cups.h	2006-09-07 15:49:34.000000000 -0400
22cc213
+++ cups-1.2.4/cups/cups.h	2006-09-28 16:31:29.000000000 -0400
22cc213
@@ -24,6 +24,9 @@
5dd9863
  *   This file is subject to the Apple OS-Developed Software exception.
5dd9863
  */
5dd9863
 
5dd9863
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
22cc213
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
5dd9863
+
5dd9863
 #ifndef _CUPS_CUPS_H_
5dd9863
 #  define _CUPS_CUPS_H_
5dd9863
 
22cc213
@@ -68,6 +71,12 @@
5dd9863
 #  define CUPS_DATE_ANY		-1
5dd9863
 
5dd9863
 
5dd9863
+# ifdef WITH_LSPP
5dd9863
+# define MLS_CONFIG "mls"
5dd9863
+# define TE_CONFIG "te"
5dd9863
+# define SELINUX_CONFIG "SELinux"
5dd9863
+# define UNKNOWN_SL "UNKNOWN SL"
5dd9863
+# endif /* WITH_LSPP */
5dd9863
 /*
5dd9863
  * Types and structures...
5dd9863
  */
22cc213
--- cups-1.2.4-orig/data/Makefile	2006-03-18 22:23:34.000000000 -0500
22cc213
+++ cups-1.2.4/data/Makefile	2006-09-28 16:31:29.000000000 -0400
5dd9863
@@ -34,7 +34,10 @@
5dd9863
 		secret \
5dd9863
 		standard \
5dd9863
 		topsecret \
5dd9863
-		unclassified
5dd9863
+		unclassified \
5dd9863
+		selinux \
5dd9863
+		mls \
5dd9863
+		te
5dd9863
 
5dd9863
 CHARMAPS =	\
5dd9863
 		euc-cn.txt \
22cc213
--- cups-1.2.4-orig/data/mls	1969-12-31 19:00:00.000000000 -0500
22cc213
+++ cups-1.2.4/data/mls	2006-09-28 16:31:29.000000000 -0400
75d0e82
@@ -0,0 +1,277 @@
75d0e82
+%!PS-Adobe-3.0
75d0e82
+%%BoundingBox: 0 0 612 792
75d0e82
+%%Pages: 1
75d0e82
+%%LanguageLevel: 1
75d0e82
+%%DocumentData: Clean7Bit
75d0e82
+%%DocumentSuppliedResources: procset bannerprint/1.0
75d0e82
+%%DocumentNeededResources: font Helvetica Helvetica-Bold Times-Roman
75d0e82
+%%Creator: Michael Sweet, Easy Software Products
75d0e82
+%%CreationDate: May 10, 2000
75d0e82
+%%Title: Test Page
75d0e82
+%%EndComments
75d0e82
+%%BeginProlog
75d0e82
+%%BeginResource procset bannerprint 1.1 0
75d0e82
+%
75d0e82
+%   PostScript banner page for the Common UNIX Printing System ("CUPS").
75d0e82
+%
75d0e82
+%   Copyright 1993-2005 by Easy Software Products
75d0e82
+%
75d0e82
+%   These coded instructions, statements, and computer programs are the
75d0e82
+%   property of Easy Software Products and are protected by Federal
75d0e82
+%   copyright law.  Distribution and use rights are outlined in the file
75d0e82
+%   "LICENSE.txt" which should have been included with this file.  If this
75d0e82
+%   file is missing or damaged please contact Easy Software Products
75d0e82
+%   at:
75d0e82
+%
75d0e82
+%       Attn: CUPS Licensing Information
75d0e82
+%       Easy Software Products
75d0e82
+%       44141 Airport View Drive, Suite 204
75d0e82
+%       Hollywood, Maryland 20636 USA
75d0e82
+%
75d0e82
+%       Voice: (301) 373-9600
75d0e82
+%       EMail: cups-info@cups.org
75d0e82
+%         WWW: http://www.cups.org
75d0e82
+%
75d0e82
+/CENTER {			% Draw centered text
75d0e82
+				% (name) CENTER -
75d0e82
+  dup stringwidth pop		% Get the width of the string
75d0e82
+  0.5 mul neg 0 rmoveto		% Shift left 1/2 of the distance
75d0e82
+  show				% Show the string
75d0e82
+} bind def
75d0e82
+/RIGHT {			% Draw right-justified text
75d0e82
+				% (name) RIGHT -
75d0e82
+  dup stringwidth pop		% Get the width of the string
75d0e82
+  neg 0 rmoveto			% Shift left the entire distance
75d0e82
+  show				% Show the string
75d0e82
+} bind def
75d0e82
+/NUMBER {			% Draw a number
75d0e82
+				% power n NUMBER -
75d0e82
+  1 index 1 eq {		% power == 1?
75d0e82
+    round cvi exch pop		% Convert "n" to integer
75d0e82
+  } {
75d0e82
+    1 index mul round exch div	% Truncate extra decimal places
75d0e82
+  } ifelse
75d0e82
+  100 string cvs show		% Convert to a string and show it...
75d0e82
+} bind def
75d0e82
+/CUPSLOGO {			% Draw the CUPS logo
75d0e82
+				% height CUPSLOGO
75d0e82
+  % Start with a big C...
75d0e82
+  /Helvetica findfont 1 index scalefont setfont
75d0e82
+  0 setgray
75d0e82
+  0 0 moveto
75d0e82
+  (C) show
75d0e82
+
75d0e82
+  % Then "UNIX Printing System" much smaller...
75d0e82
+  /Helvetica-Bold findfont 1 index 9 div scalefont setfont
75d0e82
+  0.25 mul
75d0e82
+  dup dup 2.0 mul moveto
75d0e82
+  (UNIX) show
75d0e82
+  dup dup 1.6 mul moveto
75d0e82
+  (Printing) show
75d0e82
+  dup 1.2 mul moveto
75d0e82
+  (System) show
75d0e82
+} bind def
75d0e82
+/ESPLOGO {			% Draw the ESP logo
75d0e82
+				% height ESPLOGO
75d0e82
+  % Compute the size of the logo...
75d0e82
+  0 0
75d0e82
+  2 index 1.5 mul 3 index
75d0e82
+
75d0e82
+  % Do the "metallic" fill from 10% black to 40% black...
75d0e82
+  1 -0.001 0 {
75d0e82
+    dup			% loopval
75d0e82
+    -0.15 mul		% loopval * -0.15
75d0e82
+    0.9 add		% 0.9 - loopval * 0.15
75d0e82
+    setgray		% set gray shade
75d0e82
+
75d0e82
+    0			% x
75d0e82
+    1 index neg		% loopval
75d0e82
+    1 add		% 1 - loopval
75d0e82
+    3 index		% height
75d0e82
+    mul			% height * (1 - loopval)
75d0e82
+    moveto		% starting point
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    3 index		% width
75d0e82
+    mul			% loopval * width
75d0e82
+    2 index		% height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    0			% x
75d0e82
+    2 index		% height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    closepath
75d0e82
+    fill
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    0.15 mul		% loopval * 0.15
75d0e82
+    0.6 add		% 0.6 + loopval * 0.15
75d0e82
+    setgray
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    neg 1 add		% 1 - loopval
75d0e82
+    3 index		% width
75d0e82
+    mul			% (1 - loopval) * width
75d0e82
+    0			% y
75d0e82
+    moveto		% Starting point
75d0e82
+
75d0e82
+    2 index		% width
75d0e82
+    exch		% loopval
75d0e82
+    2 index		% height
75d0e82
+    mul			% loopval * height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    1 index		% width
75d0e82
+    0			% y
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    closepath
75d0e82
+    fill
75d0e82
+  } for
75d0e82
+
75d0e82
+  0 setgray rectstroke
75d0e82
+
75d0e82
+  /Helvetica-BoldOblique findfont 1 index 3 div scalefont setfont
75d0e82
+  dup 40 div
75d0e82
+
75d0e82
+  dup 4 mul 1 index 25 mul moveto (E) show
75d0e82
+  dup 10 mul 1 index 15 mul moveto (S) show
75d0e82
+  dup 16 mul 1 index 5 mul moveto (P) show
75d0e82
+
75d0e82
+  /Helvetica-BoldOblique findfont 2 index 5 div scalefont setfont
75d0e82
+  dup 14 mul 1 index 29 mul moveto (asy) show
75d0e82
+  dup 20 mul 1 index 19 mul moveto (oftware) show
75d0e82
+  dup 26 mul 1 index 9 mul moveto (roducts) show
75d0e82
+
75d0e82
+  pop
75d0e82
+} bind def
75d0e82
+%%EndResource
75d0e82
+%%EndProlog
75d0e82
+%%Page: 1 1
75d0e82
+gsave
75d0e82
+
75d0e82
+  % Determine the imageable area and device resolution...
75d0e82
+  initclip newpath clippath pathbbox	% Get bounding rectangle
75d0e82
+  72 div /pageTop exch def		% Get top margin in inches
75d0e82
+  72 div /pageRight exch def		% Get right margin in inches
75d0e82
+  72 div /pageBottom exch def		% Get bottom margin in inches
75d0e82
+  72 div /pageLeft exch def		% Get left margin in inches
75d0e82
+
75d0e82
+  /pageWidth pageRight pageLeft sub def	% pageWidth = pageRight - pageLeft
75d0e82
+  /pageHeight pageTop pageBottom sub def% pageHeight = pageTop - pageBottom
75d0e82
+
75d0e82
+  /boxWidth				% width of text box
75d0e82
+  pageWidth pageHeight lt
75d0e82
+  { pageWidth 54 mul }
75d0e82
+  { pageHeight 42 mul }
75d0e82
+  ifelse def
75d0e82
+
75d0e82
+  newpath				% Clear bounding path
75d0e82
+
75d0e82
+  % Create fonts...
75d0e82
+  /bigFont /Helvetica-Bold findfont	% bigFont = Helvetica-Bold
75d0e82
+  pageHeight 3 mul scalefont def	% size = pageHeight * 3 (nominally 33)
75d0e82
+
75d0e82
+  /mediumFont /Helvetica findfont	% mediumFont = Helvetica
75d0e82
+  pageHeight 1.5 mul scalefont def	% size = pageHeight * 1.5 (nominally 16.5)
75d0e82
+
75d0e82
+  % Offset page to account for lower-left margin...
75d0e82
+  pageLeft 72 mul
75d0e82
+  pageBottom 72 mul
75d0e82
+  translate
75d0e82
+
75d0e82
+  % Draw the label at the top and bottom...
75d0e82
+  0 setgray				% Color
75d0e82
+
75d0e82
+  pageWidth 36 mul			% Center of page
75d0e82
+  pageHeight 72 mul			% Top of page
75d0e82
+  pageWidth -7 mul add			% - 2 lines
75d0e82
+  moveto				% Position text
75d0e82
+  bigFont setfont			% Font
75d0e82
+  ({mls-label}) CENTER		% Show text centered
75d0e82
+
75d0e82
+  pageWidth 36 mul			% Center of page
75d0e82
+  pageHeight 6 mul			% Bottom of page
75d0e82
+  moveto				% Position text
75d0e82
+  bigFont setfont			% Font
75d0e82
+  ({mls-label}) CENTER		% Show text centered
75d0e82
+
75d0e82
+  % Job information box...
75d0e82
+  pageWidth 36 mul 9 add		% x = pageWidth * 1/2 * 72 + 9
75d0e82
+  boxWidth 0.5 mul sub			% x-= 1/2 box width
75d0e82
+  pageHeight 30 mul 9 sub		% y = pageHeight * 1/2 * 72 - 9
75d0e82
+  boxWidth				% w = box width
75d0e82
+  pageHeight 14 mul			% h = pageHeight * 1/2 * 72
75d0e82
+  0.5 setgray rectfill			% Draw a shadow
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  boxWidth 0.5 mul sub			% x-= 1/2 box width
75d0e82
+  pageHeight 30 mul			% y = pageHeight * 1/4 * 72
75d0e82
+  boxWidth				% w = box width
75d0e82
+  pageHeight 14 mul			% h = pageHeight * 1/2 * 72
75d0e82
+
75d0e82
+  4 copy 1 setgray rectfill		% Clear the box to white
75d0e82
+  0 setgray rectstroke			% Draw a black box around it...
75d0e82
+
75d0e82
+  % Job information text...
75d0e82
+  mediumFont setfont			% Medium sized font
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight 5 mul add			% y += 2 lines
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Job ID: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({printer-name}-{job-id}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight 2 mul add			% y += 1 line
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Title: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({job-name}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight -1 mul add			% y -= 1 line
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Requesting User: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({job-originating-user-name}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight -4 mul add			% y -= 2 lines
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Billing Info: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({?job-billing}) show
75d0e82
+
75d0e82
+  % Then the CUPS logo....
75d0e82
+  gsave
75d0e82
+    pageWidth 4 mul
75d0e82
+    pageWidth 6 mul
75d0e82
+    translate
75d0e82
+    pageWidth 9 mul CUPSLOGO
75d0e82
+  grestore
75d0e82
+
75d0e82
+  % And the ESP logo....
75d0e82
+  gsave
75d0e82
+    pageWidth 59 mul
75d0e82
+    pageWidth 6 mul
75d0e82
+    translate
75d0e82
+    pageWidth 6 mul ESPLOGO
75d0e82
+  grestore
75d0e82
+% Show the page...
75d0e82
+grestore
75d0e82
+showpage
75d0e82
+%
75d0e82
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
75d0e82
+%
75d0e82
+%%EOF
22cc213
--- cups-1.2.4-orig/data/selinux	1969-12-31 19:00:00.000000000 -0500
22cc213
+++ cups-1.2.4/data/selinux	2006-09-28 16:31:29.000000000 -0400
75d0e82
@@ -0,0 +1,277 @@
75d0e82
+%!PS-Adobe-3.0
75d0e82
+%%BoundingBox: 0 0 612 792
75d0e82
+%%Pages: 1
75d0e82
+%%LanguageLevel: 1
75d0e82
+%%DocumentData: Clean7Bit
75d0e82
+%%DocumentSuppliedResources: procset bannerprint/1.0
75d0e82
+%%DocumentNeededResources: font Helvetica Helvetica-Bold Times-Roman
75d0e82
+%%Creator: Michael Sweet, Easy Software Products
75d0e82
+%%CreationDate: May 10, 2000
75d0e82
+%%Title: Test Page
75d0e82
+%%EndComments
75d0e82
+%%BeginProlog
75d0e82
+%%BeginResource procset bannerprint 1.1 0
75d0e82
+%
75d0e82
+%   PostScript banner page for the Common UNIX Printing System ("CUPS").
75d0e82
+%
75d0e82
+%   Copyright 1993-2005 by Easy Software Products
75d0e82
+%
75d0e82
+%   These coded instructions, statements, and computer programs are the
75d0e82
+%   property of Easy Software Products and are protected by Federal
75d0e82
+%   copyright law.  Distribution and use rights are outlined in the file
75d0e82
+%   "LICENSE.txt" which should have been included with this file.  If this
75d0e82
+%   file is missing or damaged please contact Easy Software Products
75d0e82
+%   at:
75d0e82
+%
75d0e82
+%       Attn: CUPS Licensing Information
75d0e82
+%       Easy Software Products
75d0e82
+%       44141 Airport View Drive, Suite 204
75d0e82
+%       Hollywood, Maryland 20636 USA
75d0e82
+%
75d0e82
+%       Voice: (301) 373-9600
75d0e82
+%       EMail: cups-info@cups.org
75d0e82
+%         WWW: http://www.cups.org
75d0e82
+%
75d0e82
+/CENTER {			% Draw centered text
75d0e82
+				% (name) CENTER -
75d0e82
+  dup stringwidth pop		% Get the width of the string
75d0e82
+  0.5 mul neg 0 rmoveto		% Shift left 1/2 of the distance
75d0e82
+  show				% Show the string
75d0e82
+} bind def
75d0e82
+/RIGHT {			% Draw right-justified text
75d0e82
+				% (name) RIGHT -
75d0e82
+  dup stringwidth pop		% Get the width of the string
75d0e82
+  neg 0 rmoveto			% Shift left the entire distance
75d0e82
+  show				% Show the string
75d0e82
+} bind def
75d0e82
+/NUMBER {			% Draw a number
75d0e82
+				% power n NUMBER -
75d0e82
+  1 index 1 eq {		% power == 1?
75d0e82
+    round cvi exch pop		% Convert "n" to integer
75d0e82
+  } {
75d0e82
+    1 index mul round exch div	% Truncate extra decimal places
75d0e82
+  } ifelse
75d0e82
+  100 string cvs show		% Convert to a string and show it...
75d0e82
+} bind def
75d0e82
+/CUPSLOGO {			% Draw the CUPS logo
75d0e82
+				% height CUPSLOGO
75d0e82
+  % Start with a big C...
75d0e82
+  /Helvetica findfont 1 index scalefont setfont
75d0e82
+  0 setgray
75d0e82
+  0 0 moveto
75d0e82
+  (C) show
75d0e82
+
75d0e82
+  % Then "UNIX Printing System" much smaller...
75d0e82
+  /Helvetica-Bold findfont 1 index 9 div scalefont setfont
75d0e82
+  0.25 mul
75d0e82
+  dup dup 2.0 mul moveto
75d0e82
+  (UNIX) show
75d0e82
+  dup dup 1.6 mul moveto
75d0e82
+  (Printing) show
75d0e82
+  dup 1.2 mul moveto
75d0e82
+  (System) show
75d0e82
+} bind def
75d0e82
+/ESPLOGO {			% Draw the ESP logo
75d0e82
+				% height ESPLOGO
75d0e82
+  % Compute the size of the logo...
75d0e82
+  0 0
75d0e82
+  2 index 1.5 mul 3 index
75d0e82
+
75d0e82
+  % Do the "metallic" fill from 10% black to 40% black...
75d0e82
+  1 -0.001 0 {
75d0e82
+    dup			% loopval
75d0e82
+    -0.15 mul		% loopval * -0.15
75d0e82
+    0.9 add		% 0.9 - loopval * 0.15
75d0e82
+    setgray		% set gray shade
75d0e82
+
75d0e82
+    0			% x
75d0e82
+    1 index neg		% loopval
75d0e82
+    1 add		% 1 - loopval
75d0e82
+    3 index		% height
75d0e82
+    mul			% height * (1 - loopval)
75d0e82
+    moveto		% starting point
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    3 index		% width
75d0e82
+    mul			% loopval * width
75d0e82
+    2 index		% height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    0			% x
75d0e82
+    2 index		% height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    closepath
75d0e82
+    fill
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    0.15 mul		% loopval * 0.15
75d0e82
+    0.6 add		% 0.6 + loopval * 0.15
75d0e82
+    setgray
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    neg 1 add		% 1 - loopval
75d0e82
+    3 index		% width
75d0e82
+    mul			% (1 - loopval) * width
75d0e82
+    0			% y
75d0e82
+    moveto		% Starting point
75d0e82
+
75d0e82
+    2 index		% width
75d0e82
+    exch		% loopval
75d0e82
+    2 index		% height
75d0e82
+    mul			% loopval * height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    1 index		% width
75d0e82
+    0			% y
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    closepath
75d0e82
+    fill
75d0e82
+  } for
75d0e82
+
75d0e82
+  0 setgray rectstroke
75d0e82
+
75d0e82
+  /Helvetica-BoldOblique findfont 1 index 3 div scalefont setfont
75d0e82
+  dup 40 div
75d0e82
+
75d0e82
+  dup 4 mul 1 index 25 mul moveto (E) show
75d0e82
+  dup 10 mul 1 index 15 mul moveto (S) show
75d0e82
+  dup 16 mul 1 index 5 mul moveto (P) show
75d0e82
+
75d0e82
+  /Helvetica-BoldOblique findfont 2 index 5 div scalefont setfont
75d0e82
+  dup 14 mul 1 index 29 mul moveto (asy) show
75d0e82
+  dup 20 mul 1 index 19 mul moveto (oftware) show
75d0e82
+  dup 26 mul 1 index 9 mul moveto (roducts) show
75d0e82
+
75d0e82
+  pop
75d0e82
+} bind def
75d0e82
+%%EndResource
75d0e82
+%%EndProlog
75d0e82
+%%Page: 1 1
75d0e82
+gsave
75d0e82
+
75d0e82
+  % Determine the imageable area and device resolution...
75d0e82
+  initclip newpath clippath pathbbox	% Get bounding rectangle
75d0e82
+  72 div /pageTop exch def		% Get top margin in inches
75d0e82
+  72 div /pageRight exch def		% Get right margin in inches
75d0e82
+  72 div /pageBottom exch def		% Get bottom margin in inches
75d0e82
+  72 div /pageLeft exch def		% Get left margin in inches
75d0e82
+
75d0e82
+  /pageWidth pageRight pageLeft sub def	% pageWidth = pageRight - pageLeft
75d0e82
+  /pageHeight pageTop pageBottom sub def% pageHeight = pageTop - pageBottom
75d0e82
+
75d0e82
+  /boxWidth				% width of text box
75d0e82
+  pageWidth pageHeight lt
75d0e82
+  { pageWidth 54 mul }
75d0e82
+  { pageHeight 42 mul }
75d0e82
+  ifelse def
75d0e82
+
75d0e82
+  newpath				% Clear bounding path
75d0e82
+
75d0e82
+  % Create fonts...
75d0e82
+  /bigFont /Helvetica-Bold findfont	% bigFont = Helvetica-Bold
75d0e82
+  pageHeight 3 mul scalefont def	% size = pageHeight * 3 (nominally 33)
75d0e82
+
75d0e82
+  /mediumFont /Helvetica findfont	% mediumFont = Helvetica
75d0e82
+  pageHeight 1.5 mul scalefont def	% size = pageHeight * 1.5 (nominally 16.5)
75d0e82
+
75d0e82
+  % Offset page to account for lower-left margin...
75d0e82
+  pageLeft 72 mul
75d0e82
+  pageBottom 72 mul
75d0e82
+  translate
75d0e82
+
75d0e82
+  % Draw the label at the top and bottom...
75d0e82
+  0 setgray				% Color
75d0e82
+
75d0e82
+  pageWidth 36 mul			% Center of page
75d0e82
+  pageHeight 72 mul			% Top of page
75d0e82
+  pageWidth -7 mul add			% - 2 lines
75d0e82
+  moveto				% Position text
75d0e82
+  bigFont setfont			% Font
75d0e82
+  ({mls-label}) CENTER		% Show text centered
75d0e82
+
75d0e82
+  pageWidth 36 mul			% Center of page
75d0e82
+  pageHeight 6 mul			% Bottom of page
75d0e82
+  moveto				% Position text
75d0e82
+  bigFont setfont			% Font
75d0e82
+  ({mls-label}) CENTER		% Show text centered
75d0e82
+
75d0e82
+  % Job information box...
75d0e82
+  pageWidth 36 mul 9 add		% x = pageWidth * 1/2 * 72 + 9
75d0e82
+  boxWidth 0.5 mul sub			% x-= 1/2 box width
75d0e82
+  pageHeight 30 mul 9 sub		% y = pageHeight * 1/2 * 72 - 9
75d0e82
+  boxWidth				% w = box width
75d0e82
+  pageHeight 14 mul			% h = pageHeight * 1/2 * 72
75d0e82
+  0.5 setgray rectfill			% Draw a shadow
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  boxWidth 0.5 mul sub			% x-= 1/2 box width
75d0e82
+  pageHeight 30 mul			% y = pageHeight * 1/4 * 72
75d0e82
+  boxWidth				% w = box width
75d0e82
+  pageHeight 14 mul			% h = pageHeight * 1/2 * 72
75d0e82
+
75d0e82
+  4 copy 1 setgray rectfill		% Clear the box to white
75d0e82
+  0 setgray rectstroke			% Draw a black box around it...
75d0e82
+
75d0e82
+  % Job information text...
75d0e82
+  mediumFont setfont			% Medium sized font
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight 5 mul add			% y += 2 lines
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Job ID: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({printer-name}-{job-id}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight 2 mul add			% y += 1 line
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Title: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({job-name}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight -1 mul add			% y -= 1 line
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Requesting User: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({job-originating-user-name}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight -4 mul add			% y -= 2 lines
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Billing Info: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({?job-billing}) show
75d0e82
+
75d0e82
+  % Then the CUPS logo....
75d0e82
+  gsave
75d0e82
+    pageWidth 4 mul
75d0e82
+    pageWidth 6 mul
75d0e82
+    translate
75d0e82
+    pageWidth 9 mul CUPSLOGO
75d0e82
+  grestore
75d0e82
+
75d0e82
+  % And the ESP logo....
75d0e82
+  gsave
75d0e82
+    pageWidth 59 mul
75d0e82
+    pageWidth 6 mul
75d0e82
+    translate
75d0e82
+    pageWidth 6 mul ESPLOGO
75d0e82
+  grestore
75d0e82
+% Show the page...
75d0e82
+grestore
75d0e82
+showpage
75d0e82
+%
75d0e82
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
75d0e82
+%
75d0e82
+%%EOF
22cc213
--- cups-1.2.4-orig/data/te	1969-12-31 19:00:00.000000000 -0500
22cc213
+++ cups-1.2.4/data/te	2006-09-28 16:31:29.000000000 -0400
75d0e82
@@ -0,0 +1,277 @@
75d0e82
+%!PS-Adobe-3.0
75d0e82
+%%BoundingBox: 0 0 612 792
75d0e82
+%%Pages: 1
75d0e82
+%%LanguageLevel: 1
75d0e82
+%%DocumentData: Clean7Bit
75d0e82
+%%DocumentSuppliedResources: procset bannerprint/1.0
75d0e82
+%%DocumentNeededResources: font Helvetica Helvetica-Bold Times-Roman
75d0e82
+%%Creator: Michael Sweet, Easy Software Products
75d0e82
+%%CreationDate: May 10, 2000
75d0e82
+%%Title: Test Page
75d0e82
+%%EndComments
75d0e82
+%%BeginProlog
75d0e82
+%%BeginResource procset bannerprint 1.1 0
75d0e82
+%
75d0e82
+%   PostScript banner page for the Common UNIX Printing System ("CUPS").
75d0e82
+%
75d0e82
+%   Copyright 1993-2005 by Easy Software Products
75d0e82
+%
75d0e82
+%   These coded instructions, statements, and computer programs are the
75d0e82
+%   property of Easy Software Products and are protected by Federal
75d0e82
+%   copyright law.  Distribution and use rights are outlined in the file
75d0e82
+%   "LICENSE.txt" which should have been included with this file.  If this
75d0e82
+%   file is missing or damaged please contact Easy Software Products
75d0e82
+%   at:
75d0e82
+%
75d0e82
+%       Attn: CUPS Licensing Information
75d0e82
+%       Easy Software Products
75d0e82
+%       44141 Airport View Drive, Suite 204
75d0e82
+%       Hollywood, Maryland 20636 USA
75d0e82
+%
75d0e82
+%       Voice: (301) 373-9600
75d0e82
+%       EMail: cups-info@cups.org
75d0e82
+%         WWW: http://www.cups.org
75d0e82
+%
75d0e82
+/CENTER {			% Draw centered text
75d0e82
+				% (name) CENTER -
75d0e82
+  dup stringwidth pop		% Get the width of the string
75d0e82
+  0.5 mul neg 0 rmoveto		% Shift left 1/2 of the distance
75d0e82
+  show				% Show the string
75d0e82
+} bind def
75d0e82
+/RIGHT {			% Draw right-justified text
75d0e82
+				% (name) RIGHT -
75d0e82
+  dup stringwidth pop		% Get the width of the string
75d0e82
+  neg 0 rmoveto			% Shift left the entire distance
75d0e82
+  show				% Show the string
75d0e82
+} bind def
75d0e82
+/NUMBER {			% Draw a number
75d0e82
+				% power n NUMBER -
75d0e82
+  1 index 1 eq {		% power == 1?
75d0e82
+    round cvi exch pop		% Convert "n" to integer
75d0e82
+  } {
75d0e82
+    1 index mul round exch div	% Truncate extra decimal places
75d0e82
+  } ifelse
75d0e82
+  100 string cvs show		% Convert to a string and show it...
75d0e82
+} bind def
75d0e82
+/CUPSLOGO {			% Draw the CUPS logo
75d0e82
+				% height CUPSLOGO
75d0e82
+  % Start with a big C...
75d0e82
+  /Helvetica findfont 1 index scalefont setfont
75d0e82
+  0 setgray
75d0e82
+  0 0 moveto
75d0e82
+  (C) show
75d0e82
+
75d0e82
+  % Then "UNIX Printing System" much smaller...
75d0e82
+  /Helvetica-Bold findfont 1 index 9 div scalefont setfont
75d0e82
+  0.25 mul
75d0e82
+  dup dup 2.0 mul moveto
75d0e82
+  (UNIX) show
75d0e82
+  dup dup 1.6 mul moveto
75d0e82
+  (Printing) show
75d0e82
+  dup 1.2 mul moveto
75d0e82
+  (System) show
75d0e82
+} bind def
75d0e82
+/ESPLOGO {			% Draw the ESP logo
75d0e82
+				% height ESPLOGO
75d0e82
+  % Compute the size of the logo...
75d0e82
+  0 0
75d0e82
+  2 index 1.5 mul 3 index
75d0e82
+
75d0e82
+  % Do the "metallic" fill from 10% black to 40% black...
75d0e82
+  1 -0.001 0 {
75d0e82
+    dup			% loopval
75d0e82
+    -0.15 mul		% loopval * -0.15
75d0e82
+    0.9 add		% 0.9 - loopval * 0.15
75d0e82
+    setgray		% set gray shade
75d0e82
+
75d0e82
+    0			% x
75d0e82
+    1 index neg		% loopval
75d0e82
+    1 add		% 1 - loopval
75d0e82
+    3 index		% height
75d0e82
+    mul			% height * (1 - loopval)
75d0e82
+    moveto		% starting point
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    3 index		% width
75d0e82
+    mul			% loopval * width
75d0e82
+    2 index		% height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    0			% x
75d0e82
+    2 index		% height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    closepath
75d0e82
+    fill
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    0.15 mul		% loopval * 0.15
75d0e82
+    0.6 add		% 0.6 + loopval * 0.15
75d0e82
+    setgray
75d0e82
+
75d0e82
+    dup			% loopval
75d0e82
+    neg 1 add		% 1 - loopval
75d0e82
+    3 index		% width
75d0e82
+    mul			% (1 - loopval) * width
75d0e82
+    0			% y
75d0e82
+    moveto		% Starting point
75d0e82
+
75d0e82
+    2 index		% width
75d0e82
+    exch		% loopval
75d0e82
+    2 index		% height
75d0e82
+    mul			% loopval * height
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    1 index		% width
75d0e82
+    0			% y
75d0e82
+    lineto		% Next point
75d0e82
+
75d0e82
+    closepath
75d0e82
+    fill
75d0e82
+  } for
75d0e82
+
75d0e82
+  0 setgray rectstroke
75d0e82
+
75d0e82
+  /Helvetica-BoldOblique findfont 1 index 3 div scalefont setfont
75d0e82
+  dup 40 div
75d0e82
+
75d0e82
+  dup 4 mul 1 index 25 mul moveto (E) show
75d0e82
+  dup 10 mul 1 index 15 mul moveto (S) show
75d0e82
+  dup 16 mul 1 index 5 mul moveto (P) show
75d0e82
+
75d0e82
+  /Helvetica-BoldOblique findfont 2 index 5 div scalefont setfont
75d0e82
+  dup 14 mul 1 index 29 mul moveto (asy) show
75d0e82
+  dup 20 mul 1 index 19 mul moveto (oftware) show
75d0e82
+  dup 26 mul 1 index 9 mul moveto (roducts) show
75d0e82
+
75d0e82
+  pop
75d0e82
+} bind def
75d0e82
+%%EndResource
75d0e82
+%%EndProlog
75d0e82
+%%Page: 1 1
75d0e82
+gsave
75d0e82
+
75d0e82
+  % Determine the imageable area and device resolution...
75d0e82
+  initclip newpath clippath pathbbox	% Get bounding rectangle
75d0e82
+  72 div /pageTop exch def		% Get top margin in inches
75d0e82
+  72 div /pageRight exch def		% Get right margin in inches
75d0e82
+  72 div /pageBottom exch def		% Get bottom margin in inches
75d0e82
+  72 div /pageLeft exch def		% Get left margin in inches
75d0e82
+
75d0e82
+  /pageWidth pageRight pageLeft sub def	% pageWidth = pageRight - pageLeft
75d0e82
+  /pageHeight pageTop pageBottom sub def% pageHeight = pageTop - pageBottom
75d0e82
+
75d0e82
+  /boxWidth				% width of text box
75d0e82
+  pageWidth pageHeight lt
75d0e82
+  { pageWidth 54 mul }
75d0e82
+  { pageHeight 42 mul }
75d0e82
+  ifelse def
75d0e82
+
75d0e82
+  newpath				% Clear bounding path
75d0e82
+
75d0e82
+  % Create fonts...
75d0e82
+  /bigFont /Helvetica-Bold findfont	% bigFont = Helvetica-Bold
75d0e82
+  pageHeight 3 mul scalefont def	% size = pageHeight * 3 (nominally 33)
75d0e82
+
75d0e82
+  /mediumFont /Helvetica findfont	% mediumFont = Helvetica
75d0e82
+  pageHeight 1.5 mul scalefont def	% size = pageHeight * 1.5 (nominally 16.5)
75d0e82
+
75d0e82
+  % Offset page to account for lower-left margin...
75d0e82
+  pageLeft 72 mul
75d0e82
+  pageBottom 72 mul
75d0e82
+  translate
75d0e82
+
75d0e82
+  % Draw the label at the top and bottom...
75d0e82
+  0 setgray				% Color
75d0e82
+
75d0e82
+  pageWidth 36 mul			% Center of page
75d0e82
+  pageHeight 72 mul			% Top of page
75d0e82
+  pageWidth -7 mul add			% - 2 lines
75d0e82
+  moveto				% Position text
75d0e82
+  bigFont setfont			% Font
75d0e82
+  ({mls-label}) CENTER		% Show text centered
75d0e82
+
75d0e82
+  pageWidth 36 mul			% Center of page
75d0e82
+  pageHeight 6 mul			% Bottom of page
75d0e82
+  moveto				% Position text
75d0e82
+  bigFont setfont			% Font
75d0e82
+  ({mls-label}) CENTER		% Show text centered
75d0e82
+
75d0e82
+  % Job information box...
75d0e82
+  pageWidth 36 mul 9 add		% x = pageWidth * 1/2 * 72 + 9
75d0e82
+  boxWidth 0.5 mul sub			% x-= 1/2 box width
75d0e82
+  pageHeight 30 mul 9 sub		% y = pageHeight * 1/2 * 72 - 9
75d0e82
+  boxWidth				% w = box width
75d0e82
+  pageHeight 14 mul			% h = pageHeight * 1/2 * 72
75d0e82
+  0.5 setgray rectfill			% Draw a shadow
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  boxWidth 0.5 mul sub			% x-= 1/2 box width
75d0e82
+  pageHeight 30 mul			% y = pageHeight * 1/4 * 72
75d0e82
+  boxWidth				% w = box width
75d0e82
+  pageHeight 14 mul			% h = pageHeight * 1/2 * 72
75d0e82
+
75d0e82
+  4 copy 1 setgray rectfill		% Clear the box to white
75d0e82
+  0 setgray rectstroke			% Draw a black box around it...
75d0e82
+
75d0e82
+  % Job information text...
75d0e82
+  mediumFont setfont			% Medium sized font
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight 5 mul add			% y += 2 lines
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Job ID: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({printer-name}-{job-id}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight 2 mul add			% y += 1 line
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Title: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({job-name}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight -1 mul add			% y -= 1 line
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Requesting User: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({job-originating-user-name}) show
75d0e82
+
75d0e82
+  pageWidth 36 mul			% x = pageWidth * 1/2 * 72
75d0e82
+  pageHeight 36 mul			% y = pageHeight * 1/2 * 72
75d0e82
+  pageHeight -4 mul add			% y -= 2 lines
75d0e82
+  2 copy				% Copy X & Y
75d0e82
+  moveto
75d0e82
+  (Billing Info: ) RIGHT
75d0e82
+  moveto
75d0e82
+  ({?job-billing}) show
75d0e82
+
75d0e82
+  % Then the CUPS logo....
75d0e82
+  gsave
75d0e82
+    pageWidth 4 mul
75d0e82
+    pageWidth 6 mul
75d0e82
+    translate
75d0e82
+    pageWidth 9 mul CUPSLOGO
75d0e82
+  grestore
75d0e82
+
75d0e82
+  % And the ESP logo....
75d0e82
+  gsave
75d0e82
+    pageWidth 59 mul
75d0e82
+    pageWidth 6 mul
75d0e82
+    translate
75d0e82
+    pageWidth 6 mul ESPLOGO
75d0e82
+  grestore
75d0e82
+% Show the page...
75d0e82
+grestore
75d0e82
+showpage
75d0e82
+%
75d0e82
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
75d0e82
+%
75d0e82
+%%EOF
22cc213
--- cups-1.2.4-orig/Makedefs.in	2006-09-28 11:38:14.000000000 -0400
22cc213
+++ cups-1.2.4/Makedefs.in	2006-09-28 16:31:29.000000000 -0400
5dd9863
@@ -135,7 +135,7 @@
5dd9863
 			@LDFLAGS@ @RELROFLAG@ @PIEFLAGS@ $(OPTIM)
5dd9863
 LINKCUPS	=	@LINKCUPS@ $(SSLLIBS)
5dd9863
 LINKCUPSIMAGE	=	@LINKCUPSIMAGE@
5dd9863
-LIBS		=	$(LINKCUPS) $(COMMONLIBS)
5dd9863
+LIBS		=	$(LINKCUPS) $(COMMONLIBS) @LIBAUDIT@ @LIBSELINUX@
5dd9863
 OPTIM		=	@OPTIM@
5dd9863
 OPTIONS		=
5dd9863
 PAMLIBS		=	@PAMLIBS@
22cc213
--- cups-1.2.4-orig/scheduler/client.c	2006-09-19 16:44:07.000000000 -0400
c5c7073
+++ cups-1.2.4/scheduler/client.c	2006-10-04 11:53:10.000000000 -0400
22cc213
@@ -44,12 +44,17 @@
5dd9863
  *   make_certificate()      - Make a self-signed SSL/TLS certificate.
5dd9863
  *   pipe_command()          - Pipe the output of a command to the remote client.
5dd9863
  *   write_file()            - Send a file via HTTP.
5dd9863
+ *   client_pid_to_auid()    - Get the audit login uid of the client.
75d0e82
  */
75d0e82
 
5dd9863
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
75d0e82
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
75d0e82
+
75d0e82
 /*
75d0e82
  * Include necessary headers...
75d0e82
  */
75d0e82
 
5dd9863
+#define _GNU_SOURCE
5dd9863
 #include <cups/http-private.h>
5dd9863
 #include "cupsd.h"
75d0e82
 
22cc213
@@ -65,6 +70,12 @@
5dd9863
 #  include <gnutls/x509.h>
5dd9863
 #endif /* HAVE_GNUTLS */
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
75d0e82
+#include <selinux/selinux.h>
22cc213
+#include <selinux/context.h>
5dd9863
+#include <fcntl.h>
75d0e82
+#endif /* WITH_LSPP */
5dd9863
+
75d0e82
 
75d0e82
 /*
5dd9863
  * Local functions...
c5c7073
@@ -381,6 +392,55 @@
5dd9863
                   "cupsdAcceptClient: %d connected to server on %s:%d",
5dd9863
                   con->http.fd, con->servername, con->serverport);
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
5dd9863
+  if (is_lspp_config())
75d0e82
+  {
5dd9863
+    struct ucred cr;
5dd9863
+    unsigned int cl=sizeof(cr);
5dd9863
+
5dd9863
+    if (getsockopt(con->http.fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl) == 0)
5dd9863
+    {
5dd9863
+     /*
5dd9863
+      * client_pid_to_auid() can be racey
5dd9863
+      * In this case the pid is based on a socket connected to the client
5dd9863
+      */
5dd9863
+      if ((con->auid = client_pid_to_auid(cr.pid)) == -1)
5dd9863
+      {
5dd9863
+        close(con->http.fd);
5dd9863
+        cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdAcceptClient: unable to determine client auid");
c5c7073
+        free(con);
c5c7073
+        return;
5dd9863
+      }
5dd9863
+      cupsdLogMessage(CUPSD_LOG_INFO, "cupsdAcceptClient: peer's pid=%d, uid=%d, gid=%d, auid=%d",
5dd9863
+                      cr.pid, cr.uid, cr.gid, con->auid);
5dd9863
+    }
5dd9863
+    else
5dd9863
+    {
5dd9863
+      close(con->http.fd);
5dd9863
+      cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdAcceptClient: getsockopt() failed");
c5c7073
+      free(con);
c5c7073
+      return; 
5dd9863
+    }
5dd9863
+
75d0e82
+   /*
5dd9863
+    * get the context of the peer connection
75d0e82
+    */
5dd9863
+    if (getpeercon(con->http.fd, &con->scon))
5dd9863
+    {
5dd9863
+      cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdAcceptClient: getpeercon() failed");
5dd9863
+      cupsdSetString(&con->scon, UNKNOWN_SL);
5dd9863
+    }
5dd9863
+
5dd9863
+    cupsdLogMessage(CUPSD_LOG_INFO, "cupsdAcceptClient: client context=%s", con->scon);
5dd9863
+
5dd9863
+  }
5dd9863
+  else
5dd9863
+  {
6bb98ac
+    cupsdLogMessage(CUPSD_LOG_INFO, "cupsdAcceptClient: skipping getpeercon()");
5dd9863
+    cupsdSetString(&con->scon, UNKNOWN_SL);
75d0e82
+  }
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
5dd9863
  /*
5dd9863
   * Using TCP_NODELAY improves responsiveness, especially on systems
5dd9863
   * with a slow loopback interface...  Since we write large buffers
c5c7073
@@ -711,6 +771,11 @@
22cc213
   mime_type_t		*type;		/* MIME type of file */
22cc213
   cupsd_printer_t	*p;		/* Printer */
22cc213
   static unsigned	request_id = 0;	/* Request ID for temp files */
22cc213
+#ifdef WITH_LSPP
22cc213
+  security_context_t	spoolcon;	/* context of the job file */
22cc213
+  context_t		clicon;		/* contex_t container for con->scon */
22cc213
+  context_t		tmpcon;		/* temp context to swap the level */
22cc213
+#endif /* WITH_LSPP */
75d0e82
 
22cc213
 
22cc213
   status = HTTP_CONTINUE;
c5c7073
@@ -1797,6 +1862,47 @@
22cc213
 	  fchmod(con->file, 0640);
22cc213
 	  fchown(con->file, RunUser, Group);
22cc213
           fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
22cc213
+#ifdef WITH_LSPP
6bb98ac
+          if (strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
22cc213
+          {
6bb98ac
+            if (getfilecon(con->filename, &spoolcon) == -1)
6bb98ac
+            {
6bb98ac
+              cupsdSendError(con, HTTP_SERVER_ERROR);
6bb98ac
+              freecon(spoolcon);
6bb98ac
+              return (cupsdCloseClient(con));
6bb98ac
+            }
6bb98ac
+            clicon = context_new(con->scon);
6bb98ac
+            tmpcon = context_new(spoolcon);
22cc213
+            freecon(spoolcon);
c5c7073
+            if (!clicon || !tmpcon)
c5c7073
+            {
c5c7073
+              cupsdSendError(con, HTTP_SERVER_ERROR);
c5c7073
+              if (clicon)
c5c7073
+                context_free(clicon);
c5c7073
+              if (tmpcon)
c5c7073
+                context_free(tmpcon);
c5c7073
+              return (cupsdCloseClient(con));
c5c7073
+            }
6bb98ac
+            if (context_range_set(tmpcon, (context_range_get(clicon))) == -1)
6bb98ac
+            {
6bb98ac
+              cupsdSendError(con, HTTP_SERVER_ERROR);
6bb98ac
+              context_free(tmpcon);
6bb98ac
+              context_free(clicon);
6bb98ac
+              return (cupsdCloseClient(con));
6bb98ac
+            }
6bb98ac
+            if (setfilecon(con->filename, context_str(tmpcon)) == -1)
6bb98ac
+            {
6bb98ac
+              cupsdSendError(con, HTTP_SERVER_ERROR);
6bb98ac
+              context_free(tmpcon);
6bb98ac
+              context_free(clicon);
6bb98ac
+              return (cupsdCloseClient(con));
6bb98ac
+            }
6bb98ac
+            cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadClient: %s set to %s", 
6bb98ac
+                            con->filename, context_str(tmpcon));
22cc213
+            context_free(tmpcon);
22cc213
+            context_free(clicon);
22cc213
+          }
22cc213
+#endif /* WITH_LSPP */
22cc213
 	}
22cc213
 
22cc213
 	if (con->http.state != HTTP_POST_SEND)
c5c7073
@@ -3810,6 +3916,49 @@
5dd9863
 #endif /* HAVE_SSL */
75d0e82
 
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
5dd9863
+/*
5dd9863
+ * 'client_pid_to_auid()' - Using the client's pid, read /proc and determine the loginuid.
5dd9863
+ */
75d0e82
+
5dd9863
+uid_t client_pid_to_auid(pid_t clipid)
5dd9863
+{
5dd9863
+  uid_t uid;
5dd9863
+  int len, in;
5dd9863
+  char buf[16] = {0};
5dd9863
+  char fname[32] = {0};
75d0e82
+
75d0e82
+
5dd9863
+ /*
5dd9863
+  * Hopefully this pid is still the one we are interested in.
5dd9863
+  */
5dd9863
+  snprintf(fname, 32, "/proc/%d/loginuid", clipid);
5dd9863
+  in = open(fname, O_NOFOLLOW|O_RDONLY);
75d0e82
+
5dd9863
+  if (in < 0)
5dd9863
+    return -1;
75d0e82
+
5dd9863
+  errno = 0;
75d0e82
+
5dd9863
+  do {
5dd9863
+    len = read(in, buf, sizeof(buf));
5dd9863
+  } while (len < 0 && errno == EINTR);
75d0e82
+
5dd9863
+  close(in);
75d0e82
+
5dd9863
+  if (len < 0 || len >= sizeof(buf))
5dd9863
+    return -1;
5dd9863
+
5dd9863
+  buf[len] = 0;
5dd9863
+  uid = strtol(buf, 0, 10);
5dd9863
+
5dd9863
+  if (errno != 0)
5dd9863
+    return -1;
5dd9863
+  else
5dd9863
+    return uid;
5dd9863
+}
75d0e82
+#endif /* WITH_LSPP */
5dd9863
+
5dd9863
 /*
5dd9863
  * 'pipe_command()' - Pipe the output of a command to the remote client.
5dd9863
  */
22cc213
--- cups-1.2.4-orig/scheduler/client.h	2006-09-11 10:21:23.000000000 -0400
22cc213
+++ cups-1.2.4/scheduler/client.h	2006-09-28 16:31:29.000000000 -0400
75d0e82
@@ -22,6 +22,13 @@
75d0e82
  *         WWW: http://www.cups.org
75d0e82
  */
75d0e82
 
75d0e82
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
75d0e82
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
75d0e82
+
75d0e82
+#ifdef WITH_LSPP
75d0e82
+#include <selinux/selinux.h>
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
75d0e82
 /*
75d0e82
  * HTTP client structure...
75d0e82
  */
75d0e82
@@ -55,6 +62,10 @@
75d0e82
   http_addr_t		clientaddr;	/* Client address */
75d0e82
   char			servername[256];/* Server name for connection */
75d0e82
   int			serverport;	/* Server port for connection */
75d0e82
+#ifdef WITH_LSPP
75d0e82
+  security_context_t	scon;		/* Security context of connection */
75d0e82
+  uid_t			auid;		/* Audit loginuid of the client */
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 };
75d0e82
 
75d0e82
 #define HTTP(con) &((con)->http)
22cc213
@@ -119,6 +130,9 @@
75d0e82
 extern void	cupsdStopListening(void);
75d0e82
 extern void	cupsdUpdateCGI(void);
75d0e82
 extern int	cupsdWriteClient(cupsd_client_t *con);
75d0e82
+#ifdef WITH_LSPP
75d0e82
+extern uid_t	client_pid_to_auid(pid_t clipid);
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 
75d0e82
 
75d0e82
 /*
22cc213
--- cups-1.2.4-orig/scheduler/conf.c	2006-09-28 11:38:08.000000000 -0400
22cc213
+++ cups-1.2.4/scheduler/conf.c	2006-09-29 18:23:37.000000000 -0400
5dd9863
@@ -35,6 +35,7 @@
5dd9863
  *   read_configuration()     - Read a configuration file.
5dd9863
  *   read_location()          - Read a <Location path> definition.
5dd9863
  *   read_policy()            - Read a <Policy name> definition.
5dd9863
+ *   is_lspp_config()         - Is the system configured for LSPP
75d0e82
  */
75d0e82
 
75d0e82
 /*
5dd9863
@@ -60,6 +61,9 @@
5dd9863
 #  define INADDR_NONE	0xffffffff
5dd9863
 #endif /* !INADDR_NONE */
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
75d0e82
+#  include <libaudit.h>
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 
75d0e82
 /*
5dd9863
  * Configuration variable structure...
5dd9863
@@ -161,6 +165,9 @@
5dd9863
   { "ServerKey",		&ServerKey,		CUPSD_VARTYPE_STRING },
5dd9863
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
5dd9863
 #endif /* HAVE_SSL */
5dd9863
+#ifdef WITH_LSPP
5dd9863
+  { "AuditLog",			&AuditLog,		CUPSD_VARTYPE_INTEGER },
5dd9863
+#endif /* WITH_LSPP */
5dd9863
 #ifdef HAVE_LAUNCHD
5dd9863
   { "LaunchdTimeout",		&LaunchdTimeout,	CUPSD_VARTYPE_INTEGER },
5dd9863
   { "LaunchdConf",		&LaunchdConf,		CUPSD_VARTYPE_STRING },
5dd9863
@@ -223,6 +230,9 @@
5dd9863
 		*old_requestroot;	/* Old RequestRoot */
5dd9863
   const char	*tmpdir;		/* TMPDIR environment variable */
5dd9863
   struct stat	tmpinfo;		/* Temporary directory info */
5dd9863
+#ifdef WITH_LSPP
5dd9863
+  char		*audit_message;		/* Audit message string */
5dd9863
+#endif /* WITH_LSPP */
5dd9863
 
5dd9863
 
5dd9863
  /*
22cc213
@@ -470,6 +480,16 @@
9ad376b
 
9ad376b
   RunUser = getuid();
9ad376b
 
75d0e82
+#ifdef WITH_LSPP
5dd9863
+  /*
5dd9863
+   * ClassifyOverride is set during read_configuration, if its on, report it now
5dd9863
+   */
9ad376b
+  if (ClassifyOverride && AuditLog != -1)
5dd9863
+    audit_log_user_message(AuditLog, AUDIT_USYS_CONFIG,
5dd9863
+              "[Config] ClassifyOverride=enabled Users can override print banners",
5dd9863
+              ServerName, NULL, NULL, 1);
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
75d0e82
  /*
9ad376b
   * See if the ServerName is an IP address...
75d0e82
   */
22cc213
@@ -777,11 +797,23 @@
22cc213
   if (MaxActiveJobs > (MaxFDs / 3))
22cc213
     MaxActiveJobs = MaxFDs / 3;
22cc213
 
22cc213
-  if (Classification && !strcasecmp(Classification, "none"))
22cc213
+  if (Classification && strcasecmp(Classification, "none") == 0)
5dd9863
     cupsdClearString(&Classification);
75d0e82
 
5dd9863
   if (Classification)
5dd9863
+  {
5dd9863
     cupsdLogMessage(CUPSD_LOG_INFO, "Security set to \"%s\"", Classification);
75d0e82
+#ifdef WITH_LSPP
9ad376b
+    if (AuditLog != -1)
9ad376b
+    {
9ad376b
+      audit_message = NULL;
22cc213
+      cupsdSetStringf(&audit_message, "[Config] Classification=%s", Classification);
9ad376b
+      audit_log_user_message(AuditLog, AUDIT_LABEL_LEVEL_CHANGE, audit_message,
9ad376b
+                             ServerName, NULL, NULL, 1);
9ad376b
+      free(audit_message);
9ad376b
+    }
75d0e82
+#endif /* WITH_LSPP */
5dd9863
+  }
75d0e82
 
5dd9863
  /*
5dd9863
   * Update the MaxClientsPerHost value, as needed...
22cc213
@@ -3295,6 +3327,18 @@
5dd9863
   return (0);
5dd9863
 }
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
5dd9863
+int is_lspp_config()
5dd9863
+{
5dd9863
+  if (Classification != NULL)
5dd9863
+    return ((strcasecmp(Classification, MLS_CONFIG) == 0) 
5dd9863
+            || (strcasecmp(Classification, TE_CONFIG) == 0)
5dd9863
+            || (strcasecmp(Classification, SELINUX_CONFIG) == 0));
5dd9863
+  else
5dd9863
+    return 0;
5dd9863
+}
75d0e82
+#endif /* WITH_LSPP */
5dd9863
+
5dd9863
 
5dd9863
 /*
22cc213
  * End of "$Id: conf.c 5905 2006-08-29 20:48:59Z mike $".
22cc213
--- cups-1.2.4-orig/scheduler/conf.h	2006-09-28 11:38:08.000000000 -0400
22cc213
+++ cups-1.2.4/scheduler/conf.h	2006-09-28 16:31:29.000000000 -0400
22cc213
@@ -191,6 +191,10 @@
5dd9863
 					/* Server key file */
5dd9863
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
5dd9863
 #endif /* HAVE_SSL */
5dd9863
+#ifdef WITH_LSPP
5dd9863
+VAR int			AuditLog		VALUE(-1);
5dd9863
+					/* File descriptor for audit */
5dd9863
+#endif /* WITH_LSPP */
5dd9863
 
5dd9863
 #ifdef HAVE_LAUNCHD
5dd9863
 VAR int			LaunchdTimeout		VALUE(DEFAULT_TIMEOUT);
22cc213
@@ -213,6 +217,9 @@
5dd9863
 ;
5dd9863
 extern int	cupsdLogPage(cupsd_job_t *job, const char *page);
75d0e82
 
5dd9863
+#ifdef WITH_LSPP
5dd9863
+extern int	is_lspp_config(void);
5dd9863
+#endif /* WITH_LSPP */
75d0e82
 
5dd9863
 /*
5dd9863
  * End of "$Id: conf.h 5696 2006-06-26 18:34:20Z mike $".
22cc213
--- cups-1.2.4-orig/scheduler/ipp.c	2006-09-28 11:38:08.000000000 -0400
c5c7073
+++ cups-1.2.4/scheduler/ipp.c	2006-10-04 11:53:10.000000000 -0400
75d0e82
@@ -96,6 +96,9 @@
75d0e82
  *   validate_user()             - Validate the user for the request.
75d0e82
  */
75d0e82
 
75d0e82
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
75d0e82
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
75d0e82
+
75d0e82
 /*
75d0e82
  * Include necessary headers...
75d0e82
  */
75d0e82
@@ -106,6 +109,14 @@
75d0e82
 #  include <paper.h>
75d0e82
 #endif /* HAVE_LIBPAPER */
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
75d0e82
+#include <libaudit.h>
75d0e82
+#include <selinux/selinux.h>
75d0e82
+#include <selinux/context.h>
75d0e82
+#include <selinux/avc.h>
75d0e82
+#include <selinux/flask.h>
75d0e82
+#include <selinux/av_permissions.h>
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 
75d0e82
 /*
75d0e82
  * PPD default choice structure...
22cc213
@@ -1173,6 +1184,21 @@
75d0e82
   int		kbytes;			/* Size of print file */
75d0e82
   int		i;			/* Looping var */
75d0e82
   int		lowerpagerange;		/* Page range bound */
75d0e82
+#ifdef WITH_LSPP
75d0e82
+  char		*audit_message;		/* Audit message string */
75d0e82
+  char		*printerfile;		/* device file pointed to by the printer */
9ad376b
+  char		*userheader = NULL;	/* User supplied job-sheets[0] */
9ad376b
+  char		*userfooter = NULL;	/* User supplied job-sheets[1] */
9ad376b
+  int		override = 0;		/* Was a banner overrode on a job */
22cc213
+  security_id_t	clisid;			/* SELinux SID for the client */
22cc213
+  security_id_t	psid;			/* SELinux SID for the printer */
22cc213
+  context_t	printercon;		/* Printer's context string */
22cc213
+  security_context_t	devcon;		/* Printer's SELinux context */
22cc213
+  struct av_decision	avd;		/* Pointer to the access decision */
22cc213
+  struct avc_entry_ref	avcref;		/* Pointer to the access vector cache */
22cc213
+  security_class_t	tclass;		/* Object class for the SELinux check */
22cc213
+  access_vector_t	avr;		/* Access method being requested */
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 
75d0e82
 
75d0e82
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %s)", con,
6bb98ac
@@ -1349,6 +1375,101 @@
75d0e82
     return (NULL);
75d0e82
   }
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
75d0e82
+  if (is_lspp_config())
75d0e82
+  {
6bb98ac
+    if (!con->scon || strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) == 0)
75d0e82
+    {
75d0e82
+      cupsdLogMessage(CUPSD_LOG_ERROR, "add_job: missing classification for connection \'%s\'!", dest);
75d0e82
+      send_ipp_status(con, IPP_INTERNAL_ERROR, _("Missing required secuirty attributes."));
75d0e82
+      return (NULL);
75d0e82
+    }
75d0e82
+    else
75d0e82
+    {
75d0e82
+     /*
75d0e82
+      * duplicate the security context and auid of the connection into the job structure
75d0e82
+      */
6bb98ac
+      job->scon = strdup(con->scon);
6bb98ac
+      job->auid = con->auid;
75d0e82
+
75d0e82
+     /* 
75d0e82
+      * add the security context to the request so that on a restart the security
75d0e82
+      * attributes will be able to be restored
75d0e82
+      */
75d0e82
+      ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "security-context", 
75d0e82
+                   NULL, job->scon);
75d0e82
+    }
75d0e82
+
75d0e82
+   /*
75d0e82
+    * Perform an access check so that if the user gets feedback at enqueue time
75d0e82
+    */
75d0e82
+
9ad376b
+    printerfile = strstr(printer->device_uri, "/dev/");
22cc213
+    if (printerfile == NULL && (strncmp(printer->device_uri, "file:/", 6) == 0))
22cc213
+      printerfile = strdup(printer->device_uri + strlen("file:/"));
22cc213
+
9ad376b
+    if (printerfile != NULL)
75d0e82
+    {
75d0e82
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "add_job: Attempting an access check on printer device %s",
75d0e82
+                      printerfile);
75d0e82
+
22cc213
+      tclass = SECCLASS_FILE;
22cc213
+      avr = FILE__WRITE;
22cc213
+      avc_init("cupsd_enqueue_", NULL, NULL, NULL, NULL);
22cc213
+      avc_entry_ref_init(&avcref);
22cc213
+      if (avc_context_to_sid(con->scon, &clisid) != 0)
75d0e82
+      {
22cc213
+        send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Unable to get the SELinux sid of the client"));
75d0e82
+        return (NULL);
75d0e82
+      }
22cc213
+      if (getfilecon(printerfile, &devcon) == -1)
22cc213
+      {
22cc213
+        send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Unable to get the SELinux context of the printer"));
22cc213
+        return (NULL);
22cc213
+      }
22cc213
+      printercon = context_new(devcon);
22cc213
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "add_job: printer context %s client context %s",
22cc213
+                      context_str(printercon), con->scon);
22cc213
+      context_free(printercon);
75d0e82
+
22cc213
+      if (avc_context_to_sid(devcon, &psid) != 0)
75d0e82
+      {
22cc213
+        send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Unable to get the SELinux sid of the printer"));
22cc213
+        freecon(devcon);
22cc213
+        return (NULL);
22cc213
+      }
22cc213
+      freecon(devcon);
22cc213
+      if (avc_has_perm_noaudit(clisid, psid, tclass, avr, &avcref, &avd) != 0)
22cc213
+      {
22cc213
+       /*
22cc213
+        * The access check failed, so cancel the job and send an audit message
22cc213
+        */
22cc213
+        if (AuditLog != -1)
75d0e82
+        {
22cc213
+          audit_message = NULL;
22cc213
+          cupsdSetStringf(&audit_message, "job=%d auid=%u acct=%s obj=%s refused"
22cc213
+                          " unable to access printer=%s", job->id, con->auid,
22cc213
+                          con->username, con->scon, printer->name);
22cc213
+          audit_log_user_message(AuditLog, AUDIT_USER_LABELED_EXPORT, audit_message,
22cc213
+                                 ServerName, NULL, NULL, 0);
22cc213
+          free(audit_message);
75d0e82
+        }
22cc213
+
22cc213
+        send_ipp_status(con, IPP_NOT_AUTHORIZED, _("SELinux prohibits access to the printer"));
22cc213
+        return (NULL);
75d0e82
+      }
75d0e82
+    }
75d0e82
+  }
6bb98ac
+  else
6bb98ac
+  {
6bb98ac
+   /*
6bb98ac
+    * Fill in the security context of the job as unlabeled
6bb98ac
+    */
6bb98ac
+    cupsdLogMessage(CUPSD_LOG_INFO, "add_job: setting context of job to %s", UNKNOWN_SL);
6bb98ac
+    cupsdSetString(&job->scon, UNKNOWN_SL);
6bb98ac
+  }
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
75d0e82
   job->dtype   = dtype;
75d0e82
   job->attrs   = con->request;
75d0e82
   con->request = NULL;
6bb98ac
@@ -1544,6 +1665,29 @@
9ad376b
       attr->values[0].string.text = _cupsStrAlloc(printer->job_sheets[0]);
9ad376b
       attr->values[1].string.text = _cupsStrAlloc(printer->job_sheets[1]);
9ad376b
     }
75d0e82
+#ifdef WITH_LSPP
9ad376b
+    else
9ad376b
+    {
9ad376b
+     /*
9ad376b
+      * The option was present, so capture the user supplied strings
9ad376b
+      */
9ad376b
+      userheader = strdup(attr->values[0].string.text);
9ad376b
+
9ad376b
+      if (attr->num_values > 1)
9ad376b
+        userfooter = strdup(attr->values[1].string.text);
9ad376b
+  
f6c7a0a
+      if (Classification != NULL && (strcmp(userheader, Classification) == 0)
d90f391
+          && userfooter &&(strcmp(userfooter, Classification) == 0))
9ad376b
+      {
75d0e82
+       /*
9ad376b
+        * Since both values are Classification, the user is not trying to Override
75d0e82
+        */
9ad376b
+        free(userheader);
d90f391
+        if (userfooter) free(userfooter);
9ad376b
+        userheader = userfooter = NULL;
9ad376b
+      }
9ad376b
+    }
9ad376b
+#endif /* WITH_LSPP */
9ad376b
 
9ad376b
     job->job_sheets = attr;
9ad376b
 
6bb98ac
@@ -1574,6 +1718,9 @@
9ad376b
 	                		    "job-sheets=\"%s,none\", "
9ad376b
 					    "job-originating-user-name=\"%s\"",
9ad376b
 	        	 job->id, Classification, job->username);
9ad376b
+#ifdef WITH_LSPP
9ad376b
+          override = 1;
9ad376b
+#endif /* WITH_LSPP */
9ad376b
 	}
9ad376b
 	else if (attr->num_values == 2 &&
9ad376b
 	         strcmp(attr->values[0].string.text,
6bb98ac
@@ -1592,6 +1739,9 @@
9ad376b
 					    "job-originating-user-name=\"%s\"",
9ad376b
 	        	 job->id, attr->values[0].string.text,
9ad376b
 			 attr->values[1].string.text, job->username);
9ad376b
+#ifdef WITH_LSPP
9ad376b
+          override = 1;
9ad376b
+#endif /* WITH_LSPP */
9ad376b
 	}
9ad376b
 	else if (strcmp(attr->values[0].string.text, Classification) &&
9ad376b
 	         strcmp(attr->values[0].string.text, "none") &&
6bb98ac
@@ -1612,6 +1762,9 @@
9ad376b
 			    "job-originating-user-name=\"%s\"",
9ad376b
 	        	    job->id, attr->values[0].string.text,
9ad376b
 			    attr->values[1].string.text, job->username);
9ad376b
+#ifdef WITH_LSPP
9ad376b
+          override = 1;
9ad376b
+#endif /* WITH_LSPP */
9ad376b
         }
9ad376b
       }
9ad376b
       else if (strcmp(attr->values[0].string.text, Classification) &&
c5c7073
@@ -1652,7 +1805,50 @@
9ad376b
 	                  "job-sheets=\"%s\", "
9ad376b
 			  "job-originating-user-name=\"%s\"",
9ad376b
 	        	 job->id, Classification, job->username);
9ad376b
+#ifdef WITH_LSPP
9ad376b
+        override = 1;
9ad376b
+#endif /* WITH_LSPP */
c5c7073
       }
9ad376b
+#ifdef WITH_LSPP
9ad376b
+      if (is_lspp_config() && AuditLog != -1)
9ad376b
+      {
75d0e82
+        audit_message = NULL;
9ad376b
+
9ad376b
+        if (userheader || userfooter)
9ad376b
+        {
9ad376b
+          if (!override)
9ad376b
+          {
9ad376b
+           /*
9ad376b
+            * The user overrode the banner, so audit it
9ad376b
+            */
22cc213
+            cupsdSetStringf(&audit_message, "job=%d user supplied job-sheets=%s,%s"
22cc213
+                            " using banners=%s,%s", job->id, userheader,
9ad376b
+                            userfooter, attr->values[0].string.text,
9ad376b
+                            (attr->num_values > 1) ? attr->values[1].string.text : "(null)");
9ad376b
+            audit_log_user_message(AuditLog, AUDIT_LABEL_OVERRIDE, audit_message,
9ad376b
+                                   ServerName, NULL, NULL, 1);
9ad376b
+          }
9ad376b
+          else
9ad376b
+          {
9ad376b
+           /*
9ad376b
+            * The user tried to override the banner, audit the failure
9ad376b
+            */
22cc213
+            cupsdSetStringf(&audit_message, "job=%d user supplied job-sheets=%s,%s"
22cc213
+                            " ignored banners=%s,%s", job->id, userheader,
9ad376b
+                            userfooter, attr->values[0].string.text,
9ad376b
+                            (attr->num_values > 1) ? attr->values[1].string.text : "(null)");
9ad376b
+            audit_log_user_message(AuditLog, AUDIT_LABEL_OVERRIDE, audit_message,
9ad376b
+                                   ServerName, NULL, NULL, 0);
9ad376b
+          }
9ad376b
+          free(audit_message);
c5c7073
+      }
c5c7073
+    }
c5c7073
+
9ad376b
+      if (userheader)
9ad376b
+        free(userheader);
9ad376b
+      if (userfooter)
9ad376b
+        free(userfooter);
75d0e82
+#endif /* WITH_LSPP */
c5c7073
     }
c5c7073
 
9ad376b
    /*
6bb98ac
@@ -3504,6 +3700,13 @@
75d0e82
   char		attrname[255],		/* Name of attribute */
75d0e82
 		*s;			/* Pointer into name */
75d0e82
   ipp_attribute_t *attr;		/* Attribute */
75d0e82
+#ifdef WITH_LSPP
75d0e82
+  const char	*mls_label = NULL;	/* SL of print job */
22cc213
+  context_t	jobcon;			/* SELinux context of the job */
22cc213
+  context_t	tmpcon;			/* Temp context to set the level */
22cc213
+  security_context_t	spoolcon;	/* Context of the file in the spool */
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
75d0e82
 
75d0e82
 
75d0e82
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_banner(%p[%d], %p[%d], %s)",
c5c7073
@@ -3537,6 +3740,57 @@
22cc213
 
22cc213
   fchmod(cupsFileNumber(out), 0640);
22cc213
   fchown(cupsFileNumber(out), RunUser, Group);
22cc213
+#ifdef WITH_LSPP
6bb98ac
+  if (strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
22cc213
+  {
6bb98ac
+    if (getfilecon(filename, &spoolcon) == -1)
6bb98ac
+    {
6bb98ac
+      cupsdLogMessage(CUPSD_LOG_ERROR,
6bb98ac
+                      "copy_banner: Unable to get the context of the banner file %s - %s",
6bb98ac
+                      filename, strerror(errno));
6bb98ac
+      job->num_files --;
6bb98ac
+      return (0);
6bb98ac
+    }
6bb98ac
+    tmpcon = context_new(spoolcon);
6bb98ac
+    jobcon = context_new(con->scon);
6bb98ac
+    freecon(spoolcon);
c5c7073
+    if (!tmpcon || !jobcon)
c5c7073
+    {
c5c7073
+      if (tmpcon)
c5c7073
+        context_free(tmpcon);
c5c7073
+      if (jobcon)
c5c7073
+        context_free(jobcon);
c5c7073
+      cupsdLogMessage(CUPSD_LOG_ERROR,
c5c7073
+                      "copy_banner: Unable to get the SELinux contexts");
c5c7073
+      job->num_files --;
c5c7073
+      return (0);
c5c7073
+    }
6bb98ac
+    if (context_range_set(tmpcon, (context_range_get(jobcon))) == -1)
6bb98ac
+    {
6bb98ac
+      cupsdLogMessage(CUPSD_LOG_ERROR,
6bb98ac
+                      "copy_banner: Unable to set the level of the context for file %s - %s",
6bb98ac
+                      filename, strerror(errno));
6bb98ac
+      context_free(jobcon);
6bb98ac
+      context_free(tmpcon);
6bb98ac
+      job->num_files --;
6bb98ac
+      return (0);
6bb98ac
+    }
6bb98ac
+    if (setfilecon(filename, context_str(tmpcon)) == -1)
6bb98ac
+    {
6bb98ac
+      cupsdLogMessage(CUPSD_LOG_ERROR,
6bb98ac
+                      "copy_banner: Unable to set the context of the banner file %s - %s",
6bb98ac
+                      filename, strerror(errno));
6bb98ac
+      context_free(jobcon);
6bb98ac
+      context_free(tmpcon);
6bb98ac
+      job->num_files --;
6bb98ac
+      return (0);
6bb98ac
+    }
6bb98ac
+    cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_banner: %s set to %s",
6bb98ac
+                    filename, context_str(tmpcon));
22cc213
+    context_free(jobcon);
22cc213
+    context_free(tmpcon);
22cc213
+  }
22cc213
+#endif /* WITH_LSPP */
22cc213
 
22cc213
  /*
22cc213
   * Try the localized banner file under the subdirectory...
c5c7073
@@ -3631,6 +3885,24 @@
75d0e82
       else
75d0e82
         s = attrname;
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
75d0e82
+      if (strcmp(s, "mls-label") == 0)
75d0e82
+      {
6bb98ac
+        if (con->scon != NULL && strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
75d0e82
+        {
22cc213
+          jobcon = context_new(con->scon);
75d0e82
+          if (strcasecmp(name, MLS_CONFIG) == 0)
22cc213
+            mls_label = context_range_get(jobcon);
75d0e82
+          else if (strcasecmp(name, TE_CONFIG) == 0)
22cc213
+            mls_label = context_type_get(jobcon);
75d0e82
+          else // default to using the whole context string
22cc213
+            mls_label = context_str(jobcon);
75d0e82
+          cupsFilePuts(out, mls_label);
22cc213
+          context_free(jobcon);
75d0e82
+        }
75d0e82
+        continue;
75d0e82
+      }
75d0e82
+#endif /* WITH_LSPP */
75d0e82
       if (!strcmp(s, "printer-name"))
75d0e82
       {
75d0e82
         cupsFilePuts(out, job->dest);
c5c7073
@@ -5352,6 +5624,18 @@
75d0e82
   cupsd_printer_t *printer;		/* Printer */
75d0e82
   cups_array_t	*list;			/* Which job list... */
75d0e82
   cups_array_t	*ra;			/* Requested attributes array */
75d0e82
+#ifdef WITH_LSPP
75d0e82
+  int			selinuxcheck;	/* perform the SELinux access check? */
22cc213
+  char			filename[1024]; /* Filename of the spool file */
75d0e82
+  security_id_t		clisid;		/* SELinux SID of the client */
75d0e82
+  security_id_t		jobsid;		/* SELinux SID of the job */
22cc213
+  security_id_t		filesid;	/* SELinux SID of the spool file */
75d0e82
+  struct av_decision	avd;		/* SELinux decision stuct */
75d0e82
+  struct avc_entry_ref	avcref;		/* AVC entry cache pointer */
75d0e82
+  security_class_t	tclass;		/* SELinux security class */
75d0e82
+  access_vector_t	avr;		/* SELinux access being queried */
22cc213
+  security_context_t	spoolfilecon;	/* SELinux context of the spool file */
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 
75d0e82
 
75d0e82
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs(%p[%d], %s)", con, con->http.fd,
c5c7073
@@ -5469,6 +5753,45 @@
75d0e82
 
75d0e82
   ra = create_requested_array(con->request);
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
75d0e82
+ /*
75d0e82
+  * Determine outside the loop if we are concerned about SELinux
75d0e82
+  */
75d0e82
+  selinuxcheck = is_lspp_config();
75d0e82
+  if (selinuxcheck)
75d0e82
+  {
75d0e82
+    selinuxcheck = security_getenforce();
75d0e82
+    if (selinuxcheck == -1)
75d0e82
+    {
75d0e82
+      cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: unable to determine SELinux enforcement");
75d0e82
+      send_ipp_status(con, IPP_INTERNAL_ERROR, _("Internal SELinux error (getenforce)."));
75d0e82
+      return;
75d0e82
+    }
6bb98ac
+    if (strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) == 0)
6bb98ac
+      selinuxcheck = 0;
6bb98ac
+    else
75d0e82
+    {
6bb98ac
+      if (avc_init("cups", NULL, NULL, NULL, NULL) < 0)
6bb98ac
+      {
6bb98ac
+        cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: unable avc_init");
6bb98ac
+        send_ipp_status(con, IPP_INTERNAL_ERROR, _("Internal SELinux error (avc_init)."));
6bb98ac
+        return;
6bb98ac
+      } 
6bb98ac
+      if (avc_context_to_sid(con->scon, &clisid) != 0)
6bb98ac
+      {
6bb98ac
+        cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: unable to convert %s to SELinux sid", con->scon);
6bb98ac
+        send_ipp_status(con, IPP_INTERNAL_ERROR, _("Internal SELinux error (avc_context_to_sid)."));
6bb98ac
+        return;
6bb98ac
+      }
6bb98ac
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "get_jobs: client context %s", con->scon);
75d0e82
+
6bb98ac
+      avr = FILE__READ;
6bb98ac
+      tclass = SECCLASS_FILE;
6bb98ac
+    }
75d0e82
+  }
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
75d0e82
+
75d0e82
  /*
75d0e82
   * OK, build a list of jobs for this printer...
75d0e82
   */
c5c7073
@@ -5506,6 +5829,42 @@
75d0e82
     if (count > 0)
75d0e82
       ippAddSeparator(con->response);
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
6bb98ac
+    if (selinuxcheck && (strncmp(job->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0))
75d0e82
+    {
75d0e82
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "get_jobs: job context %s", job->scon);
75d0e82
+
75d0e82
+      avc_context_to_sid(job->scon, &jobsid);
75d0e82
+      avc_entry_ref_init(&avcref);
75d0e82
+      
75d0e82
+      if (avc_has_perm_noaudit(clisid, jobsid, tclass, avr, &avcref, &avd) != 0)
22cc213
+      {
22cc213
+        cupsdLogMessage(CUPSD_LOG_INFO, "get_jobs: SELinux denied access based on the client context");
22cc213
+        snprintf(filename, sizeof(filename), "%s/c%05d", RequestRoot, job->id);
22cc213
+        if (getfilecon(filename, &spoolfilecon) == -1)
22cc213
+        {
22cc213
+          cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: Unable to get spoolfile context");
22cc213
+          continue;
22cc213
+        }
22cc213
+        if (avc_context_to_sid(spoolfilecon, &filesid) != 0)
22cc213
+        {
22cc213
+          cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: Unable to determine the SELinux sid for the spool file");
22cc213
+          freecon(spoolfilecon);
22cc213
+          continue;
22cc213
+        }
22cc213
+        freecon(spoolfilecon);
22cc213
+        if (avc_has_perm_noaudit(clisid, filesid, tclass, avr, &avcref, &avd) != 0)
22cc213
+        {
22cc213
+          cupsdLogMessage(CUPSD_LOG_INFO, "get_jobs: SELinux denied access to the spool file");
22cc213
+          continue;
22cc213
+        }
22cc213
+        cupsdLogMessage(CUPSD_LOG_INFO, "get_jobs: SELinux allowed access to the spool file");
22cc213
+      }
22cc213
+      else
22cc213
+        cupsdLogMessage(CUPSD_LOG_INFO, "get_jobs: SELinux allowed access based on the client");
75d0e82
+    }
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
75d0e82
     count ++;
75d0e82
 
75d0e82
     cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count = %d", count);
c5c7073
@@ -7944,12 +8303,22 @@
75d0e82
     * See if we need to add the ending sheet...
75d0e82
     */
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
75d0e82
+    if (printer &&
75d0e82
+        ( is_lspp_config() ||
75d0e82
+        !(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) ) &&
75d0e82
+        (attr = ippFindAttribute(job->attrs, "job-sheets",
75d0e82
+	                         IPP_TAG_ZERO)) != NULL &&
75d0e82
+        attr->num_values > 1)
75d0e82
+    {
75d0e82
+#else /* !WITH_LSPP */
75d0e82
     if (printer &&
75d0e82
         !(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) &&
75d0e82
         (attr = ippFindAttribute(job->attrs, "job-sheets",
75d0e82
 	                         IPP_TAG_ZERO)) != NULL &&
75d0e82
         attr->num_values > 1)
75d0e82
     {
75d0e82
+#endif /* WITH_LSPP */
75d0e82
      /*
75d0e82
       * Yes...
75d0e82
       */
c5c7073
@@ -9201,6 +9570,17 @@
22cc213
 	      int            userlen)	/* I - Length of username */
22cc213
 {
22cc213
   cupsd_printer_t	*printer;	/* Printer for job */
22cc213
+#ifdef WITH_LSPP
22cc213
+  char			filename[1024];	/* Job filename */
22cc213
+  struct av_decision    avd;            /* Pointer to the access decision */
22cc213
+  struct avc_entry_ref  avcref;         /* Pointer to the access vector cache */
22cc213
+  security_class_t      tclass;         /* Object class for the SELinux check */
22cc213
+  access_vector_t       avr;            /* Access method being requested */
22cc213
+  security_id_t		jobsid;		/* SELinux sid for the job */
22cc213
+  security_id_t		consid;		/* SELinux sid for the client */
22cc213
+  security_id_t		filesid;	/* SELinux sid for the spool file */
22cc213
+  security_context_t	spoolfilecon;	/* SELinux context of the spool file */
22cc213
+#endif /* WITH_LSPP */
22cc213
 
22cc213
 
22cc213
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
c5c7073
@@ -9222,6 +9602,59 @@
22cc213
 
22cc213
   strlcpy(username, get_username(con), userlen);
22cc213
 
22cc213
+#ifdef WITH_LSPP
22cc213
+  if (is_lspp_config())
22cc213
+  {
22cc213
+    if (!con->scon || !job->scon)
22cc213
+      return 0;
22cc213
+
22cc213
+    tclass = SECCLASS_FILE;
22cc213
+    avr = FILE__READ;
22cc213
+    avc_init("cupsd_validate_user_", NULL, NULL, NULL, NULL);
22cc213
+    avc_entry_ref_init(&avcref);
22cc213
+    if (avc_context_to_sid(job->scon, &jobsid) != 0)
22cc213
+    {
22cc213
+      cupsdLogMessage(CUPSD_LOG_ERROR, "validate_user: Unable to determine the SELinux sid for the job");
22cc213
+      return 0;
22cc213
+    }
22cc213
+    if (avc_context_to_sid(con->scon, &consid) != 0)
22cc213
+    {
22cc213
+      cupsdLogMessage(CUPSD_LOG_ERROR, "validate_user: Unable to determine the SELinux sid for the client");
22cc213
+      return 0;
22cc213
+    }
22cc213
+
22cc213
+    if (avc_has_perm_noaudit(consid, jobsid, tclass, avr, &avcref, &avd) != 0)
22cc213
+    {
22cc213
+      cupsdLogMessage(CUPSD_LOG_INFO, "validate_user: SELinux denied access for the user");
22cc213
+     /*
22cc213
+      * The access check failed, check access on the file
22cc213
+      */
22cc213
+      snprintf(filename, sizeof(filename), "%s/c%05d", RequestRoot, job->id);
22cc213
+      if (getfilecon(filename, &spoolfilecon) == -1)
22cc213
+      {
22cc213
+        cupsdLogMessage(CUPSD_LOG_ERROR, "validate_user: Unable to get spoolfile context");
22cc213
+        return 0;
22cc213
+      }
22cc213
+      if (avc_context_to_sid(spoolfilecon, &filesid) != 0)
22cc213
+      {
22cc213
+        cupsdLogMessage(CUPSD_LOG_ERROR, "validate_user: Unable to determine the SELinux sid for the spool file");
22cc213
+        freecon(spoolfilecon);
22cc213
+        return 0;
22cc213
+      }
22cc213
+      freecon(spoolfilecon);
22cc213
+      if (avc_has_perm_noaudit(consid, filesid, tclass, avr, &avcref, &avd) != 0)
22cc213
+      {
22cc213
+        cupsdLogMessage(CUPSD_LOG_INFO, "validate_user: SELinux denied access on the spool file");
22cc213
+        return 0;
22cc213
+      }
22cc213
+      else
22cc213
+        cupsdLogMessage(CUPSD_LOG_INFO, "validate_user: SELinux allowed access on the spool file");
22cc213
+    }
22cc213
+    else
22cc213
+      cupsdLogMessage(CUPSD_LOG_INFO, "validate_user: SELinux allowed access based on the client context");
22cc213
+  }
22cc213
+#endif /* WITH_LSPP */
22cc213
+
22cc213
  /*
22cc213
   * Check the username against the owner...
22cc213
   */
22cc213
--- cups-1.2.4-orig/scheduler/job.c	2006-09-28 11:38:08.000000000 -0400
c5c7073
+++ cups-1.2.4/scheduler/job.c	2006-10-04 11:53:10.000000000 -0400
5dd9863
@@ -68,6 +68,9 @@
5dd9863
  *   unload_job()               - Unload a job from memory.
75d0e82
  */
75d0e82
 
5dd9863
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
5dd9863
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
5dd9863
+
75d0e82
 /*
5dd9863
  * Include necessary headers...
5dd9863
  */
22cc213
@@ -77,6 +80,14 @@
5dd9863
 #include <cups/backend.h>
5dd9863
 #include <cups/dir.h>
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
22cc213
+#include <libaudit.h>
5dd9863
+#include <selinux/selinux.h>
5dd9863
+#include <selinux/context.h>
22cc213
+#include <selinux/avc.h>
22cc213
+#include <selinux/flask.h>
22cc213
+#include <selinux/av_permissions.h>
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 
75d0e82
 /*
5dd9863
  * Local globals...
22cc213
@@ -1032,6 +1043,23 @@
5dd9863
     cupsdSetString(&job->dest, dest);
75d0e82
   }
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
5dd9863
+  if ((attr = ippFindAttribute(job->attrs, "security-context", IPP_TAG_NAME)) != NULL)
5dd9863
+    cupsdSetString(&job->scon, attr->values[0].string.text);
5dd9863
+  else if (is_lspp_config())
5dd9863
+  {
5dd9863
+   /*
5dd9863
+    * There was no security context so delete the job
5dd9863
+    */
5dd9863
+    cupsdLogMessage(CUPSD_LOG_ERROR, "LoadAllJobs: Missing or bad security-context attribute in control file \"%s\"!",
5dd9863
+                    jobfile);
5dd9863
+    ippDelete(job->attrs);
5dd9863
+    job->attrs = NULL;
5dd9863
+    unlink(jobfile);
5dd9863
+    return;
5dd9863
+  }
75d0e82
+#endif /* WITH_LSPP */
75d0e82
+
5dd9863
   job->sheets     = ippFindAttribute(job->attrs, "job-media-sheets-completed",
5dd9863
                                      IPP_TAG_INTEGER);
5dd9863
   job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
22cc213
@@ -1341,6 +1369,11 @@
22cc213
 {
22cc213
   char		filename[1024];		/* Job control filename */
22cc213
   cups_file_t	*fp;			/* Job file */
22cc213
+#ifdef WITH_LSPP
22cc213
+  security_context_t	spoolcon;	/* context of the job control file */
22cc213
+  context_t		jobcon;		/* contex_t container for job->scon */
22cc213
+  context_t		tmpcon;		/* temp context to swap the level */
22cc213
+#endif /* WITH_LSPP */
22cc213
 
22cc213
 
22cc213
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p",
c5c7073
@@ -1359,6 +1392,53 @@
22cc213
   fchmod(cupsFileNumber(fp), 0600);
22cc213
   fchown(cupsFileNumber(fp), RunUser, Group);
22cc213
 
22cc213
+#ifdef WITH_LSPP
6bb98ac
+  if (strncmp(job->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
22cc213
+  {
6bb98ac
+    if (getfilecon(filename, &spoolcon) == -1)
6bb98ac
+    {
6bb98ac
+      cupsdLogMessage(CUPSD_LOG_ERROR,
6bb98ac
+                      "Unable to get context of job control file \"%s\" - %s.",
6bb98ac
+                      filename, strerror(errno));
6bb98ac
+      return;
6bb98ac
+    }
6bb98ac
+    jobcon = context_new(job->scon);
6bb98ac
+    tmpcon = context_new(spoolcon);
6bb98ac
+    freecon(spoolcon);
c5c7073
+    if (!jobcon || !tmpcon)
c5c7073
+    {
c5c7073
+      if (jobcon)
c5c7073
+        context_free(jobcon);
c5c7073
+      if (tmpcon)
c5c7073
+        context_free(tmpcon);
c5c7073
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get SELinux contexts");
c5c7073
+      return;
c5c7073
+    }
6bb98ac
+    if (context_range_set(tmpcon, (context_range_get(jobcon))) == -1)
6bb98ac
+    {
6bb98ac
+      cupsdLogMessage(CUPSD_LOG_ERROR,
6bb98ac
+                      "Unable to set the range for job control file \"%s\" - %s.",
6bb98ac
+                      filename, strerror(errno));
6bb98ac
+      context_free(tmpcon);
6bb98ac
+      context_free(jobcon);
6bb98ac
+      return;
6bb98ac
+    }
6bb98ac
+    if (setfilecon(filename, context_str(tmpcon)) == -1)
6bb98ac
+    {
6bb98ac
+      cupsdLogMessage(CUPSD_LOG_ERROR,
6bb98ac
+                      "Unable to set context of job control file \"%s\" - %s.",
6bb98ac
+                      filename, strerror(errno));
6bb98ac
+      context_free(tmpcon);
6bb98ac
+      context_free(jobcon);
6bb98ac
+      return;
6bb98ac
+    }
6bb98ac
+    cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p): new spool file context=%s",
6bb98ac
+                    job, context_str(tmpcon));
22cc213
+    context_free(tmpcon);
22cc213
+    context_free(jobcon);
22cc213
+  }
22cc213
+#endif /* WITH_LSPP */
22cc213
+
22cc213
   job->attrs->state = IPP_IDLE;
22cc213
 
22cc213
   if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL,
c5c7073
@@ -2487,6 +2567,21 @@
22cc213
 					/* RIP_MAX_CACHE env variable */
5dd9863
   static char		*options = NULL;/* Full list of options */
5dd9863
   static int		optlength = 0;	/* Length of option buffer */
75d0e82
+#ifdef WITH_LSPP
5dd9863
+  const char		*mls_label = NULL;	/* SL to put in classification env var */
9ad376b
+  char			*label_template = NULL;	/* SL to put in classification env var */
5dd9863
+  char			*audit_message = NULL;	/* Audit message string */
5dd9863
+  char			*printerfile = NULL;	/* Device file pointed to by the printer */
22cc213
+  context_t		jobcon;		/* SELinux context of the job */
22cc213
+  security_id_t		clisid;		/* SELinux SID for the client */
22cc213
+  security_id_t		psid;		/* SELinux SID for the printer */
22cc213
+  context_t		printercon;	/* Printer's context string */
22cc213
+  security_context_t	devcon;		/* Printer's SELinux context */
22cc213
+  struct av_decision	avd;		/* Pointer to the access decision */
22cc213
+  struct avc_entry_ref	avcref;		/* Pointer to the access vector cache */
22cc213
+  security_class_t	tclass;		/* Object class for the SELinux check */
22cc213
+  access_vector_t	avr;		/* Access method being requested */
75d0e82
+#endif /* WITH_LSPP */
75d0e82
 
75d0e82
 
5dd9863
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job: id = %d, file = %d/%d",
c5c7073
@@ -2740,6 +2835,77 @@
75d0e82
 
5dd9863
   cupsdLogMessage(CUPSD_LOG_DEBUG, "banner_page = %d", banner_page);
75d0e82
 
75d0e82
+#ifdef WITH_LSPP
5dd9863
+  if (is_lspp_config())
5dd9863
+  {
5dd9863
+   /*
5dd9863
+    * Perform an access check before printing, but only if the printer starts with /dev/
5dd9863
+    */
9ad376b
+    printerfile = strstr(printer->device_uri, "/dev/");
22cc213
+    if (printerfile == NULL && (strncmp(printer->device_uri, "file:/", 6) == 0))
22cc213
+      printerfile = strdup(printer->device_uri + strlen("file:/"));
75d0e82
+
9ad376b
+    if (printerfile != NULL)
5dd9863
+    {
22cc213
+      cupsdLogMessage(CUPSD_LOG_DEBUG,
22cc213
+                      "StartJob: Attempting to check access on printer device %s", printerfile);
22cc213
+      tclass = SECCLASS_FILE;
22cc213
+      avr = FILE__WRITE;
22cc213
+      avc_init("cupsd_dequeue_", NULL, NULL, NULL, NULL);
22cc213
+      avc_entry_ref_init(&avcref);
22cc213
+      if (avc_context_to_sid(job->scon, &clisid) != 0)
5dd9863
+      {
22cc213
+        cupsdLogMessage(CUPSD_LOG_ERROR,
22cc213
+                        "StartJob: Unable to determine the SELinux sid for the job");
bd257fc
+        cupsdCancelJob(job, 0, IPP_JOB_ABORTED);
22cc213
+        return ;
5dd9863
+      }
22cc213
+      if (getfilecon(printerfile, &devcon) == -1)
22cc213
+      {
22cc213
+        cupsdLogMessage(CUPSD_LOG_ERROR, "StartJob: Unable to get the SELinux context of %s",
22cc213
+                        printerfile);
22cc213
+        cupsdCancelJob(job, 0, IPP_JOB_ABORTED);
22cc213
+        return ;
22cc213
+      }
22cc213
+      printercon = context_new(devcon);
22cc213
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "StartJob: printer context %s client context %s",
22cc213
+                      context_str(printercon), job->scon);
22cc213
+      context_free(printercon);
75d0e82
+
22cc213
+      if (avc_context_to_sid(devcon, &psid) != 0)
22cc213
+      {
22cc213
+        cupsdLogMessage(CUPSD_