7084880 CUPS functionality for TX lp interfaces
authorsonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM>
Thu, 12 Apr 2012 19:27:21 -0700
changeset 769 68e4ba640241
parent 768 36b9bbfcf449
child 770 f112e7923000
7084880 CUPS functionality for TX lp interfaces
components/cups/Solaris/tsol_banner.ps
components/cups/Solaris/tsol_separator.ps
components/cups/Solaris/tsol_trailer.ps
components/cups/cups-license
components/cups/cups.p5m
components/cups/patches/16-tx.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/cups/Solaris/tsol_banner.ps	Thu Apr 12 19:27:21 2012 -0700
@@ -0,0 +1,7 @@
+%
+% Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+%
+% works in conjunction with tsol_separator.ps to do a banner page
+%
+
+SeparatorPagesDict  /Banner get exec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/cups/Solaris/tsol_separator.ps	Thu Apr 12 19:27:21 2012 -0700
@@ -0,0 +1,619 @@
+%%
+%% Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+%%
+
+%%
+%% This PostScript file is used as input to tsol_labeled_banner,
+%% which will prepend code to set the values of a number of
+%% variables.
+
+%% This PostScript file may be modified for local customizations or
+%% internationalization.  Comments marked "INTERNATIONALIZE:" show 
+%% places where changes may be made for internationalization.  Comments
+%% marked "CUSTOMIZE:" show places where some typical customization
+%% changes may be made.
+
+
+%% The following comments describe variables set by tsol_labeled_banner 
+
+%% These variables are from the print job information that can be
+%% displayed with lpstat or lpq.
+%% 
+%%   /Job_Classification   The classification (from the sensitivity label) to 
+%%                    be displayed at the top and bottom of the banner
+%%   /Job_Printer     Printer Name
+%%   /Job_Host        Host job was submitted from
+%%   /Job_User        User who submitted the job
+%%   /Job_JobID       Job number
+%%   /Job_Title       Job title
+%% 
+%% Job Page labels are added in pstops filter, so page labels should not be
+%% added here.
+%% 
+%%   /Job_DoPageLabels Print page labels NO.
+%% 
+%% These variables are generated from the system clock value.
+%% 
+%%   /Job_Date        Date and time the job is being printed, in the
+%%                    locale's default format
+%%   /Job_Hash        A randomly generatred identifying number for 
+%%                    matching up the banner and trailer pages of the job
+%% 
+%% 
+%% The following variables are the job's labels
+%% as interpreted by the bcltobanner(3TSOL) library routine.
+%% 
+%%   /Job_Classification   The classification (from the sensitivity label) to be
+%%                    displayed at the top and bottom of the banner page.
+%%   /Job_Protect     The sensitivity label to be displayed in the protect-as 
+%%                    field.
+%%   /Job_Caveats     The caveats from the sesitivity label.
+%%   /Job_Channels    The channels from the sesitivity label.
+%% 
+%% 
+%% The following variables are the job's Sensitivity Label and
+%% Information Label as interpreted by the bsltos and biltos library
+%% routines.
+%% 
+%%   /Job_SL_Internal The sensitivity label in internal view format.
+%%   /Job_SL_External The sensitivity label in external view format.
+
+/SeparatorPagesDict 100 dict def
+userdict /JobDict known not {
+  userdict /JobDict 100 dict put
+} if
+
+SeparatorPagesDict
+begin
+
+    %% CUSTOMIZE: To print header page label left-justified, set this to false
+    /center_label true def	
+
+    /center_show where {
+	pop
+    } {
+	userdict /center_show
+	{
+	    dup stringwidth exch
+	    2 div neg exch rmoveto show
+	} put
+    } ifelse
+
+    /append where
+    { pop }
+    {
+    /append
+    {
+	1 index length 1 index length add
+	1 index dup type /dicttype eq
+	{
+	pop dict
+	begin
+	    exch { def } forall
+	    { def } forall
+	    currentdict
+	end
+	}
+	{
+	/arraytype eq { array } { string } ifelse
+	dup 4 -1 roll 1 index copy length 4 -1 roll putinterval
+	}
+	ifelse
+    } def
+    } ifelse
+
+    /fontheight
+    systemdict /fontheight known
+    { systemdict /fontheight get }
+    {
+	{
+	gsave
+	    setfont (qf) true charpath flattenpath pathbbox
+	    4 -1 roll pop exch pop exch sub
+	grestore
+	}
+    } ifelse
+    def
+
+    /m { moveto } def
+    /r { rmoveto } def
+    /rl { rlineto } def
+
+    /NewLine {
+    currentpoint exch pop
+    currentfont fontheight sub errorx0 exch moveto
+    } def
+
+    /clipSL {
+	/MaxWidth exch def
+	dup stringwidth pop MaxWidth gt {
+	    {
+		dup stringwidth pop (<-) stringwidth pop add MaxWidth le {exit} if
+		dup 0 exch length 1 sub getinterval
+	    } loop 
+	    (<-)
+	    %% Concatenate strings
+	    dup length 2 index length add 1 index pop string
+	    dup 0 4 index putinterval
+	    dup 4 -1 roll length 4 -1 roll  putinterval
+	} if
+    } def
+
+    /BreakWithBlanks {
+
+	{restoftext ( ) search
+	    {
+	    /blank_nextword exch def pop
+		/blank_restoftext exch def
+		/blank_wordwidth blank_nextword stringwidth pop def
+
+		    restoftext (/) search
+		    {
+			    /slash_nextword exch def pop
+			    /slash_restoftext exch def
+			    /slash_wordwidth slash_nextword stringwidth pop def
+
+			    blank_wordwidth slash_wordwidth lt
+			    {
+				    /nextword blank_nextword def
+				    /restoftext blank_restoftext def
+				    /wordwidth blank_wordwidth def
+				    /breakwidth ( ) stringwidth pop def
+			    }
+			    {
+				    /nextword slash_nextword def
+				    /restoftext slash_restoftext def
+				    /wordwidth slash_wordwidth def
+				    /breakwidth (/) stringwidth pop def
+			    }ifelse
+		    }
+		    {
+			    pop
+			    /nextword blank_nextword def
+			    /restoftext blank_restoftext def
+			    /wordwidth blank_wordwidth def
+			    /breakwidth ( ) stringwidth pop def
+		    }ifelse
+
+	    curwidth wordwidth add linewidth gt
+	    {textstring startchar
+		lastwordbreak startchar sub
+		getinterval proc
+	    /startchar lastwordbreak def
+	    /curwidth wordwidth breakwidth add def }
+
+	    {/curwidth curwidth wordwidth add
+		breakwidth add def
+	    } ifelse
+	    /lastwordbreak lastwordbreak
+	    nextword length add 1 add def
+	    }
+	    {pop BreakWithSlashes exit}
+	    ifelse
+	}loop
+}def
+
+    /BreakWithSlashes
+      {
+	/breakchar (/) def
+	/breakwidth breakchar stringwidth pop def
+	{restoftext breakchar search
+	    {/nextword exch def pop
+	    /restoftext exch def
+	    /wordwidth nextword stringwidth pop def
+
+	    curwidth wordwidth add linewidth gt
+	    {textstring startchar
+		lastwordbreak startchar sub
+		getinterval proc
+	    /startchar lastwordbreak def
+	    /curwidth wordwidth breakwidth add def }
+
+	    {/curwidth curwidth wordwidth add
+		breakwidth add def
+	    } ifelse
+	    /lastwordbreak lastwordbreak
+	    nextword length add 1 add def
+	    }
+	    {pop exit}
+	    ifelse
+	}loop
+      }def
+
+    /BreakIntoLines
+      {/proc exch def
+	/linewidth exch 40 sub def
+	/textstring exch def
+
+	/curwidth 0 def
+	/lastwordbreak 0 def
+	/startchar 0 def
+	/restoftext textstring def
+
+    % begin scale the font if necessary
+
+	/allowedarea linewidth fbh 10 div mul def
+	/currentarea currentfont fontheight textstring stringwidth pop mul def
+
+	currentarea allowedarea gt
+	{
+		currentfont allowedarea currentarea div scalefont setfont
+	}if
+
+    % end scale the font if necessary
+
+	BreakWithBlanks
+	/lastchar textstring length def
+	textstring startchar lastchar startchar sub
+	getinterval proc
+      }def
+
+
+    /ShowBanner {
+	JobDict /Job_Proclam? get {
+	systemdict /showpage get cvx exec
+	} if
+    } def
+
+    /Init {
+
+    initgraphics
+    /#copies 1 def
+    initmatrix
+    erasepage
+
+    clippath pathbbox /fbh exch def
+    /fbw exch def
+    pop pop newpath
+    0 0 moveto
+    0 fbh translate
+    0 0 moveto
+
+    /margin fbh 20 div def
+    /imargin margin 1.1 mul def
+    /errorx0 imargin def
+    /errorx1 fbw imargin sub def
+    /errory1 imargin def
+
+    gsave
+    } def
+
+% this stuff is lpd dependant.
+
+    /lpdglue {
+    userdict
+    begin
+	JobDict
+	begin
+	% If Job_Printer is defined, assume the others are too,
+	/Job_Printer where
+	{
+	    pop
+	    /Job_Proclam? true def
+	    /Job_Endclam? true def
+
+	    /Printer Job_Printer def
+	    /Host Job_Host def
+	    /User Job_User def
+	    /Title Job_Title def
+	    /JobID Job_JobID def
+	    /Date Job_Date def
+
+	    %% CUSTOMIZE: To use a different string at the top and 
+	    %% bottom of each page, change the following line.  For
+	    %% instance, to use the sensitivity label in external view
+	    %% format, change the line to: /PageLabel Job_SL_External def
+	    %% To eliminate page labels completely, change this line to 
+	    %% set the page label to an empty string: /PageLabel () def
+	    /PageLabel Job_SL_Internal def
+	    Job_Protect () eq
+		{
+		    %% Job_Protect is empty because SLs are turned 
+		    %% off in secconf.  (Turning off SLs is actually not yet
+		    %% supported by the system.)
+		    /Protect () def
+		    /Protect_Text1 () def
+		    /Protect_Text2 () def
+		}
+		{
+		    %% INTERNATIONALIZE/CUSTOMIZE: Replace the text between 
+		    %% parentheses with the appropriate text to display 
+		    %% above and below the SL.
+		    /Protect Job_Protect def
+		    /Protect_Text1 (This output must be protected as:) def
+		    /Protect_Text2 (unless manually reviewed and downgraded.) def
+		} 
+		ifelse
+
+	    %% CUSTOMIZE:  To not print the caveats, change 
+	    %% this line to /Caveats () def
+	    /Caveats Job_Caveats def
+	    %% CUSTOMIZE:  To not print the channels, change 
+	    %% this line to /Channels () def
+	    /Channels Job_Channels def
+
+	    %% CUSTOMIZE:  To not print the hash number, change 
+	    %% this line to /Hash () def
+	    /Hash Job_Hash def
+
+	    %% CUSTOMIZE:  To not print the head label, change 
+	    %% this line to /HeadLabel () def
+	    %% You may also substitute another string.  For example, to use
+	    %% the SL in internal view format: /HeadLabel Job_SL_Internal def
+	    /HeadLabel Job_Classification def
+	} {
+	    /Job_Proclam? false def
+	    /Job_Endclam? false def
+	} ifelse
+	end
+    end
+    } def
+
+    /border {
+	gsave
+		setlinewidth
+		setgray
+		30 -20 moveto
+		0 60 fbh sub rlineto
+		fbw 60 sub 0 rlineto
+		0 fbh 60 sub rlineto
+		60 currentlinewidth 2 div sub fbw sub 0 rlineto
+		stroke
+	grestore
+    } def
+
+    /TSOLJobInfo {
+    gsave
+
+		/fontscale fbh 50 div def
+		/Courier-Bold findfont fontscale scalefont setfont
+	    	/ClippedLabel
+			JobDict /HeadLabel get 
+			SeparatorPagesDict /fbw get 90 sub
+			SeparatorPagesDict /clipSL get exec 
+			def
+
+		/head_len {
+			ClippedLabel stringwidth pop 5 add
+			HeadLabel () eq { pop 0 } if
+		} def
+		15 setlinewidth
+		fbw 2 div head_len 2 div sub -20 moveto
+		head_len 0 rlineto stroke
+		1 setgray
+		fbw 10 div -25 m gsave ClippedLabel
+			currentpoint exch pop fbw 2 div exch moveto
+		center_show NewLine grestore
+
+		0 setgray
+		/fontscale fbh 70 div def
+
+		/Helvetica findfont fontscale scalefont setfont
+		0 fbh 8 div neg r Protect_Text1
+			currentpoint exch pop 
+		center_label {
+			fbw 2 div exch moveto center_show
+		}
+		{
+			fbw 10 div exch moveto show
+		}
+		ifelse
+		/fontscale fbh 60 div def
+		/Helvetica-Bold findfont fontscale scalefont setfont
+
+		0 fbh 150 div neg r
+		Protect
+		fbw errorx0 3 mul sub	% width minus margins
+
+		center_label {
+			{NewLine currentpoint exch pop fbw 2 div exch moveto center_show}
+				BreakIntoLines
+		}
+		{
+			{NewLine currentpoint exch pop fbw 10 div exch moveto show}
+				BreakIntoLines
+		} 
+		ifelse
+
+		/fontscale fbh 70 div def
+		/Helvetica findfont fontscale scalefont setfont
+		0 fbh 50 div neg r Protect_Text2
+			currentpoint exch pop 
+		center_label {
+			fbw 2 div exch moveto center_show
+		}
+		{
+			fbw 10 div exch moveto show
+		}
+		ifelse
+
+		/fontscale fbh 60 div def
+		/Helvetica-Bold findfont fontscale scalefont setfont
+		0 fbh 200 div neg r
+
+		0 fbh 10 div neg r
+
+		/fontscale fbh 40 div def
+		/Helvetica-Bold findfont fontscale scalefont setfont
+
+		0 fbh 30 div neg r gsave 
+			%% INTERNATIONALIZE: Replace the text between
+			%% parentheses with the appropriate text.
+			(User:  ) User (@) Host append append append
+			currentpoint exch pop fbw 2 div exch moveto center_show
+			NewLine grestore
+		0 fbh 30 div neg r gsave 
+			%% INTERNATIONALIZE: Replace the text between
+			%% parentheses with the appropriate text.
+			(Job:  ) JobID append
+			currentpoint exch pop fbw 2 div exch moveto center_show
+			NewLine grestore
+		0 fbh 30 div neg r gsave 
+			Title
+			currentpoint exch pop fbw 2 div exch moveto center_show
+			NewLine grestore
+		/fontscale fbh 70 div def
+		/Helvetica findfont fontscale scalefont setfont
+		0 fbh 30 div neg r gsave 
+			%% INTERNATIONALIZE: Replace the text between
+			%% parentheses with the appropriate text.
+			(Printed at:  ) Date append
+			currentpoint exch pop fbw 2 div exch moveto center_show
+			NewLine grestore
+		0 fbh 30 div neg r gsave
+			%% INTERNATIONALIZE: Replace the text between
+			%% parentheses with the appropriate text.
+			(Printer queue:  ) Printer append
+			currentpoint exch pop fbw 2 div exch moveto center_show
+			NewLine grestore
+
+		/Helvetica-Bold findfont fontscale scalefont setfont
+		0 fbh 20 div neg r
+		Caveats
+		fbw errorx0 3 mul sub	% width minus margins
+		{NewLine currentpoint exch pop fbw 2 div exch moveto center_show}
+		BreakIntoLines
+
+		0 fbh 30 div neg r
+		Channels
+		fbw errorx0 3 mul sub	% width minus margins
+		{NewLine currentpoint exch pop fbw 2 div exch moveto center_show}
+		BreakIntoLines
+
+		/fontscale fbh 50 div def
+		/Courier-Bold findfont fontscale scalefont setfont
+		15 setlinewidth
+		fbw 2 div head_len 2 div sub 40 fbh sub moveto
+		head_len 0 rlineto stroke
+		1 setgray
+		fbw 10 div 35 fbh sub m gsave ClippedLabel
+			currentpoint exch pop fbw 2 div exch moveto center_show
+	    NewLine grestore
+
+	grestore
+    } def
+
+    /JobHashInfo {
+    gsave
+		0 setgray
+		/fontscale fbh 50 div def
+		/Helvetica-Bold findfont fontscale scalefont setfont
+
+		%% Upper left corner
+		Hash
+		fbw 12 div 50 neg m gsave show grestore
+
+		%% Lower left corner
+		Hash
+		fbw 12 div fbh 60 sub neg m gsave show grestore
+
+		%% Lower right corner
+		Hash dup stringwidth pop
+		fbw 11 mul 12 div exch sub fbh 60 sub neg m gsave show grestore
+
+		%% Upper right corner
+		Hash dup stringwidth pop
+		fbw 11 mul 12 div exch sub 50 neg m gsave show grestore
+
+		/fontscale fbh 40 div def
+		/Helvetica-Bold findfont fontscale scalefont setfont
+		fbw 10 div 120 fbh sub m gsave 
+		currentpoint exch pop fbw 2 div exch moveto center_show
+
+	grestore
+    } def
+
+
+    /jobproclam {
+    JobDict
+    begin
+	Job_Proclam?
+	%% INTERNATIONALIZE: Replace the text between
+	%% parentheses with the appropriate text.
+	{ TSOLJobInfo (JOB START) JobHashInfo}
+	{ 0 -100 rmoveto }
+	ifelse
+    end
+    } def
+
+    /jobendclam {
+	JobDict
+	begin
+	    Job_Endclam?
+	%% INTERNATIONALIZE: Replace the text between
+	%% parentheses with the appropriate text.
+	{ TSOLJobInfo (JOB END) JobHashInfo}
+	{ 0 -100 rmoveto }
+	ifelse
+    end
+    } def
+
+
+    /JobProclam {
+	jobproclam
+    } def
+
+    /JobEndclam {
+	jobendclam
+    } def
+
+% A fancy box around page
+
+    /BannerBorder {
+       .7 16 border
+    } def
+
+    /TrailerBorder {
+       0 4 border
+    } def
+
+%
+% -------------------------------------------------------------------------
+%
+%   The structure of separator pages is defined below. This is invoked by
+%   using a line like:
+%
+%   SeparatorPagesDict /Banner get exec
+%
+
+    /Banner {
+    SeparatorPagesDict
+    begin
+	Init
+	lpdglue
+	BannerBorder
+	JobProclam
+    end
+    } def
+
+    /Trailer {
+    SeparatorPagesDict
+    begin
+	Init
+	lpdglue
+	TrailerBorder
+	JobEndclam
+    end
+    } def
+
+    /SkipPageLabels false def
+end
+
+SeparatorPagesDict begin
+	clippath pathbbox /fbh exch def
+	/fbw exch def
+	pop pop
+	lpdglue
+end
+
+
+JobDict /Job_DoPageLabels get (YES) eq 
+    JobDict /PageLabel get () ne and {
+    userdict begin
+	/showpage {
+		systemdict /showpage get cvx exec
+	} bind def
+    end
+}if
+
+%% End of tsol_separator.ps
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/cups/Solaris/tsol_trailer.ps	Thu Apr 12 19:27:21 2012 -0700
@@ -0,0 +1,6 @@
+%
+% Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+%
+% used in conjunction with tsol_separator.ps to create a trailer page
+%
+SeparatorPagesDict  /Trailer get exec
--- a/components/cups/cups-license	Thu Apr 12 10:33:43 2012 -0700
+++ b/components/cups/cups-license	Thu Apr 12 19:27:21 2012 -0700
@@ -2047,4 +2047,26 @@
     Unicode Standard, and to make copies of this file in any form for
     internal or external distribution as long as this notice remains
     attached.
+--------------------------------------------------------------------------------
 
+    Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+
+    This PostScript file is used as input to tsol_labeled_banner,
+    which will prepend code to set the values of a number of
+    variables.
+
+    This PostScript file may be modified for local customizations or
+    internationalization.  Comments marked "INTERNATIONALIZE:" show 
+    places where changes may be made for internationalization.  Comments
+    marked "CUSTOMIZE:" show places where some typical customization
+    changes may be made.
+--------------------------------------------------------------------------------
+
+    Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+
+    used in conjunction with tsol_separator.ps to create a trailer page
+--------------------------------------------------------------------------------
+
+    Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+
+    works in conjunction with tsol_separator.ps to do a banner page
--- a/components/cups/cups.p5m	Thu Apr 12 10:33:43 2012 -0700
+++ b/components/cups/cups.p5m	Thu Apr 12 19:27:21 2012 -0700
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 # This is the template for package manifest (.p5m) file
@@ -275,6 +275,9 @@
 file path=usr/lib/cups/filter/rastertolabel
 file path=usr/lib/cups/filter/rastertopclx
 file path=usr/lib/cups/filter/texttops
+file Solaris/tsol_banner.ps path=usr/lib/cups/filter/tsol_banner.ps
+file Solaris/tsol_separator.ps path=usr/lib/cups/filter/tsol_separator.ps
+file Solaris/tsol_trailer.ps path=usr/lib/cups/filter/tsol_trailer.ps
 file path=usr/lib/cups/monitor/bcp
 file path=usr/lib/cups/monitor/tbcp
 file path=usr/lib/cups/notifier/dbus
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/cups/patches/16-tx.patch	Thu Apr 12 19:27:21 2012 -0700
@@ -0,0 +1,1453 @@
+--- filter/Makefile	Fri Apr 23 11:56:34 2010
++++ filter/Makefile	Mon Apr  2 15:58:21 2012
+@@ -56,7 +56,7 @@
+ 		bannertops.o commandtops.o gziptoany.o imagetops.o \
+ 		imagetoraster.o common.o pdftops.o pstext.o pstops.o \
+ 		rasterbench.o rastertoepson.o rastertohp.o rastertolabel.o \
+-		testimage.o testraster.o textcommon.o texttops.o
++		testimage.o testraster.o textcommon.o texttops.o tsol_labeled_banner.o
+ 
+ 
+ #
+@@ -281,10 +281,10 @@
+ # bannertops
+ #
+ 
+-bannertops:	bannertops.o pstext.o common.o ../cups/$(LIBCUPS) $(LIBCUPSIMAGE)
++bannertops:	bannertops.o pstext.o common.o tsol_labeled_banner.o ../cups/$(LIBCUPS) $(LIBCUPSIMAGE)
+ 	echo Linking $@...
+-	$(CC) $(LDFLAGS) -o $@ bannertops.o pstext.o common.o $(LINKCUPSIMAGE) \
+-		$(IMGLIBS) $(LIBS)
++	$(CC) $(LDFLAGS) -o $@ bannertops.o pstext.o common.o tsol_labeled_banner.o $(LINKCUPSIMAGE) \
++		$(IMGLIBS) $(LIBS) -ltsol
+ 
+ 
+ #
+@@ -421,11 +421,11 @@
+ # imagetops
+ #
+ 
+-imagetops:	imagetops.o common.o $(LIBCUPSIMAGE) \
++imagetops:	imagetops.o common.o tsol_labeled_banner.o $(LIBCUPSIMAGE) \
+ 		../cups/$(LIBCUPS)
+ 	echo Linking $@...
+-	$(CC) $(LDFLAGS) -o $@ imagetops.o common.o $(LINKCUPSIMAGE) \
+-		$(IMGLIBS) $(LIBS)
++	$(CC) $(LDFLAGS) -o $@ imagetops.o common.o tsol_labeled_banner.o $(LINKCUPSIMAGE) \
++		$(IMGLIBS) $(LIBS) -ltsol
+ 
+ 
+ #
+@@ -443,9 +443,9 @@
+ # pstops
+ #
+ 
+-pstops:	pstops.o common.o ../cups/$(LIBCUPS)
++pstops:	pstops.o common.o tsol_labeled_banner.o ../cups/$(LIBCUPS)
+ 	echo Linking $@...
+-	$(CC) $(LDFLAGS) -o $@ pstops.o common.o $(LIBS) -lm
++	$(CC) $(LDFLAGS) -o $@ pstops.o common.o tsol_labeled_banner.o $(LIBS) -lm -ltsol
+ 
+ 
+ #
+--- filter/common.c	Wed Jul 11 14:46:42 2007
++++ filter/common.c	Mon Apr  2 17:33:51 2012
+@@ -49,7 +49,37 @@
+ 	PageWidth = 612.0f,		/* Total page width */
+ 	PageLength = 792.0f;		/* Total page length */
+ 
++#if defined(HAVE_TSOL)
++char *ClippedLabel = "\
++     /ClippedLabel{ \n\
++        ESPpl length 80 lt { \n\
++          ESPpl \n\
++        } \n\
++        { \n\
++          ESPpl 0 80 getinterval \n\
++          (->) \n\
++          append \n\
++        } ifelse \n\
++     }bind put \n\
++";
+ 
++char *append = "\
++     /append{ \n\
++        2 copy length exch length add \n\
++        string dup \n\
++        4 2 roll \n\
++        2 index 0 3 index \n\
++        putinterval \n\
++        exch length exch putinterval \n\
++     } bind def \n\
++";
++
++char *ESPpf = "\
++     /ESPpf /Courier-Bold findfont 12 scalefont put \n\
++";
++
++#endif /* HAVE_TSOL */
++
+ /*
+  * 'SetCommonOptions()' - Set common filter options for media size, etc.
+  */
+@@ -299,7 +329,77 @@
+ }
+ 
+ 
++#if defined(HAVE_TSOL)
+ /*
++ * 'tsol_WriteLabelProlog()' - Write the prolog with the page label
++ *			       for labeled system.
++ */
++void
++tsol_WriteLabelProlog(const char   *label,	/* I - Page label */
++		   float        bottom,	/* I - Bottom position in points */
++		   float        top,	/* I - Top position in points */
++		   float        width)	/* I - Width in points */
++{
++  const char	*ptr;			/* Temporary string pointer */
++
++
++ /*
++  * If there is nothing to show, bind an empty 'write labels' procedure
++  * and return...
++  */
++
++  if (label == NULL || !label[0])
++  {
++    puts("userdict/ESPwl{}bind put\n");
++    return;
++  }
++
++ /*
++  * Set the page label string...
++  */
++  puts("userdict");
++  puts("/ESPpl(");
++
++  if (label)
++    puts(label);
++
++  puts(")put\n");
++
++  puts("userdict");
++  puts(ClippedLabel);
++  puts(append);
++
++  puts("\n");
++
++ /*
++  * Then get a 12 point Courier-Bold font...
++  */
++
++  puts("userdict");
++  puts(ESPpf);
++
++ /*
++  * Finally, the procedure to write the labels on the page...
++  */
++
++  puts("userdict/ESPwl{\n");
++  puts("  ESPpf setfont\n");
++  printf("  ClippedLabel stringwidth pop dup 12 add exch -0.5 mul %.0f add\n",
++	width * 0.5f);
++  puts("  0 setgray\n");
++  printf("  dup 6 sub %.0f 3 index 10 ESPrf\n", bottom - 1.0);
++  printf("  dup 6 sub %.0f 3 index 10 ESPrf\n", top - 19.0);
++  puts("  1 setgray\n");
++  printf("  dup 6 sub %.0f 3 index 10 ESPrs\n", bottom - 1.0);
++  printf("  dup 6 sub %.0f 3 index 10 ESPrs\n", top - 19.0);
++  printf("  dup %.0f moveto ClippedLabel show\n", bottom + 1.0);
++  printf("  %.0f moveto ClippedLabel show\n", top - 17.0);
++  puts("pop\n");
++  puts("}bind put\n");
++}
++#endif /* HAVE_TSOL */
++
++/*
+  * 'WriteLabelProlog()' - Write the prolog with the classification
+  *                        and page label.
+  */
+@@ -441,17 +541,40 @@
+     length = PageLength;
+   }
+ 
+-  switch (orient & 3)
++#ifdef HAVE_TSOL
++  /*
++   * Rotate the label so that it is always top and bottom of the job page.
++   */
++  if (is_system_labeled())
+   {
+-    case 1 : /* Landscape */
++    switch (Orientation)
++    {
++	case 1 : /* Landscape */
++	  printf("0.0 %.1f translate -90 rotate\n", length);
++	  break;
++	case 2 : /* Reverse Portrait */
++	  printf("%.1f %.1f translate 180 rotate\n", width, length);
++	  break;
++	case 3 : /* Reverse Landscape */
++	  printf("%.1f 0.0 translate 90 rotate\n", width);
++	  break;
++    }
++  }
++  else
++#endif /* HAVE_TSOL */
++  {
++    switch (orient & 3)
++    {
++      case 1 : /* Landscape */
+         printf("%.1f 0.0 translate 90 rotate\n", length);
+         break;
+-    case 2 : /* Reverse Portrait */
++      case 2 : /* Reverse Portrait */
+         printf("%.1f %.1f translate 180 rotate\n", width, length);
+         break;
+-    case 3 : /* Reverse Landscape */
++      case 3 : /* Reverse Landscape */
+         printf("0.0 %.1f translate -90 rotate\n", width);
+         break;
++    }
+   }
+ 
+   puts("ESPwl");
+--- filter/common.h	Wed Jul 11 14:46:42 2007
++++ filter/common.h	Mon Apr  2 17:33:51 2012
+@@ -69,7 +69,15 @@
+ extern void	WriteLabels(int orient);
+ extern void	WriteTextComment(const char *name, const char *value);
+ 
++#if defined(HAVE_TSOL)
++extern void	tsol_WriteLabelProlog(const char *label, float bottom,
++				float top, float width);
+ 
++extern char *ClippedLabel;
++extern char *append;
++extern char *ESPpf;
++#endif /* HAVE_TSOL */
++
+ /*
+  * C++ magic...
+  */
+--- filter/bannertops.c	Fri Aug  7 15:28:30 2009
++++ filter/bannertops.c	Mon Apr  2 17:33:51 2012
+@@ -31,6 +31,10 @@
+ #include "image.h"
+ #include <cups/i18n.h>
+ 
++#if defined(HAVE_TSOL)
++/* Trusted Extensions header */
++#include "tsol_labeled_banner.h" 
++#endif /* HAVE_TSOL */
+ 
+ /*
+  * Constants...
+@@ -101,7 +105,6 @@
+ 		*username;		/* Username from command-line */
+   int		num_pages;		/* Number of pages printed */
+ 
+-
+  /*
+   * Make sure status messages are not buffered...
+   */
+@@ -131,7 +134,24 @@
+   num_options = cupsParseOptions(argv[5], 0, &options);
+   banner      = load_banner(argv[6]);
+ 
++#if defined(HAVE_TSOL)
+  /*
++  * Check if it is banner or trailer page
++  */
++  if (is_system_labeled())
++  {
++    /*
++     * If it is banner or trailer page
++     * call tsol_labeled_banner function
++     */
++    if ((cupsGetOption("banner", num_options, options)) ||
++	(cupsGetOption("trailer", num_options, options)))
++      return (tsol_labeled_banner(argc, argv));
++
++  }
++#endif /* HAVE_TSOL */
++
++ /*
+   * Set standard options and get the PPD file for this printer...
+   */
+ 
+--- filter/imagetops.c	Fri Nov 21 11:00:11 2008
++++ filter/imagetops.c	Mon Apr  2 17:33:51 2012
+@@ -30,6 +30,10 @@
+ #include <math.h>
+ #include <cups/i18n.h>
+ 
++#if defined(HAVE_TSOL)
++#include <auth_attr.h>
++#include "tsol_labeled_banner.h"
++#endif /* HAVE_TSOL */
+ 
+ /*
+  * Globals...
+@@ -41,6 +45,10 @@
+ 	Collate = 0,		/* Collate copies? */
+ 	Copies = 1;		/* Number of copies */
+ 
++#if defined(HAVE_TSOL)
++/* nolabels option */
++static int		nolabels = 0;
++#endif /* HAVE_TSOL */ 
+ 
+ /*
+  * Local functions...
+@@ -164,6 +172,17 @@
+ 
+   ppd = SetCommonOptions(num_options, options, 0);
+ 
++#if defined(HAVE_TSOL)
++  /*
++   * Check for 'nolabels' options and if user is authorized
++   * to disable labeling.
++   */
++  if (is_system_labeled()) 
++    if ((extract_options(argv[5], "nolabels")) &&
++       (chkauthattr("solaris.print.unlabeled", argv[2])))
++	  nolabels = 1; 
++#endif /* HAVE_TSOL */
++
+   if ((val = cupsGetOption("multiple-document-handling", num_options, options)) != NULL)
+   {
+    /*
+@@ -632,29 +651,41 @@
+            "ifelse %.3f mul } bind settransfer\n", g, b);
+ 
+   WriteCommon();
+-  switch (Orientation)
++#if defined(HAVE_TSOL)
++  /*
++   * In case of Trusted systems labels should always be written on top
++   * and bottom of the job page irrespective of the orientation.
++   */
++  if (is_system_labeled())
++    tsol_WriteLabelProlog(cupsGetOption("page-label", num_options, options),
++					PageBottom, PageTop, PageWidth);
++  else
++#endif /* HAVE_TSOL */
+   {
+-    case 0 :
+-	WriteLabelProlog(cupsGetOption("page-label", num_options, options),
+-                	 PageBottom, PageTop, PageWidth);
+-        break;
++    switch (Orientation)
++    {
++      case 0 :
++	  WriteLabelProlog(cupsGetOption("page-label", num_options, options),
++                 	   PageBottom, PageTop, PageWidth);
++          break;
+ 
+-    case 1 :
+-	WriteLabelProlog(cupsGetOption("page-label", num_options, options),
+-                	 PageLeft, PageRight, PageLength);
+-        break;
++      case 1 :
++	  WriteLabelProlog(cupsGetOption("page-label", num_options, options),
++                	   PageLeft, PageRight, PageLength);
++          break;
+ 
+-    case 2 :
+-	WriteLabelProlog(cupsGetOption("page-label", num_options, options),
+-                	 PageLength - PageTop, PageLength - PageBottom,
+-			 PageWidth);
+-        break;
++      case 2 :
++	  WriteLabelProlog(cupsGetOption("page-label", num_options, options),
++                	   PageLength - PageTop, PageLength - PageBottom,
++			   PageWidth);
++          break;
+ 
+-    case 3 :
+-	WriteLabelProlog(cupsGetOption("page-label", num_options, options),
+-                	 PageWidth - PageRight, PageWidth - PageLeft,
+-			 PageLength);
+-        break;
++      case 3 :
++	  WriteLabelProlog(cupsGetOption("page-label", num_options, options),
++                	   PageWidth - PageRight, PageWidth - PageLeft,
++			   PageLength);
++          break;
++    }
+   }
+ 
+   if (realcopies > 1)
+@@ -916,7 +947,23 @@
+ 	}
+ 
+ 	puts("grestore");
++#ifdef HAVE_TSOL
++	/*
++	 * Page-label should not be written in case user gives '-o nolabels' option
++	 * and user is authorized to disable page-labels.
++	 *
++	 * 'nolabels' is set to '1' in case user is authorized to disable page-labels.
++	 */
++	if (is_system_labeled())
++        {
++          if (!nolabels)
++	    WriteLabels(0);
++        }
++        else
++          WriteLabels(0);
++#else
+ 	WriteLabels(0);
++#endif /* HAVE_TSOL */
+ 	puts("grestore");
+ 	puts("showpage");
+       }
+--- filter/tsol_labeled_banner.c	Mon Apr  2 16:00:28 2012
++++ filter/tsol_labeled_banner.c	Mon Apr  2 17:33:51 2012
+@@ -0,0 +1,360 @@
++/*
++ * Add TSOL banner, trailer, page header/footers to a print job
++ */
++#include "tsol_labeled_banner.h"
++
++/* typedefs */
++
++typedef int BOOL;
++
++/* constants */
++
++#ifndef FALSE
++#define	FALSE 0
++#endif
++#ifndef TRUE
++#define	TRUE 1
++#endif
++
++#define	ME "tsol_labeled_banner"
++#define	SEPARATORPS "/usr/lib/cups/filter/tsol_separator.ps"
++#define	BANNERPS "/usr/lib/cups/filter/tsol_banner.ps"
++#define	TRAILERPS "/usr/lib/cups/filter/tsol_trailer.ps"
++#define	MAXUSERLEN 32
++#define	MAXHOSTLEN 32
++
++/* prototypes for static functions */
++
++static int ProcessArgs(int argc, char **argv);
++static void ParseUsername(char *input, char *user, char *host);
++static void EmitPSFile(const char *name);
++static BOOL EmitFile(FILE *file);
++static void EmitJobData(void);
++static void EmitPrologue(void);
++static void EmitCommandLineInfo(void);
++static void EmitClockBasedInfo(time_t clock);
++static void EmitLabelInfo(void);
++
++/* static variables */
++
++static char *ArgSeparatorPS;
++static char *ArgBannerPS;
++static char *ArgTrailerPS;
++static char *ArgPrinter;
++static char *ArgJobID;
++static char *ArgUser;
++static char *ArgHost;
++static char *ArgTitle;
++static char *ArgFile;
++static char *ArgOptions;
++static char *ArgCopies;
++static FILE *ArgLogFile;
++static m_label_t *FileLabel;
++static char *plabel;
++static time_t c_time;
++static int banner;
++
++/*
++ * tsol_labeled_banner emits the labeled banner or trailer page
++ * This function gets called from bannertops filter.
++ */
++int
++tsol_labeled_banner(int argc, char *argv[])
++{
++	int	err;
++
++	if (ProcessArgs(argc, argv) != 0)
++		return(1);
++
++	if ((FileLabel = m_label_alloc(MAC_LABEL)) == NULL)
++		return(1);
++	/*
++	 * peer label can be read from CLASSIFICATION environment variable.
++	 * If there is no CLASSIFICATION value, the file label can be
++         * determined from its pathname.
++	 */
++	if ((plabel = getenv("CLASSIFICATION")) != NULL) {
++		m_label_free(FileLabel);
++		FileLabel = NULL;
++		if (str_to_label(plabel, &FileLabel, MAC_LABEL,
++		    L_NO_CORRECTION, &err) == -1) {
++			perror("str_to_label");
++			return(1);
++		}
++	} else if (getlabel(ArgFile, FileLabel) != 0) {
++		(void) fprintf(ArgLogFile,
++		    gettext("%1$s: cannot get label of %2$s: %3$s\n"),
++		    ME, ArgFile, strerror(errno));
++		return(1);
++	}
++
++	/* All of these functions return if they encounter an error */
++	EmitJobData();
++	EmitPSFile(ArgSeparatorPS);
++	
++	/*
++	 * check if banner or trailer
++	 */
++	if (banner)
++		EmitPSFile(ArgBannerPS);
++	else
++		EmitPSFile(ArgTrailerPS); 
++
++	m_label_free(FileLabel);
++	return (0);
++}
++
++static void
++EmitJobData(void)
++{
++	EmitPrologue();
++	EmitCommandLineInfo();
++	EmitClockBasedInfo(c_time);
++	EmitLabelInfo();
++
++	/* Emit ending PostScript code */
++	(void) printf("end\n\n");
++	(void) printf("%%%% End of code generated by tsol_labeled_banner\n\n");
++
++}
++
++static void
++EmitPrologue(void)
++{
++	/* Emit preliminary PostScript code */
++	(void) printf("%%!\n\n");
++	(void) printf("%%%% Begin code generated by tsol_labeled_banner\n\n");
++
++	(void) printf("%%%% Create JobDict if it doesn't exist\n");
++	(void) printf("userdict /JobDict known not {\n");
++	(void) printf("  userdict /JobDict 100 dict put\n");
++	(void) printf("} if\n\n");
++
++	(void) printf("%%%% Define job parameters, including TSOL security "
++	    "info\n");
++	(void) printf("JobDict\n");
++	(void) printf("begin\n");
++}
++
++/* Emit parameters obtained from command line options */
++static void
++EmitCommandLineInfo(void)
++{
++	char user[MAXUSERLEN + 1];
++	char host[MAXHOSTLEN + 1];
++
++	(void) printf("\t/Job_Printer (%s) def\n", ArgPrinter);
++
++	/*
++	 * If ArgHost is localhost, read SERVER_ADMIN env variable to get hostname.
++	 */
++	if(strcmp(ArgHost, "localhost") == 0)
++	{
++		ArgHost = getenv("SERVER_ADMIN");
++		ParseUsername(ArgHost, user, host);
++		(void) printf("\t/Job_Host (%s) def\n", host);
++	} else 
++		(void) printf("\t/Job_Host (%s) def\n", ArgHost);
++
++	(void) printf("\t/Job_User (%s) def\n", ArgUser);
++	(void) printf("\t/Job_JobID (%s-%s) def\n", ArgPrinter, ArgJobID);
++	(void) printf("\t/Job_Title (%s) def\n", ArgTitle);
++	(void) printf("\t/Job_DoPageLabels (NO) def\n");
++	(void) printf("\n");
++}
++
++/* Emit parameters generated from the system clock */
++static void
++EmitClockBasedInfo(time_t c_time)
++{
++	(void) printf("\t/Job_Date (%s) def\n", ctime(&c_time));
++	(void) printf("\t/Job_Hash (%ld) def\n", c_time % 100000L);
++	(void) printf("\n");
++}
++
++/* Emit parameters derived from the SL and IL of the file being printed. */
++static void
++EmitLabelInfo(void)
++{
++	char	*header = NULL;		/* DIA banner page fields */
++	char	*label = NULL;
++	char	*caveats = NULL;
++	char	*channels = NULL;
++	char	*page_label = NULL;	/* interior pages label */
++
++	if (label_to_str(FileLabel, &header, PRINTER_TOP_BOTTOM,
++	    DEF_NAMES) != 0) {
++		(void) fprintf(ArgLogFile,
++		    gettext("%s: label_to_str PRINTER_TOP_BOTTOM: %s.\n"),
++		    ME, strerror(errno));
++		return;
++	}
++	if (label_to_str(FileLabel, &label, PRINTER_LABEL,
++	    DEF_NAMES) != 0) {
++		(void) fprintf(ArgLogFile,
++		    gettext("%s: label_to_str PRINTER_LABEL: %s.\n"),
++		    ME, strerror(errno));
++		return;
++	}
++	if (label_to_str(FileLabel, &caveats, PRINTER_CAVEATS,
++	    DEF_NAMES) != 0) {
++		(void) fprintf(ArgLogFile,
++		    gettext("%s: label_to_str PRINTER_CAVEATS: %s.\n"),
++		    ME, strerror(errno));
++		return;
++	}
++	if (label_to_str(FileLabel, &channels, PRINTER_CHANNELS,
++	    DEF_NAMES) != 0) {
++		(void) fprintf(ArgLogFile,
++		    gettext("%s: label_to_str PRINTER_CHANNELS: %s.\n"),
++		    ME, strerror(errno));
++		return;
++	}
++	if (label_to_str(FileLabel, &page_label, M_LABEL,
++	    LONG_NAMES) != 0) {
++		(void) fprintf(ArgLogFile,
++		    gettext("%s: label_to_str M_LABEL: %s.\n"),
++		    ME, strerror(errno));
++		return;
++	}
++
++	(void) printf("\t/Job_Classification (%s) def\n", header);
++	(void) printf("\t/Job_Protect (%s) def\n", label);
++	(void) printf("\t/Job_Caveats (%s) def\n", caveats);
++	(void) printf("\t/Job_Channels (%s) def\n", channels);
++	(void) printf("\t/Job_SL_Internal (%s) def\n", page_label);
++
++	/* Free memory allocated label_to_str */
++	free(header);
++	free(label);
++	free(caveats);
++	free(channels);
++	free(page_label);
++}
++
++/*
++ * Parse input "host!user" to separate host and user names.
++ */
++
++static void
++ParseUsername(char *input, char *user, char *host)
++{
++	char *cp;
++
++	if ((cp = strchr(input, '@')) != NULL) {
++		/* user@host */
++		(void) strlcpy(host, cp + 1, MAXHOSTLEN + 1);
++		*cp = '\0';
++		(void) strlcpy(user, input, MAXUSERLEN + 1);
++		*cp = '@';
++	} else if ((cp = strchr(input, '!')) != NULL) {
++		/* host!user */
++		(void) strlcpy(user, cp + 1, MAXUSERLEN + 1);
++		*cp = '\0';
++		(void) strlcpy(host, input, MAXHOSTLEN + 1);
++		*cp = '!';
++	} else {
++		/* user */
++		(void) strlcpy(user, input, MAXUSERLEN + 1);
++		host[0] = '\0';
++	}
++}
++
++static BOOL
++EmitFile(FILE *file)
++{
++	int len;
++#define	BUFLEN 1024
++	char buf[BUFLEN];
++
++	while ((len = fread(buf, 1, BUFLEN, file)) > 0) {
++		if (fwrite(buf, 1, len, stdout) != len)
++			return (FALSE);
++	}
++	if (!feof(file))
++		return (FALSE);
++	return (TRUE);
++}
++
++
++static void
++EmitPSFile(const char *name)
++{
++	char path[PATH_MAX];
++	FILE *file;
++	BOOL emitted;
++
++	(void) strlcpy(path, name, sizeof (path));
++
++	file = fopen(path, "r");
++	if (file == NULL) {
++		(void) fprintf(ArgLogFile,
++		    gettext("%s: Error opening PostScript file %s. %s.\n"),
++		    ME, path, strerror(errno));
++		return;
++	}
++
++	emitted = EmitFile(file);
++	(void) fclose(file);
++	if (!emitted) {
++		(void) fprintf(ArgLogFile, gettext(
++		    "%s: Error copying PostScript file %s to stdout.\n"),
++		    ME, path);
++		return;
++	}
++}
++
++
++static int
++ProcessArgs(int argc, char *argv[])
++{
++	/* set default values for arguments */
++	ArgSeparatorPS = SEPARATORPS;
++	ArgBannerPS = BANNERPS;
++	ArgTrailerPS = TRAILERPS;
++	ArgLogFile = stderr;
++	banner = 0;
++
++	ArgPrinter = argv++[0];
++	ArgJobID = argv++[0];
++	ArgUser = argv++[0];
++	ArgTitle = argv++[0];
++	ArgCopies = argv++[0];
++	ArgOptions = argv++[0];
++	ArgFile = argv++[0];
++
++	/*
++	 * Read options string to check if call is for
++	 * banner page. If call is for banner page then
++	 * options string contains 'banner=true'. 
++	 */
++	if(extract_options(ArgOptions, "banner="))
++		banner = 1;
++
++	/*
++	 * Read options string to get the job creation time.
++	 */
++	c_time = atoi(extract_options(ArgOptions, "time-at-creation"));
++
++	/*
++	 * Read options string to get the originating hostname of
++	 * the job.
++	 */
++	ArgHost=extract_options(ArgOptions, "job-originating-host-name=");
++
++	return (0);
++}
++
++/* Check if string 'str' exists in options. */   
++char * extract_options(const char *options, const char *str) {
++	char *chk2 = NULL, *chk1 = NULL;
++	char *optstr = strdup(options);
++
++	chk2 = strstr(optstr, str);
++	if (chk2) {
++        	chk1 = strtok(chk2, "=");
++        	chk2 = strtok(NULL, " ");
++	}
++
++	return chk2;
++}
+--- filter/tsol_labeled_banner.h	Mon Apr  2 16:00:30 2012
++++ filter/tsol_labeled_banner.h	Mon Apr  2 17:33:51 2012
+@@ -0,0 +1,12 @@
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <time.h>
++#include <limits.h>
++#include <errno.h>
++#include <signal.h>
++#include <locale.h>
++#include <tsol/label.h>
++
++int tsol_labeled_banner(int argc, char *argv[]);
++char *extract_options(const char *, const char *);
+--- scheduler/client.c	Mon Apr  2 17:30:50 2012
++++ scheduler/client.c	Mon Apr  2 17:33:51 2012
+@@ -145,6 +145,8 @@
+   if (is_system_labeled()) {
+     ucred_t *cred = NULL;
+     m_label_t *slabel;
++    m_label_t *admin_low = m_label_alloc(MAC_LABEL);
++    m_label_t *admin_high = m_label_alloc(MAC_LABEL);
+ 
+     if (getpeerucred(fd, &cred) == -1)
+       return (-1);
+@@ -151,9 +153,32 @@
+ 
+     slabel = ucred_getlabel(cred);
+     *label = NULL;
+-    if (label_to_str(slabel, label, M_INTERNAL, DEF_NAMES) != 0)
+-      cupsdLogMessage(CUPSD_LOG_ERROR, "getpeercon(%d, 0x%8.8x): %s",
+-                      fd, (int)label, strerror(errno));
++
++    if ((admin_low == NULL) || (admin_high == NULL))
++      cupsdLogMessage(CUPSD_LOG_ERROR, "getpeerseclabel(%d, unable to"
++		      " allocate admin_low/admin_high label", fd);
++    else
++    {
++      bsllow(admin_low);
++      bslhigh(admin_high);
++
++      /*
++       * Remote print requests from the global zone
++       * arrive at admin_low, make them admin_high to
++       * avoid downgrade.
++       */
++      if (blequal(slabel, admin_low))
++      {
++        slabel = admin_high;
++        cupsdLogMessage(CUPSD_LOG_DEBUG, "getpeerseclabel(%d, upgrade"
++		        " admin_low label to admin_high", fd);
++      } 
++
++      if (label_to_str(slabel, label, M_LABEL, DEF_NAMES) != 0)
++        cupsdLogMessage(CUPSD_LOG_ERROR, "getpeerseclabel(%d, 0x%8.8x): %s",
++			fd, (int)label, strerror(errno));
++
++    }
+     ucred_free(cred);
+   }
+ 
+--- scheduler/job.c	Mon Apr  2 17:30:50 2012
++++ scheduler/job.c	Mon Apr  2 17:33:51 2012
+@@ -3193,6 +3193,24 @@
+   for (i = num_pwgppds, pwgppd = pwgppds; i > 0; i --, pwgppd ++)
+     newlength += 1 + strlen(pwgppd->name) + 1 + strlen(pwgppd->value);
+ 
++#if defined(HAVE_TSOL)
++  if (is_system_labeled())
++    if(job->current_file == 0)
++      /*
++       * Increase length to add option ' banner=true' to options string
++       * in case of banner page.
++       */
++      newlength += strlen(" banner=true");
++    else if (job->job_sheets->num_values > 1 &&
++             job->current_file == (job->num_files - 1))
++      /*
++       * Increase length to add option ' trailer=true' to options string
++       * in case of trailer page.
++       */
++      newlength += strlen(" trailer=true");
++
++#endif /* HAVE_TSOL */
++
+  /*
+   * Then allocate/reallocate the option buffer as needed...
+   */
+@@ -3380,6 +3398,24 @@
+ 
+   cupsFreeOptions(num_pwgppds, pwgppds);
+ 
++#if defined(HAVE_TSOL)
++  if (is_system_labeled())
++    if(job->current_file == 0)
++      /*
++       * Add option ' banner=true' to options string
++       * in case of banner page.
++       */
++      strlcat(optptr, " banner=true", 13);
++    else if (/*job->job_sheets->num_values > 1 && */
++             job->current_file == (job->num_files - 1)) 
++      /*
++       * Add option ' trailer=true' to options string
++       * in case of trailer page.
++       */
++      strlcat(optptr, " trailer=true", 14);
++
++#endif /* HAVE_TSOL */
++
+  /*
+   * Return the options string...
+   */
+--- scheduler/printers.c	Mon Apr  2 17:30:50 2012
++++ scheduler/printers.c	Mon Apr  2 17:33:51 2012
+@@ -2676,12 +2676,22 @@
+     ippDelete(oldattrs);
+   }
+ 
++#if defined(HAVE_TSOL)
+  /*
+-  * Force sharing off for remote queues...
++  * Allow sharing for remote queues.
++  * This is required for cascade printing.
+   */
+ 
+-  if (p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT))
+-    p->shared = 0;
++  if ((p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) &&
++       !is_system_labeled())
++#else
++  /*
++   * Force sharing off for remote queues...
++   */
++
++   if (p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT))
++#endif /* HAVE_TSOL */
++    p->shared = 0; 
+   else
+   {
+    /*
+--- berkeley/lpq.c	Thu Apr  5 11:12:37 2012
++++ berkeley/lpq.c	Thu Apr  5 11:30:46 2012
+@@ -77,7 +77,6 @@
+ 
+   http       = NULL;
+   dest       = NULL;
+-  user       = NULL;
+   id         = 0;
+   interval   = 0;
+   longstatus = 0;
+@@ -84,6 +83,12 @@
+   all        = 0;
+   num_dests  = 0;
+   dests      = NULL;
++#if defined (HAVE_TSOL)
++  if (is_system_labeled())
++    user = cupsUser();
++  else
++#endif /* HAVE_TSOL */
++    user = NULL;
+ 
+   for (i = 1; i < argc; i ++)
+     if (argv[i][0] == '+')
+--- scheduler/auth.c	Wed Oct  6 13:07:44 2010
++++ scheduler/auth.c	Fri Apr  6 10:37:14 2012
+@@ -2253,8 +2253,38 @@
+ #endif /* HAVE_AUTHORIZATION_H */
+     {
+       if (best->satisfy == CUPSD_AUTH_SATISFY_ALL || auth == CUPSD_AUTH_DENY)
++      {
++#if defined(HAVE_TSOL)
++	if (is_system_labeled())
++	{
++	  /*
++	   * Read requesting-user-name attribute.
++	   */
++	  ipp_attribute_t *attr = ippFindAttribute(con->request,
++				"requesting-user-name", IPP_TAG_NAME);
++	  if (attr)
++	  {
++	    cupsdLogMessage(CUPSD_LOG_DEBUG,
++			    "cupsdIsAuthorized: requesting-user-name=\"%s\"",
++			    attr->values[0].string.text);
++	   /*
++	    * Check if requesting-user-name has
++	    * 'solaris.print.admin' authorization
++	    */
++	    if(chkauthattr("solaris.print.admin", attr->values[0].string.text))
++	    {
++	      cupsdLogMessage(CUPSD_LOG_DEBUG,
++			      "cupsdIsAuthorized: username=\"%s\" has "
++			      "solaris.print.admin authorization",
++			      attr->values[0].string.text);
++	      return (HTTP_OK);
++	    }
++	  } 
++	  cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdIsAuthorized: HTTP_UNAUTHORIZED");
++	}
++#endif /* HAVE_TSOL */
+ 	return (HTTP_UNAUTHORIZED);	/* Non-anonymous needs user/pass */
+-      else
++      } else
+ 	return (HTTP_OK);		/* unless overridden with Satisfy */
+     }
+ 
+--- scheduler/ipp.c	Fri Apr  6 10:44:27 2012
++++ scheduler/ipp.c	Fri Apr  6 10:55:56 2012
+@@ -124,6 +124,11 @@
+ #  endif /* HAVE_MEMBERSHIPPRIV_H */
+ #endif /* __APPLE__ */
+ 
++#if defined(HAVE_TSOL)
++#include <deflt.h>
++#include <auth_attr.h>
++#include <secdb.h>
++#endif /* HAVE_TSOL */
+ 
+ /*
+  * Local functions...
+@@ -836,18 +841,38 @@
+   printer = cupsdFindDest(job->dest);
+   attr    = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
+ 
++#if defined(HAVE_TSOL) 
+   if (printer &&
+       !(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) &&
+-      attr && attr->num_values > 1)
+-  {
+-   /*
+-    * Yes...
+-    */
++      attr && (attr->num_values > 1 || is_system_labeled()))
++#else
++  if (printer &&
++      !(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) &&
++      attr && (attr->num_values > 1))  
++#endif /* HAVE_TSOL */ 
++ {
++    char *job_sheets_banner = attr->values[1].string.text;
+ 
++#if defined(HAVE_TSOL)
++    if (is_system_labeled()) {
++      /*
++       * Initialize job_sheets_banner to start banner value.
++       * In case start banner is 'none' and user is authorized
++       * to disable printing banner/trailer pages, trailer page
++       * should not be printed.
++       */
++      job_sheets_banner = attr->values[0].string.text;
++
++      if ((strcmp(job_sheets_banner, "none") != 0) ||
++	  (!chkauthattr("solaris.print.nobanner", job->username)))
++	  job_sheets_banner = "labeled";
++    }
++#endif /* HAVE_TSOL */
++
+     cupsdLogJob(job, CUPSD_LOG_INFO, "Adding end banner page \"%s\".",
+-                attr->values[1].string.text);
++                job_sheets_banner);
+ 
+-    if ((kbytes = copy_banner(NULL, job, attr->values[1].string.text)) < 0)
++    if ((kbytes = copy_banner(NULL, job, job_sheets_banner)) < 0)
+       return (-1);
+ 
+     cupsdUpdateQuota(printer, job->username, 0, kbytes);
+@@ -890,7 +915,7 @@
+ 
+     if (str_to_label(label, &sl, USER_CLEAR, L_NO_CORRECTION, NULL) == 0)
+     {
+-      (void) label_to_str(sl, &result, PRINTER_TOP_BOTTOM, DEF_NAMES);
++      (void) label_to_str(sl, &result, M_LABEL, LONG_NAMES);
+       if (result == NULL)
+         result = label;
+ 
+@@ -1751,7 +1776,7 @@
+ 
+     if (attr->value_tag != IPP_TAG_NAME ||
+         attr->num_values != 1 ||
+-        strcmp(con->http.hostname, "localhost"))
++        (strcmp(attr->values[0].string.text, "localhost") == 0))
+     {
+      /*
+       * Can't override the value if we aren't connected via localhost.
+@@ -1797,7 +1822,7 @@
+       attr->value_tag             = IPP_TAG_NAME;
+       attr->num_values            = 1;
+       attr->values[0].string.text = _cupsStrAlloc(con->http.hostname);
+-    }
++  }
+ 
+     attr->group_tag = IPP_TAG_JOB;
+   }
+@@ -2011,10 +2036,24 @@
+ 
+     if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)))
+     {
++      char *job_sheets_banner = attr->values[0].string.text;
++
++#if defined(HAVE_TSOL)   
++      if (is_system_labeled()) {
++        /*
++         * If attr->values[0].string.text is 'none', then check if
++         * user is authorized to disable printing banner pages.
++         */
++	if ((strcmp(job_sheets_banner, "none") != 0) ||
++	  (!chkauthattr("solaris.print.nobanner", job->username)))
++	    job_sheets_banner = "labeled";
++      }
++#endif /* HAVE_TSOL */
++
+       cupsdLogJob(job, CUPSD_LOG_INFO, "Adding start banner page \"%s\".",
+-		  attr->values[0].string.text);
++		  job_sheets_banner);
+ 
+-      if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0)
++      if ((kbytes = copy_banner(con, job, job_sheets_banner)) < 0)
+       {
+         cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE,
+ 	                 "Aborting job because the start banner could not be "
+@@ -7213,6 +7252,21 @@
+   else
+     username[0] = '\0';
+ 
++#if defined(HAVE_TSOL)
++ /*
++  * By default, see jobs for a specific user in case of
++  * Trusted Extensions environment.
++  * List all jobs if the user is authorized.
++  */
++
++  if (!chkauthattr("solaris.print.list", get_username(con)))
++    strlcpy(username, get_username(con), sizeof(username));
++  else
++    username[0] = '\0';
++
++#endif /* HAVE_TSOL */
++
++
+   if ((ra = create_requested_array(con->request)) == NULL &&
+       !ippFindAttribute(con->request, "requested-attributes", IPP_TAG_KEYWORD))
+   {
+--- filter/pstops.c	Tue Aug 31 11:36:08 2010
++++ filter/pstops.c	Fri Apr  6 11:05:36 2012
+@@ -61,6 +61,11 @@
+ #include <signal.h>
+ 
+ 
++#if defined(HAVE_TSOL)
++#include <auth_attr.h>
++#include "tsol_labeled_banner.h"
++#endif /* HAVE_TSOL */
++ 
+ /*
+  * Constants...
+  */
+@@ -166,6 +171,10 @@
+ 
+ static int		JobCanceled = 0;/* Set to 1 on SIGTERM */
+ 
++#if defined(HAVE_TSOL)
++/* nolabels option */
++static int		nolabels = 0;
++#endif /* HAVE_TSOL */ 
+ 
+ /*
+  * Local functions...
+@@ -222,6 +231,12 @@
+ static void		write_label_prolog(pstops_doc_t *doc, const char *label,
+ 			                   float bottom, float top,
+ 					   float width);
++#if defined(HAVE_TSOL)
++static void		tsol_write_label_prolog(pstops_doc_t *doc,
++                                                const char *label,
++						float bottom, float top,
++						float width);
++#endif /* HAVE_TSOL */
+ static void		write_labels(pstops_doc_t *doc, int orient);
+ static void		write_options(pstops_doc_t  *doc, ppd_file_t *ppd,
+ 			              int num_options, cups_option_t *options);
+@@ -322,6 +337,19 @@
+ 
+   set_pstops_options(&doc, ppd, argv, num_options, options);
+ 
++#if defined(HAVE_TSOL)
++  if (is_system_labeled()) 
++  {
++    /*
++     * Check for 'nolabels' options and if user is authorized
++     * to disable labeling.
++     */
++     if ((extract_options(argv[5], "nolabels")) &&
++         (chkauthattr("solaris.print.unlabeled", doc.user)))
++	  nolabels = 1; 
++  }
++#endif /* HAVE_TSOL */
++
+  /*
+   * Write any "exit server" options that have been selected...
+   */
+@@ -2076,6 +2104,19 @@
+   * Write the page and label prologs...
+   */
+ 
++#ifdef HAVE_TSOL
++  if (is_system_labeled())
++  {
++     if (Orientation & 1)
++       /* For landscape and reverse landscape */
++       tsol_write_label_prolog(doc, doc->page_label, PageLeft, PageRight,
++			       PageLength);
++     else
++       /* For portrait and reverse portrait */
++       tsol_write_label_prolog(doc, doc->page_label, PageBottom, PageTop, PageWidth);
++  } 
++  else 
++#endif /* HAVE_TSOL */ 
+   if (doc->number_up == 2 || doc->number_up == 6)
+   {
+    /*
+@@ -3290,7 +3331,76 @@
+   }
+ }
+ 
++#if defined(HAVE_TSOL)
++/*
++ * 'tsol_write_label_prolog()' - Write the prolog with the page label
++ *			       for labeled system.
++ */
++static void
++tsol_write_label_prolog(pstops_doc_t *doc,	/* I - Document info */
++                   const char   *label,	/* I - Page label */
++		   float        bottom,	/* I - Bottom position in points */
++		   float        top,	/* I - Top position in points */
++		   float        width)	/* I - Width in points */
++{
++  const char	*ptr;			/* Temporary string pointer */
+ 
++
++ /*
++  * If there is nothing to show, bind an empty 'write labels' procedure
++  * and return...
++  */
++  if (label == NULL || !label[0])
++  {
++    doc_puts(doc, "userdict/ESPwl{}bind put\n");
++    return;
++  }
++
++ /*
++  * Set the page label string...
++  */
++  doc_puts(doc, "userdict");
++  doc_puts(doc, "/ESPpl(");
++
++  if (label)
++    doc_puts(doc, label);
++
++  doc_puts(doc, ")put\n");
++
++  doc_puts(doc, "userdict");
++  doc_puts(doc, ClippedLabel);
++  doc_puts(doc, append);
++
++  doc_puts(doc, "\n");
++
++ /*
++  * Then get a 12 point Courier-Bold font...
++  */
++
++  doc_puts(doc, "userdict");
++  doc_puts(doc, ESPpf);
++
++ /*
++  * Finally, the procedure to write the labels on the page...
++  */
++
++  doc_puts(doc, "userdict/ESPwl{\n");
++  doc_puts(doc, "  ESPpf setfont\n");
++  doc_printf(doc, "  ClippedLabel stringwidth pop dup 12 add exch -0.5 mul %.0f add\n",
++	width * 0.5f);
++  doc_puts(doc, "  0 setgray\n");
++  doc_printf(doc, "  dup 6 sub %.0f 3 index 10 ESPrf\n", bottom - 1.0);
++  doc_printf(doc, "  dup 6 sub %.0f 3 index 10 ESPrf\n", top - 19.0);
++  doc_puts(doc, "  1 setgray\n");
++  doc_printf(doc, "  dup 6 sub %.0f 3 index 10 ESPrs\n", bottom - 1.0);
++  doc_printf(doc, "  dup 6 sub %.0f 3 index 10 ESPrs\n", top - 19.0);
++  doc_printf(doc, "  dup %.0f moveto ClippedLabel show\n", bottom + 1.0);
++  doc_printf(doc, "  %.0f moveto ClippedLabel show\n", top - 17.0);
++  doc_puts(doc, "pop\n");
++  doc_puts(doc, "}bind put\n");
++}
++#endif /* HAVE_TSOL */
++
+ /*
+  * 'write_label_prolog()' - Write the prolog with the classification
+  *                          and page label.
+@@ -3436,20 +3546,59 @@
+     length = PageLength;
+   }
+ 
+-  switch (orient & 3)
++#ifdef HAVE_TSOL
++  if (is_system_labeled())
+   {
+-    case 1 : /* Landscape */
+-        doc_printf(doc, "%.1f 0.0 translate 90 rotate\n", length);
+-        break;
+-    case 2 : /* Reverse Portrait */
+-        doc_printf(doc, "%.1f %.1f translate 180 rotate\n", width, length);
+-        break;
+-    case 3 : /* Reverse Landscape */
+-        doc_printf(doc, "0.0 %.1f translate -90 rotate\n", width);
+-        break;
++    /*
++     * For 2- and 6-up output, do not rotate the labels.
++     * Labels should be always on top & bottom of the job page.
++     */ 
++    if (doc->number_up != 2 && doc->number_up != 6) 
++    {
++      switch (orient & 3)
++      {
++        case 1 : /* Landscape */
++	  doc_printf(doc, "0.0 %.1f translate -90 rotate\n", length);
++	  break;
++	case 2 : /* Reverse Portrait */
++	  doc_printf(doc, "%.1f %.1f translate 180 rotate\n", width, length);
++	  break;
++	case 3 : /* Reverse Landscape */
++	  doc_printf(doc, "%.1f 0.0 translate 90 rotate\n", width);
++	  break;
++      }
++    }
+   }
++  else
++#endif /* HAVE_TSOL */
++  {
++    switch (orient & 3)
++    {
++      case 1 : /* Landscape */
++	doc_printf(doc, "%.1f 0.0 translate 90 rotate\n", length);
++	break;
++      case 2 : /* Reverse Portrait */
++	doc_printf(doc, "%.1f %.1f translate 180 rotate\n", width, length);
++	break;
++      case 3 : /* Reverse Landscape */
++	doc_printf(doc, "0.0 %.1f translate -90 rotate\n", width);
++	break;
++    }
++  }
+ 
++#ifdef HAVE_TSOL
++  /*
++   * Page-label should not be written in case user gives '-o nolabels' option
++   * and user is authorized to disable page-labels.
++   *
++   * 'nolabels' is set to '1' in case user is authorized to disable page-labels.
++   */
++  if (is_system_labeled() && !nolabels)
++     doc_puts(doc, "ESPwl\n");
++#else
+   doc_puts(doc, "ESPwl\n");
++#endif /* HAVE_TSOL */
++
+   doc_puts(doc, "grestore\n");
+ }
+ 
+--- systemv/lpadmin.c	Thu Aug 12 18:34:04 2010
++++ systemv/lpadmin.c	Fri Apr  6 11:10:17 2012
+@@ -701,6 +701,18 @@
+   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+                "printer-uri", NULL, uri);
+ 
++#if defined(HAVE_TSOL)
++  /*
++   * Add requesting-user-name to the request.
++   * This is required to authorize a user to add a printer to a class.
++   */
++  if (is_system_labeled())
++  {
++    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
++		 "requesting-user-name", NULL, cupsUser());
++  }
++#endif /* HAVE_TSOL */
++
+  /*
+   * See if the printer is already in the class...
+   */
+@@ -804,6 +816,18 @@
+   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+                "printer-uri", NULL, uri);
+ 
++#if defined(HAVE_TSOL)
++  /*
++   * Add requesting-user-name to the request.
++   * This is required to authorize a user to set the default printer.
++   */
++  if (is_system_labeled())
++  {
++    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
++		 "requesting-user-name", NULL, cupsUser());
++  }
++#endif /* HAVE_TSOL */
++
+  /*
+   * Do the request and get back a response...
+   */
+@@ -862,6 +886,18 @@
+   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+                "printer-uri", NULL, uri);
+ 
++#if defined(HAVE_TSOL)
++  /*
++   * Add requesting-user-name to the request.
++   * This is required to authorize a user to delete a printer.
++   */
++  if (is_system_labeled())
++  {
++    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
++		 "requesting-user-name", NULL, cupsUser());
++  }
++#endif /* HAVE_TSOL */
++
+  /*
+   * Do the request and get back a response...
+   */
+@@ -983,6 +1019,19 @@
+ 
+     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+         	 "printer-uri", NULL, uri);
++
++#if defined(HAVE_TSOL)
++    /*
++     * Add requesting-user-name to the request.
++     * This is required to authorize a user to delete a printer from
++     * a class.
++     */
++    if (is_system_labeled())
++    {
++      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
++                   "requesting-user-name", NULL, cupsUser());
++    }
++#endif /* HAVE_TSOL */
+   }
+   else
+   {
+@@ -1001,6 +1050,18 @@
+     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+         	 "printer-uri", NULL, uri);
+ 
++#if defined(HAVE_TSOL)
++    /*
++     * Add requesting-user-name to the request.
++     * This is required to authorize a user to delete a printer from
++     * a class.
++     */
++    if (is_system_labeled())
++    {
++      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
++                   "requesting-user-name", NULL, cupsUser());
++    }
++#endif /* HAVE_TSOL */
+    /*
+     * Delete the printer from the class...
+     */
+@@ -1076,6 +1137,17 @@
+                    "localhost", 0, "/printers/%s", printer);
+   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+                "printer-uri", NULL, uri);
++#if defined(HAVE_TSOL)
++  /*
++   * Add requesting-user-name to the request.
++   * This is required to authorize a user to enable a printer.
++   */
++  if (is_system_labeled())
++  {
++    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
++     		 "requesting-user-name", NULL, cupsUser());
++  }
++#endif /* HAVE_TSOL */
+ 
+   ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
+                 IPP_PRINTER_IDLE);