components/cups/patches/18-audit-tx.patch
author Sonam Gupta <sonam.x.gupta@oracle.com>
Sun, 17 Feb 2013 21:51:48 -0800
branchs11u1-sru
changeset 2495 eb04a6ca141d
permissions -rw-r--r--
15698471 cups should audit printing information in TX environments 14850597 TX printing is reported to print jobs even when request authorization fail. 16182423 Update error code for all the failed use of authorization records in CUPS 16182458 Print 3 files requesting nolabel and nobanner should produce 6 audit records 16201093 For remote print requests, the path token in AR from GZ needs modification
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2495
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     1
--- configure.in	Thu Jan  3 02:44:26 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     2
+++ configure.in	Wed Jan  2 21:45:05 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     3
@@ -42,6 +42,7 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     4
 sinclude(config-scripts/cups-pdf.m4)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     5
 sinclude(config-scripts/cups-scripting.m4)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     6
 sinclude(config-scripts/cups-labeling.m4)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     7
+sinclude(config-scripts/cups-auditing.m4)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     8
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
     9
 INSTALL_LANGUAGES=""
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    10
 UNINSTALL_LANGUAGES=""
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    11
--- config-scripts/cups-auditing.m4	Wed Jan  2 23:23:52 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    12
+++ config-scripts/cups-auditing.m4	Wed Jan  2 21:45:18 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    13
@@ -0,0 +1,35 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    14
+dnl
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    15
+dnl    Auditing support for the Common UNIX Printing System (CUPS).
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    16
+dnl
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    17
+dnl    Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    18
+dnl
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    19
+dnl   This program is free software; you can redistribute it and/or modify
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    20
+dnl   it under the terms of the GNU General Public License as published by
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    21
+dnl   the Free Software Foundation; version 2.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    22
+dnl
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    23
+dnl   This program is distributed in the hope that it will be useful, but
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    24
+dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    25
+dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    26
+dnl   General Public License for more details.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    27
+dnl
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    28
+dnl   You should have received a copy of the GNU General Public License
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    29
+dnl   along with this program; if not, write to the Free Software Foundation,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    30
+dnl   Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    31
+dnl
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    32
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    33
+AC_ARG_ENABLE(auditing, [ --enable-auditing enable support for auditing, default=auto])
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    34
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    35
+if test x"$enable_auditing" != xno; then
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    36
+    case "$uname" in
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    37
+        SunOS)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    38
+		AC_CHECK_LIB(bsm, adt_start_session,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    39
+		    [AUDITING_LIBS="-lbsm" AC_SUBST(AUDITING_LIBS)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    40
+		    AC_CHECK_HEADER(bsm/adt.h)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    41
+		    AC_CHECK_HEADER(bsm/adt_event.h)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    42
+		    AC_DEFINE(HAVE_ADT)])
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    43
+            ;;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    44
+        *)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    45
+            # All others
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    46
+            ;;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    47
+    esac
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    48
+fi
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    49
--- config.h.in	Wed Jan  2 23:21:36 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    50
+++ config.h.in	Wed Jan  2 21:44:45 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    51
@@ -672,6 +672,11 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    52
 #undef HAVE_TSOL
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    53
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    54
 /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    55
+ * Do we have Auditing support ?
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    56
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    57
+#undef HAVE_ADT
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    58
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    59
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    60
  * Do we have SELinux support?
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    61
  */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    62
 #undef HAVE_SELINUX
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    63
--- Makedefs.in	Wed Jan  2 23:21:36 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    64
+++ Makedefs.in	Wed Jan  2 21:46:40 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    65
@@ -125,7 +125,7 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    66
 BANNERTOPS	=	@BANNERTOPS@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    67
 CFLAGS		=	@CPPFLAGS@ @CFLAGS@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    68
 COMMONLIBS	=	@LIBS@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    69
-CUPSDLIBS	=	@CUPSDLIBS@ @LABELING_LIBS@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    70
+CUPSDLIBS	=	@CUPSDLIBS@ @LABELING_LIBS@ @AUDITING_LIBS@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    71
 CXXFLAGS	=	@CPPFLAGS@ @CXXFLAGS@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    72
 CXXLIBS		=	@CXXLIBS@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    73
 DBUS_NOTIFIER	=	@DBUS_NOTIFIER@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    74
--- scheduler/client.h	Wed Jan  2 23:21:36 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    75
+++ scheduler/client.h	Wed Jan  2 21:44:36 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    76
@@ -17,6 +17,9 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    77
 #  include <Security/Authorization.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    78
 #endif /* HAVE_AUTHORIZATION_H */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    79
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    80
+#ifdef HAVE_ADT
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    81
+#include <bsm/adt.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    82
+#endif /* HAVE_ADT */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    83
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    84
 /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    85
  * HTTP client structure...
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    86
@@ -64,8 +67,13 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    87
 #ifdef HAVE_AUTHORIZATION_H
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    88
   AuthorizationRef	authref;	/* Authorization ref */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    89
 #endif /* HAVE_AUTHORIZATION_H */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    90
-  char                  *slabel;		/* security context for security
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    91
+#ifdef HAVE_TSOL
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    92
+  char                  *slabel;	/* security context for security
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    93
 					   labeled environments */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    94
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    95
+#ifdef HAVE_ADT
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    96
+  adt_session_data_t	*ah		/* audit handle for print requests */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    97
+#endif /* HAVE_ADT */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    98
 };
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
    99
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   100
 #define HTTP(con) &((con)->http)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   101
--- scheduler/job.h	Wed Jan  2 23:21:36 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   102
+++ scheduler/job.h	Wed Jan  2 21:46:16 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   103
@@ -13,6 +13,10 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   104
  *   file is missing or damaged, see the license at "http://www.cups.org/".
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   105
  */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   106
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   107
+#ifdef HAVE_ADT
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   108
+#include <bsm/adt.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   109
+#endif /* HAVE_ADT */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   110
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   111
 /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   112
  * Constants...
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   113
  */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   114
@@ -83,8 +87,13 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   115
   krb5_ccache		ccache;		/* Kerberos credential cache */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   116
   char			*ccname;	/* KRB5CCNAME environment variable */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   117
 #endif /* HAVE_GSSAPI */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   118
-  char                  *slabel;		/* security context for security
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   119
+#ifdef HAVE_TSOL
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   120
+  char                  *slabel;	/* security context for security
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   121
 					   labeled environments */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   122
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   123
+#ifdef HAVE_ADT
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   124
+  adt_session_data_t	*ah;		/* audit handle for print requests */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   125
+#endif /* HAVE_ADT */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   126
 };
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   127
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   128
 typedef struct cupsd_joblog_s		/**** Job log message ****/
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   129
--- scheduler/ipp.c	Wed Jan  2 23:21:36 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   130
+++ scheduler/ipp.c	Wed Jan  2 23:25:46 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   131
@@ -1425,12 +1425,20 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   132
 		*media_margin;		/* media-*-margin attribute */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   133
   ipp_t		*unsup_col;		/* media-col in unsupported response */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   134
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   135
-
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   136
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   137
                   con, con->http.fd, printer, printer->name,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   138
 		  filetype, filetype ? filetype->super : "none",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   139
 		  filetype ? filetype->type : "none");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   140
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   141
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   142
+  /* Start audit session to audit CUPS print requests */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   143
+  if (is_system_labeled() != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   144
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "add_job: Start CUPS audit session"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   145
+		    " for connection");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   146
+    cups_audit_start_session(con);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   147
+  }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   148
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   149
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   150
   /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   151
    * Validate that the label associated with the connection is acceptable for
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   152
    * printing on the printer.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   153
@@ -1437,6 +1445,11 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   154
    */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   155
   if (cupsdInPrinterLabelRange(con->slabel, printer) == 0)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   156
   {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   157
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   158
+    /* Audit the print request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   159
+    if (is_system_labeled() != 0)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   160
+      cups_audit_print_request_denial(con, NULL, printer, -1, EACCES);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   161
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   162
     send_ipp_status(con, IPP_NOT_AUTHORIZED, _("label violation."));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   163
     return (NULL);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   164
   }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   165
@@ -1450,6 +1463,12 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   166
       strcasecmp(con->http.hostname, "localhost") &&
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   167
       strcasecmp(con->http.hostname, ServerName))
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   168
   {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   169
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   170
+    /* Audit the print request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   171
+    if (is_system_labeled() != 0)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   172
+      cups_audit_print_request_denial(con, NULL, printer, -1, EPERM);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   173
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   174
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   175
     send_ipp_status(con, IPP_NOT_AUTHORIZED,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   176
                     _("The printer or class is not shared!"));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   177
     return (NULL);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   178
@@ -1463,6 +1482,11 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   179
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   180
   if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   181
   {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   182
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   183
+    /* Audit the print request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   184
+    if (is_system_labeled() != 0)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   185
+      cups_audit_print_request_denial(con, NULL, printer, -1, EPERM);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   186
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   187
     send_http_error(con, status, printer);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   188
     return (NULL);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   189
   }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   190
@@ -1714,6 +1738,21 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   191
 		 NULL, label_to_page_top_bottom_string(job->slabel));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   192
   }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   193
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   194
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   195
+  /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   196
+   * Initialize audit handle for job.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   197
+   * Audit handle for job is same as that for connection.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   198
+   * Connection handle is not available in job.c where job requests
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   199
+   * are processed so the same is copied to job handle so that
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   200
+   * job requests can be audited.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   201
+   * Here just the handle pointer is being copied. It will stay valid
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   202
+   * throughout the processing of a print request.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   203
+   */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   204
+  if (is_system_labeled() != 0)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   205
+    job->ah = con->ah;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   206
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   207
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   208
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   209
   job->dtype   = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT |
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   210
                                   CUPS_PRINTER_REMOTE);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   211
   job->attrs   = con->request;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   212
@@ -1851,6 +1890,7 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   213
   */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   214
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   215
   ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   216
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   217
   job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   218
                              "job-state", IPP_JOB_STOPPED);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   219
   job->state_value = (ipp_jstate_t)job->state->values[0].integer;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   220
@@ -4081,6 +4121,11 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   221
     if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   222
                                    NULL)) != HTTP_OK)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   223
     {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   224
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   225
+      /* Audit the print request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   226
+      if (is_system_labeled() != 0)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   227
+        cups_audit_print_request_denial(con, NULL, printer, -1, EPERM);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   228
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   229
       send_http_error(con, status, printer);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   230
       return;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   231
     }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   232
--- scheduler/job.c	Wed Jan  2 23:21:36 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   233
+++ scheduler/job.c	Wed Jan  2 21:46:11 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   234
@@ -75,6 +75,9 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   235
 #include <cups/backend.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   236
 #include <cups/dir.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   237
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   238
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   239
+#include <bsm/adt_event.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   240
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   241
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   242
 /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   243
  * Design Notes for Job Management
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   244
@@ -2712,6 +2715,9 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   245
   const char		*message;	/* Message for job state */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   246
   char			buffer[1024];	/* Buffer for formatted messages */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   247
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   248
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   249
+  ipp_attribute_t	*attr;		/* Current attributes */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   250
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   251
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   252
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "finalize_job(job=%p(%d))", job, job->id);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   253
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   254
@@ -2986,6 +2992,13 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   255
 		  "error_log file for details.";
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   256
     }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   257
   }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   258
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   259
+  /* Audit the print request. */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   260
+  if (is_system_labeled() != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   261
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "finalize_job(cups_audit_print_request)");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   262
+    cups_audit_print_request(job, job_state);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   263
+  }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   264
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   265
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   266
  /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   267
   * Update the printer and job state.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   268
@@ -4037,6 +4050,12 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   269
                     "start_job(): job label outside of printer label range");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   270
     cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   271
                      "job label is outside of printer label range");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   272
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   273
+    if (is_system_labeled() != 0)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   274
+	cups_audit_print_request_denial(NULL, job, printer,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   275
+				    job->state_value, EACCES);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   276
+#endif /*HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   277
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   278
     cupsdCheckJobs();
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   279
     return;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   280
   }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   281
@@ -4586,7 +4605,6 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   282
    /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   283
     * Handle the end of job stuff...
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   284
     */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   285
-
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   286
     finalize_job(job, 1);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   287
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   288
    /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   289
--- scheduler/cups-lpd.c	Wed Sep  3 05:57:17 2008
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   290
+++ scheduler/cups-lpd.c	Wed Jan  2 21:45:33 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   291
@@ -348,8 +348,11 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   292
   ipp_attribute_t *attr;		/* IPP attribute */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   293
   char		uri[HTTP_MAX_URI];	/* Printer URI */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   294
   int		id;			/* Job ID */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   295
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   296
+  char		*hostname;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   297
+  const char    uid[11], gid[11];	/* user id and group id */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   298
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   299
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   300
-
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   301
  /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   302
   * Setup the Create-Job request...
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   303
   */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   304
@@ -373,6 +376,29 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   305
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-name", 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   306
                  NULL, docname);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   307
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   308
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   309
+  if (is_system_labeled() != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   310
+    /* Add job-originating-host-name to the request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   311
+    if ((hostname = cupsGetOption("job-originating-host-name", num_options,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   312
+	options)) != NULL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   313
+      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   314
+		   "job-originating-host-name", NULL, hostname);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   315
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   316
+    /* Add userID and groupID of the user who submitted the request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   317
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   318
+    /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   319
+     * When uid and gid are added to the attributes using ippAddInteger,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   320
+     * ippFindAttribute from the scheduler is not able to read the attribute,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   321
+     * so using ippAddString to add uid and gid.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   322
+     */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   323
+    snprintf(uid, sizeof(uid), "%d", getuid());
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   324
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "userID", NULL, uid);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   325
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   326
+    snprintf(gid, sizeof(gid), "%d", getgid());
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   327
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "groupID", NULL, gid);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   328
+  }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   329
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   330
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   331
   cupsEncodeOptions(request, num_options, options);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   332
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   333
  /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   334
--- scheduler/audit.c	Wed Jan  2 23:26:12 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   335
+++ scheduler/audit.c	Wed Jan  2 21:44:22 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   336
@@ -0,0 +1,781 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   337
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   338
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   339
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   340
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   341
+ * This program is free software; you can redistribute it and/or modify
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   342
+ * it under the terms of the GNU General Public License as published by
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   343
+ * the Free Software Foundation; version 2.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   344
+ *
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   345
+ * This program is distributed in the hope that it will be useful, but
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   346
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   347
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   348
+ * General Public License for more details.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   349
+ *
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   350
+ * You should have received a copy of the GNU General Public License
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   351
+ * along with this program; if not, write to the Free Software Foundation,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   352
+ * Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   353
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   354
+#include <syslog.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   355
+#include "cupsd.h"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   356
+#include <bsm/adt.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   357
+#include <bsm/adt_event.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   358
+#include <auth_attr.h>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   359
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   360
+#define	PRINT_UNLABELED_AUTH	"solaris.print.unlabeled"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   361
+#define	PRINT_NOBANNER_AUTH	"solaris.print.nobanner"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   362
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   363
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   364
+ * Maximum length of string to hold requested job id:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   365
+ * <printer-name>-<job-id>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   366
+ * IPP_MAX_NAME+1+10+1
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   367
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   368
+#define	REQ_MAX_NAME		IPP_MAX_NAME+1+10+1
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   369
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   370
+uid_t	uid = ADT_NO_ATTRIB;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   371
+gid_t	gid = ADT_NO_ATTRIB;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   372
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   373
+void cups_audit_start_session(cupsd_client_t *con);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   374
+void cups_audit_print_request_denial(cupsd_client_t *con, cupsd_job_t *job,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   375
+     cupsd_printer_t *printer, ipp_jstate_t job_state, int fail_reason);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   376
+void cups_audit_print_request(cupsd_job_t *job, ipp_jstate_t job_state);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   377
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   378
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   379
+ * Set up an audit session for auditing the current print request.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   380
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   381
+void
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   382
+cups_audit_start_session(cupsd_client_t *con)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   383
+{
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   384
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   385
+	if (adt_start_session(&con->ah, NULL, 0) != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   386
+		cupsdLogMessage(CUPSD_LOG_EMERG, "cups_audit_start_session(): "
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   387
+		    "adt_start_session(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   388
+		con->ah = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   389
+		return;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   390
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   391
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   392
+	if (strcasecmp(con->http.hostname, "localhost") == 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   393
+		/* Local Request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   394
+		ucred_t *cred = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   395
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   396
+		if (getpeerucred(con->http.fd, &cred) == -1) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   397
+			cupsdLogMessage(CUPSD_LOG_EMERG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   398
+			    "cups_audit_start_session(): "
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   399
+			    "getpeerucred(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   400
+			(void) adt_end_session(con->ah);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   401
+			con->ah = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   402
+			return;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   403
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   404
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   405
+		if (adt_set_from_ucred(con->ah, cred, ADT_NEW) != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   406
+			cupsdLogMessage(CUPSD_LOG_EMERG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   407
+			    "cups_audit_start_session(): "
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   408
+			    "adt_set_from_ucred(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   409
+			(void) adt_end_session(con->ah);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   410
+			con->ah = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   411
+			return;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   412
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   413
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   414
+		/* Remote Request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   415
+		ipp_attribute_t	*userID = NULL, *grpID = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   416
+		adt_termid_t	*termid = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   417
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   418
+		if ((userID = ippFindAttribute(con->request, "userID",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   419
+		    IPP_TAG_NAME)) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   420
+			cupsdLogMessage(CUPSD_LOG_DEBUG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   421
+			    "cups_audit_start_session():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   422
+			    "userID = %s", userID->values[0].string.text);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   423
+			uid = atoi(userID->values[0].string.text);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   424
+		} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   425
+			cupsdLogMessage(CUPSD_LOG_DEBUG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   426
+			    "cups_audit_start_session():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   427
+			    "userID = NULL");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   428
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   429
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   430
+		if ((grpID = ippFindAttribute(con->request, "groupID",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   431
+		    IPP_TAG_NAME)) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   432
+			cupsdLogMessage(CUPSD_LOG_DEBUG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   433
+			    "cups_audit_start_session():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   434
+			    "grpID = %s", grpID->values[0].string.text);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   435
+			gid = atoi(grpID->values[0].string.text);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   436
+		} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   437
+			cupsdLogMessage(CUPSD_LOG_DEBUG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   438
+			    "cups_audit_start_session():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   439
+			    "grpID = NULL");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   440
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   441
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   442
+		if (adt_load_termid(con->http.fd, &termid) != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   443
+			cupsdLogMessage(CUPSD_LOG_ERROR,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   444
+			    "cups_audit_start_session(): "
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   445
+			    "adt_load_termid(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   446
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   447
+		if (adt_set_user(con->ah, uid, gid, uid, gid, termid,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   448
+		    ADT_NEW) != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   449
+			cupsdLogMessage(CUPSD_LOG_EMERG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   450
+			    "cups_audit_start_session(): "
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   451
+			    "adt_set_user(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   452
+			(void) adt_end_session(con->ah);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   453
+			con->ah = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   454
+			free(termid);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   455
+			return;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   456
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   457
+		free(termid);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   458
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   459
+}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   460
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   461
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   462
+ * Routine for filling in the audit event details for each of the
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   463
+ * three types of TX-related printing audit records:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   464
+ *    AUE_print_request - audit each file in print request
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   465
+ *    AUE_print_request_unlabeled - audit use of the solaris.print.nolabels auth
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   466
+ *    AUE_print_request_nobanner - audit use of the solaris.print.nobanner auth
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   467
+ * One AUE_print_request audit record is written for each text file in the
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   468
+ * print request. The '-o nolabels' and '-o nobanner' options apply to the
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   469
+ * entire print request so one AUE_print_request_unlabeled audit record and one
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   470
+ * AUE_print_request_nobanner audit record is written, respectively, for each
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   471
+ * file in the print request when these options are supplied.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   472
+ * 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   473
+ * event_ID		= type of TX-related printing audit record
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   474
+ * event		= audit event structure
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   475
+ * printer		= printer name
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   476
+ * slabel		= Sensitivity Label
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   477
+ * job_ID		= request_ID; <printe-name>-<job-id>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   478
+ * job_ID_remote	= remote request_ID; <printe-name>-<remote-job_id>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   479
+ *			job id for the same request differ on client and server
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   480
+ * filelist		= file to be printed;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   481
+ *			 In case 'filelist' is 'stdin', temporary filename
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   482
+ *			 created in /var/spool/cups/ is read 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   483
+ * ai			= struct addrinfo; 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   484
+ * status 		= audit request status;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   485
+ *			 ADT_FAILURE, ADT_SUCCESS
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   486
+ * return_val		= return value of audit request;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   487
+ *			 If user is not authorized then ADT_FAIL_VALUE_AUTH
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   488
+ *			 If print job is successfully completed then ADT_SUCCESS
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   489
+ *			 If job is cancelled then
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   490
+ *			 ADT_FAIL_VALUE_PRINT_JOB_CANCELLED
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   491
+ *			MAC failures it is EACESS
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   492
+ *			DAC failures it is EPERM
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   493
+ * i = which of the job files is this 000-999 for the CUPS max of 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   494
+ *	1000 jobs.  See util.c
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   495
+ * job_id 		= print request job id; this is used to get the location
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   496
+ *			 of the temporary file in spool directory which is of the format:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   497
+ *			 /var/spool/cups/d00550-001
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   498
+ *			where 550 is the job-id.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   499
+ * remote		= true: remote request
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   500
+ *			 false: local request
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   501
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   502
+static void
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   503
+cups_audit_print_request_data(au_event_t event_ID,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   504
+    adt_event_data_t *event, char *printer, char *slabel,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   505
+    char *job_ID, char *job_ID_remote, char *filelist,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   506
+    struct addrinfo *ai, int status, int return_val, int i,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   507
+    int job_id, boolean_t remote)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   508
+{
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   509
+	char		tmpfile[IPP_MAX_NAME];
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   510
+	char		tfile[IPP_MAX_NAME];
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   511
+	char		r_job_ID[IPP_MAX_NAME];
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   512
+	char		*file, *f_job_ID = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   513
+	struct stat	attributes;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   514
+	m_label_t	*file_label = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   515
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   516
+	/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   517
+	 * If 'filelist' is 'stdin', read the temporary filename
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   518
+	 * created for the file contents in /var/spool/cups/
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   519
+	 * This will be useful to audit the files printed
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   520
+	 * via standard input.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   521
+	 * Scheduler can't discern the difference between a
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   522
+	 * file printed via stdin and one printed normally so
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   523
+	 * the file attributes and label are always included
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   524
+	 * even though they refer to the temporary file created
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   525
+	 * in the case of stdin.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   526
+	 * The label is going to be the same regardless of wheather
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   527
+	 * it is of the tmp file that was used for stdin or the real file.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   528
+	 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   529
+	if (remote) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   530
+	    	/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   531
+		 * temporary filename is of the format:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   532
+		 * /var/spool/cups/d00550-001
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   533
+		 * where 550 is the job-id.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   534
+		 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   535
+		snprintf(tmpfile, sizeof (tmpfile), "%s/d%05d-%03d",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   536
+		    RequestRoot, job_id, i + 1);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   537
+		/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   538
+		 * In case of remote request,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   539
+		 * Job_ID string is like:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   540
+		 * 'Local JOB_ID: <printer>-id |
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   541
+		 * Remote JOB_ID: <printer>-<remote-id>'
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   542
+		 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   543
+		if (job_ID_remote != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   544
+			snprintf(r_job_ID, sizeof (r_job_ID),
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   545
+			    "Local JOB_ID: %s |"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   546
+			    " Remote JOB_ID: %s-%s",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   547
+			    job_ID, printer, job_ID_remote);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   548
+			f_job_ID = r_job_ID;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   549
+		} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   550
+			f_job_ID = job_ID;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   551
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   552
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   553
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   554
+		f_job_ID = job_ID;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   555
+		if (job_id != -1) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   556
+			if ((strncmp(filelist, "(stdin)", 7)) == 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   557
+				snprintf(tmpfile, sizeof (tmpfile),
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   558
+				    "%s/d%05d-%03d", RequestRoot,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   559
+				    job_id, i + 1);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   560
+			} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   561
+				strlcpy(tmpfile, filelist, sizeof (tmpfile));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   562
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   563
+		} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   564
+			strlcpy(tmpfile, filelist, sizeof (tmpfile));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   565
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   566
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   567
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   568
+	file = tmpfile;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   569
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   570
+	if (stat(file, &attributes) == -1) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   571
+		cupsdLogMessage(CUPSD_LOG_ERROR,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   572
+		    "cups_audit_print_request_data():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   573
+		    "stat(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   574
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   575
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   576
+	/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   577
+	 * In case of remote request, filelist contains client document-name.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   578
+	 * Append the same to filename before writing to the audit record.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   579
+	 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   580
+	if (remote && (filelist != NULL)) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   581
+		strlcpy(tfile, "Local file: ", sizeof (tmpfile));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   582
+		strcat(tfile, tmpfile);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   583
+		strcat(tfile, " | Remote file: ");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   584
+		strcat(tfile, filelist);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   585
+		file = tfile;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   586
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   587
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   588
+	/* extract label from slabel */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   589
+	if (str_to_label(slabel, &file_label, MAC_LABEL,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   590
+	    L_NO_CORRECTION, NULL) == 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   591
+		cupsdLogMessage(CUPSD_LOG_DEBUG2,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   592
+		    "cups_audit_print_request_data():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   593
+		    "file_label extracted");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   594
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   595
+		cupsdLogMessage(CUPSD_LOG_ERROR,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   596
+		    "cups_audit_print_request_data():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   597
+		    "file_label not extracted");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   598
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   599
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   600
+	/* Populate audit event structure */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   601
+	switch (event_ID) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   602
+	case ADT_print_request_unlabeled:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   603
+		if (remote) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   604
+			if (ai->ai_family == AF_INET) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   605
+				event->adt_print_request_unlabeled.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   606
+				    remote_host_ip_type = ADT_IPv4;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   607
+				    
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   608
+				(void) memcpy(event->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   609
+				    adt_print_request_unlabeled.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   610
+				    remote_host_ipaddress,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   611
+				    &((struct sockaddr_in *)ai->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   612
+				    ai_addr)->sin_addr,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   613
+				    sizeof (struct in_addr));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   614
+			} else if (ai->ai_family == AF_INET6) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   615
+				event->adt_print_request_unlabeled.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   616
+				    remote_host_ip_type = ADT_IPv6;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   617
+				    
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   618
+				(void) memcpy(event->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   619
+				    adt_print_request_unlabeled.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   620
+				    remote_host_ipaddress,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   621
+				    &((struct sockaddr_in6 *)ai->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   622
+				    ai_addr)->sin6_addr,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   623
+				    sizeof (struct in6_addr));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   624
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   625
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   626
+		event->adt_print_request_unlabeled.request_ID = f_job_ID;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   627
+		event->adt_print_request_unlabeled.printer = printer;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   628
+		event->adt_print_request_unlabeled.file = file;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   629
+		event->adt_print_request_unlabeled.file_attrs = &attributes;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   630
+		event->adt_print_request_unlabeled.file_label = file_label;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   631
+		event->adt_print_request_unlabeled.override_auth =
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   632
+		    PRINT_UNLABELED_AUTH;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   633
+		break;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   634
+	case ADT_print_request_nobanner:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   635
+		if (remote) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   636
+			if (ai->ai_family == AF_INET) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   637
+				event->adt_print_request_nobanner.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   638
+				    remote_host_ip_type = ADT_IPv4;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   639
+				    
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   640
+				(void) memcpy(event->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   641
+				    adt_print_request_nobanner.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   642
+				    remote_host_ipaddress,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   643
+				    &((struct sockaddr_in *)ai->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   644
+				    ai_addr)->sin_addr,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   645
+				    sizeof (struct in_addr));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   646
+			} else if (ai->ai_family == AF_INET6) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   647
+				event->adt_print_request_nobanner.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   648
+				    remote_host_ip_type = ADT_IPv6;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   649
+				    
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   650
+				(void) memcpy(event->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   651
+				    adt_print_request_nobanner.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   652
+				    remote_host_ipaddress,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   653
+				    &((struct sockaddr_in6 *)ai->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   654
+				    ai_addr)->sin6_addr,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   655
+				    sizeof (struct in6_addr));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   656
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   657
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   658
+		event->adt_print_request_nobanner.request_ID = f_job_ID;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   659
+		event->adt_print_request_nobanner.printer = printer;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   660
+		event->adt_print_request_nobanner.file = file;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   661
+		event->adt_print_request_nobanner.file_attrs = &attributes;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   662
+		event->adt_print_request_nobanner.file_label = file_label;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   663
+		event->adt_print_request_nobanner.override_auth =
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   664
+		    PRINT_NOBANNER_AUTH;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   665
+		break;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   666
+	case ADT_print_request:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   667
+		if (remote) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   668
+			if (ai->ai_family == AF_INET) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   669
+				event->adt_print_request.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   670
+				    remote_host_ip_type = ADT_IPv4;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   671
+				    
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   672
+				(void) memcpy(event->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   673
+				    adt_print_request.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   674
+				    remote_host_ipaddress,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   675
+				    &((struct sockaddr_in *)ai->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   676
+				    ai_addr)->sin_addr,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   677
+				    sizeof (struct in_addr));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   678
+			} else if (ai->ai_family == AF_INET6) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   679
+				event->adt_print_request.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   680
+				    remote_host_ip_type = ADT_IPv6;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   681
+				    
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   682
+				(void) memcpy(event->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   683
+				    adt_print_request.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   684
+				    remote_host_ipaddress,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   685
+				    &((struct sockaddr_in6 *)ai->
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   686
+				    ai_addr)->sin6_addr,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   687
+				    sizeof (struct in6_addr));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   688
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   689
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   690
+		event->adt_print_request.request_ID = f_job_ID;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   691
+		event->adt_print_request.printer = printer;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   692
+		event->adt_print_request.file = file;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   693
+		event->adt_print_request.file_attrs = &attributes;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   694
+		event->adt_print_request.file_label = file_label;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   695
+		break;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   696
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   697
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   698
+	if (adt_put_event(event, status, return_val) != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   699
+		cupsdLogMessage(CUPSD_LOG_EMERG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   700
+		    "cups_audit_print_request_data():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   701
+		    "adt_put_event(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   702
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   703
+}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   704
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   705
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   706
+ * To populate the audit events, cups_audit_print_request() is called.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   707
+ * cups_audit_print_request() calls cups_audit_print_request_common()
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   708
+ * which in turn calls cups_audit_print_request_sub() which finally
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   709
+ * calls cups_audit_print_request_data().
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   710
+ *
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   711
+ * event_ID		= type of TX-related printing audit record
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   712
+ *			 ADT_print_request_unlabeled
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   713
+ *			 ADT_print_request_nobanner
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   714
+ *			 ADT_print_request 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   715
+ * ah 			= Audit session handle
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   716
+ * printer              = printer name
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   717
+ * job_ID		= request_ID; <printe-name>-<job-id> 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   718
+ * job_id		= job->id; Job identification number.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   719
+ *			 -1 in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   720
+ *			 a request is denied before job gets created.	
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   721
+ *			 -1 in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   722
+ *			 a request is denied before job gets created.	
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   723
+ * job_ID_remote	= remote request_ID; <printe-name>-<remote-job_id>
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   724
+ *			 local job_id and remote job_id are different
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   725
+ * job_state		= ipp_jstate_t enum:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   726
+ *	IPP_JOB_PENDING = 3,	Job is waiting to be printed
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   727
+ *	IPP_JOB_HELD,		Job is held for printing
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   728
+ * 	IPP_JOB_PROCESSING,	Job is currently printing
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   729
+ * 	IPP_JOB_STOPPED,	Job has been stopped
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   730
+ * 	IPP_JOB_CANCELED,	Job has been canceled
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   731
+ * 	IPP_JOB_ABORTED,	Job has aborted due to error
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   732
+ * 	IPP_JOB_COMPLETED	Job has completed successfully
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   733
+ *			 current job state 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   734
+ *			 -1 in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   735
+ *			 a request is denied before job gets created.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   736
+ * job_state_value 	= ipp_jstate_t; cached job state
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   737
+ *			 -1 in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   738
+ *			 a request is denied before job gets created.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   739
+ * hostname		= name of connected host
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   740
+ * document_list	= list of files to be printed
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   741
+ * job_name		= job title; usually the first filename in filelist
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   742
+ * slabel		= Sensitivity Label 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   743
+ * fail_reason 		= failure reason; EPERM, EACESS
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   744
+ * authorized		= true: user has required autorization to print
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   745
+ *			 false: user is not authorized to print 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   746
+ * num_files		= 0 for initial MAC/DAC
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   747
+ *			 1 - 999 for number of files printed in a job.       
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   748
+ * wants_nobanner	= true: user does not want to print banner and trailer page
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   749
+ *			 false: user wants to print banner and trailer page 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   750
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   751
+static void
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   752
+cups_audit_print_request_sub(au_event_t event_ID, adt_session_data_t *ah,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   753
+    char *printer, char *job_ID, int job_id, char *job_ID_remote,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   754
+    ipp_jstate_t job_state, ipp_jstate_t job_state_value, char *hostname,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   755
+    char *document_list, char *job_name, char *slabel, int fail_reason,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   756
+    int authorized, int num_files, boolean_t wants_nobanner)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   757
+{
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   758
+	adt_event_data_t	*event;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   759
+	char			*dlist, *filelist;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   760
+	int			status, return_val;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   761
+	struct addrinfo		*ai = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   762
+	boolean_t		remote = B_FALSE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   763
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   764
+	if ((event = adt_alloc_event(ah, event_ID)) == NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   765
+		cupsdLogMessage(CUPSD_LOG_EMERG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   766
+		    "cups_audit_print_request_sub():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   767
+		    "adt_alloc_event(): %d", errno);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   768
+		return;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   769
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   770
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   771
+	if ((job_id == -1) && (job_state == -1) && (job_state_value == -1)) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   772
+		status = ADT_FAILURE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   773
+		return_val = fail_reason;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   774
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   775
+		if (authorized != 1) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   776
+			status = ADT_FAILURE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   777
+			return_val = ADT_FAIL_VALUE_AUTH;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   778
+		} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   779
+			if (job_state == IPP_JOB_COMPLETED) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   780
+				status = ADT_SUCCESS;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   781
+				return_val = ADT_SUCCESS;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   782
+			} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   783
+				status = ADT_FAILURE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   784
+				if ((fail_reason == 0) &&
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   785
+				    (job_state_value == IPP_JOB_CANCELED)) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   786
+					return_val =
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   787
+					    ADT_FAIL_VALUE_PRINT_JOB_CANCELLED;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   788
+				} else if (fail_reason == 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   789
+					return_val =
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   790
+					    ADT_FAIL_VALUE_PRINT_JOB_FAILED;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   791
+				} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   792
+					return_val = fail_reason;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   793
+				}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   794
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   795
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   796
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   797
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   798
+	if (hostname != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   799
+		int err;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   800
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   801
+		cupsdLogMessage(CUPSD_LOG_DEBUG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   802
+		    "cups_audit_print_request_sub():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   803
+		    "host = %s", hostname);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   804
+		if ((err = getaddrinfo(hostname,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   805
+		    NULL, NULL, &ai)) != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   806
+			cupsdLogMessage(CUPSD_LOG_ERROR,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   807
+			    "cups_audit_print_request_sub():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   808
+			    "getaddrinfo(%s) failed[%s]",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   809
+			    hostname, gai_strerror(err));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   810
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   811
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   812
+		if (strcasecmp(hostname, "localhost") != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   813
+			remote = B_TRUE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   814
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   815
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   816
+		cupsdLogMessage(CUPSD_LOG_DEBUG,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   817
+		    "cups_audit_print_request_sub():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   818
+		    "host is NULL");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   819
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   820
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   821
+	if (document_list == NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   822
+		dlist = job_name;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   823
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   824
+		dlist = document_list;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   825
+		cupsdLogMessage(CUPSD_LOG_DEBUG2,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   826
+		    "cups_audit_print_request_sub():"
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   827
+		    "document-names is %s ", dlist);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   828
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   829
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   830
+	/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   831
+	 * document-names=f1,f2,f3...
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   832
+	 * extract the files from it.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   833
+	 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   834
+	if (dlist != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   835
+		filelist = strtok(dlist, ",");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   836
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   837
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   838
+	if (remote) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   839
+		/* Remote Request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   840
+		int i = 1;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   841
+		int max_files = (num_files - 1);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   842
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   843
+		/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   844
+		 * remote root always sends banner and trailer files
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   845
+		 * to the server. Whereas in case of non-root if
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   846
+		 * nobanner is set it sends only the job file to
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   847
+		 * the server.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   848
+		 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   849
+		if ((uid != 0) && (gid != 0) && wants_nobanner) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   850
+			i = 0;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   851
+			max_files = num_files;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   852
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   853
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   854
+		for (; i < max_files; i++) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   855
+			cups_audit_print_request_data(event_ID,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   856
+			    event, printer, slabel, job_ID, job_ID_remote,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   857
+			    filelist, ai, status, return_val,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   858
+			    i, job_id, remote);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   859
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   860
+			if (filelist != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   861
+				filelist = strtok(NULL, ",");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   862
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   863
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   864
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   865
+		/* Local Request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   866
+		while (filelist != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   867
+			cups_audit_print_request_data(event_ID,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   868
+			    event, printer, slabel, job_ID, job_ID_remote,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   869
+			    filelist, ai, status, return_val,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   870
+			    0, job_id, remote);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   871
+			filelist = strtok(NULL, ",");
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   872
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   873
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   874
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   875
+	if (ai != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   876
+		freeaddrinfo(ai);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   877
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   878
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   879
+	adt_free_event(event);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   880
+}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   881
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   882
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   883
+ * To populate the audit events, cups_audit_print_request() is called.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   884
+ * cups_audit_print_request() calls cups_audit_print_request_common()
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   885
+ * which in turns calls cups_audit_print_request_sub() which finally
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   886
+ * calls cups_audit_print_request_data().
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   887
+ *
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   888
+ * ah 			= Audit session handle
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   889
+ * request_ID		= <printer-name>-<job_id>;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   890
+ *			 <printer-name>-none in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   891
+ *			 a request is denied before job gets created.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   892
+ * job_id		= job->id; Job identification number.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   893
+ *			 -1 in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   894
+ *			 a request is denied before job gets created.	
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   895
+ * job_state		= ipp_jstate_t enum:
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   896
+ *	IPP_JOB_PENDING = 3,	Job is waiting to be printed
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   897
+ *	IPP_JOB_HELD,		Job is held for printing
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   898
+ * 	IPP_JOB_PROCESSING,	Job is currently printing
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   899
+ * 	IPP_JOB_STOPPED,	Job has been stopped
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   900
+ * 	IPP_JOB_CANCELED,	Job has been canceled
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   901
+ * 	IPP_JOB_ABORTED,	Job has aborted due to error
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   902
+ * 	IPP_JOB_COMPLETED	Job has completed successfully
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   903
+ *			 current job state 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   904
+ *			 -1 in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   905
+ *			 a request is denied before job gets created.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   906
+ * job_state_value 	= ipp_jstate_t; cached job state
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   907
+ *			 -1 in case of denial request when
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   908
+ *			 a request is denied before job gets created.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   909
+ * ipp 			= ipp_t; Request information
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   910
+ * printer 		= cupsd_printer_t
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   911
+ * slabel 		= Sensitivity Label
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   912
+ * username 		= Username from Authorization
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   913
+ * hname 		= name of connected host
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   914
+ * fail_reason 		= failure reason; EPERM, EACESS
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   915
+ * num_files		= 0 for initial MAC/DAC
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   916
+ *			 1 - 999 for number of files printed in a job.       
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   917
+ * denial_request	= false if cups_audit_print_request()
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   918
+ *			 true if cups_audit_print_request_denial()
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   919
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   920
+static void
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   921
+cups_audit_print_request_common(adt_session_data_t *ah,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   922
+    char *request_ID, int job_id, ipp_jstate_t job_state,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   923
+    ipp_jstate_t job_state_value, ipp_t *ipp, cupsd_printer_t *printer,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   924
+    char *slabel, char *username, char *hname, int fail_reason,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   925
+    int num_files, boolean_t denial_request)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   926
+{
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   927
+	int		authorized = 0;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   928
+	boolean_t	wants_nobanner = B_FALSE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   929
+	boolean_t	wants_nolabels = B_FALSE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   930
+	ipp_attribute_t	*attr = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   931
+	char		*document_list = NULL, *job_name = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   932
+	char		*hostname = NULL, *job_id_remote = NULL;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   933
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   934
+	/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   935
+	 * Read 'document-names', 'job-name',
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   936
+	 * 'job-id-remote' and 'job-originating-host-name'
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   937
+	 * from request.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   938
+	 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   939
+	if ((attr = ippFindAttribute(ipp, "document-names",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   940
+	    IPP_TAG_NAME)) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   941
+		document_list = attr->values[0].string.text;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   942
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   943
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   944
+	if ((attr = ippFindAttribute(ipp, "job-name", IPP_TAG_NAME)) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   945
+		job_name = attr->values[0].string.text;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   946
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   947
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   948
+	/* If input hostname is NULL, then read hostname from job */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   949
+	if (hname == NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   950
+		if ((attr = ippFindAttribute(ipp, "job-originating-host-name",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   951
+		    IPP_TAG_NAME)) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   952
+			hostname = attr->values[0].string.text;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   953
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   954
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   955
+		hostname = hname;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   956
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   957
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   958
+	if ((attr = ippFindAttribute(ipp, "job-id-remote",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   959
+	    IPP_TAG_NAME)) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   960
+		job_id_remote = attr->values[0].string.text;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   961
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   962
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   963
+	/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   964
+	 * '-o job-sheets=none,none' means
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   965
+	 * user does not want to print banner and trailer page.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   966
+	 * In trusted system, '-o job-sheets=none' and '-o job-sheets=none,none'
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   967
+	 * means same.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   968
+	 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   969
+	if ((attr = ippFindAttribute(ipp, "job-sheets",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   970
+	    IPP_TAG_ZERO)) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   971
+		if (strcmp(attr->values[0].string.text, "none") == 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   972
+			wants_nobanner = B_TRUE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   973
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   974
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   975
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   976
+	if (wants_nobanner) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   977
+		authorized = chkauthattr(PRINT_NOBANNER_AUTH, username);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   978
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   979
+		/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   980
+		 * In case of normal print request
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   981
+		 * fail_reason is based on authorized.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   982
+		 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   983
+		if (!denial_request) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   984
+			if (authorized) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   985
+				fail_reason = 0;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   986
+			} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   987
+				fail_reason = ADT_FAIL_VALUE_AUTH;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   988
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   989
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   990
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   991
+		cups_audit_print_request_sub(
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   992
+		    ADT_print_request_nobanner, ah, printer->name,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   993
+		    request_ID, job_id, job_id_remote, job_state,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   994
+		    job_state_value, hostname, document_list,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   995
+		    job_name, slabel, fail_reason,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   996
+		    authorized, num_files, wants_nobanner);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   997
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   998
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
   999
+	/* chk for 'nolabels' in request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1000
+	if (ippFindAttribute(ipp, "labels", IPP_TAG_ZERO) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1001
+		wants_nolabels = B_TRUE;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1002
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1003
+		authorized = chkauthattr(PRINT_UNLABELED_AUTH, username);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1004
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1005
+		/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1006
+		 * In case of normal print request
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1007
+		 * fail_reason is based on authorized.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1008
+		 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1009
+		if (!denial_request) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1010
+			if (authorized) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1011
+				fail_reason = 0;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1012
+			} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1013
+				fail_reason = ADT_FAIL_VALUE_AUTH;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1014
+			}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1015
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1016
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1017
+		cups_audit_print_request_sub(
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1018
+		    ADT_print_request_unlabeled, ah, printer->name,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1019
+		    request_ID, job_id, job_id_remote, job_state,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1020
+		    job_state_value, hostname, document_list,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1021
+		    job_name, slabel, fail_reason,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1022
+		    authorized, num_files, wants_nobanner);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1023
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1024
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1025
+	if (!wants_nolabels && !wants_nobanner) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1026
+		/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1027
+		 * In case of normal print request
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1028
+		 * fail_reason is based on authorized.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1029
+		 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1030
+		if (!denial_request) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1031
+			fail_reason = 0;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1032
+		}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1033
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1034
+		cups_audit_print_request_sub(
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1035
+		    ADT_print_request, ah, printer->name,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1036
+		    request_ID, job_id, job_id_remote, job_state,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1037
+		    job_state_value, hostname, document_list,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1038
+		    job_name, slabel, fail_reason,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1039
+		    1, num_files, wants_nobanner);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1040
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1041
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1042
+	(void) adt_end_session(ah);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1043
+}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1044
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1045
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1046
+ * Routine for auditing print requests which have been validated.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1047
+ * This means user has all of the required authorizations, the
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1048
+ * ability to print to the designated printer and the printer is
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1049
+ * within the user's label range.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1050
+ *
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1051
+ * cupsd_job_[s]t int id			Job ID
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1052
+ *		ipp_jstate_t state_value	Cached job-state
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1053
+ *		char *slabel			Sensitivity Label
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1054
+ *		adt_session_data *ah		Audit session handle
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1055
+ *		char *username			Printing user
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1056
+ *		int num_files			Number of files in job
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1057
+ *		ipp_t *attrs			Job attributes
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1058
+ *			place to get attributes of job such as
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1059
+ *			document-names, job-name, job-originating-host-name,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1060
+ *			job-id-remote, job-sheets, labels
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1061
+ *		cupsd_printer_t *printer	Printer this job is assigned to
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1062
+ *			char *name	Printer name
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1063
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1064
+void
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1065
+cups_audit_print_request(cupsd_job_t *job, ipp_jstate_t job_state)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1066
+{
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1067
+	char	request_ID[REQ_MAX_NAME];
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1068
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1069
+	snprintf(request_ID, sizeof (request_ID), "%s-%d",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1070
+	    job->printer->name, job->id);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1071
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1072
+	cups_audit_print_request_common(job->ah, request_ID,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1073
+	    job->id, job_state, job->state_value, job->attrs,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1074
+	    job->printer, job->slabel, job->username, NULL, 0,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1075
+	    job->num_files, B_FALSE);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1076
+}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1077
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1078
+/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1079
+ * Routine for auditing print request which have been denied due
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1080
+ * to lack of authorization or the printer access list is configured
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1081
+ * to deny access to the user.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1082
+ * 'fail_reason' will be either EPERM or EACCES based on DAC or MAC
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1083
+ * failure resp.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1084
+ *
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1085
+ * cupsd_client_[s]t
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1086
+ *	adt_session_data_t	*ah	Audit session handle
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1087
+ *	ipp_t	*request	IPP request information
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1088
+ *		appears equivalent to job->attrs above.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1089
+ *	char	*slabel		Sesnitivity Label
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1090
+ *	char	*username	Username from Authorization
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1091
+ *	http_t	http		HTTP client connection
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1092
+ *	char    *hostname	name of connected host
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1093
+ *
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1094
+ */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1095
+void
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1096
+cups_audit_print_request_denial(cupsd_client_t *con, cupsd_job_t *job,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1097
+    cupsd_printer_t *printer, ipp_jstate_t job_state, int fail_reason)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1098
+{
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1099
+	char request_ID[REQ_MAX_NAME];
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1100
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1101
+	/*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1102
+	 * If connection is not NULL, audit based on connection and
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1103
+	 * not job.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1104
+	 */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1105
+	if (con != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1106
+		sprintf(request_ID, "%s-none", printer->name);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1107
+		cups_audit_print_request_common(con->ah, request_ID,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1108
+		    -1, -1, -1, con->request, printer, con->slabel,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1109
+		    con->username, con->http.hostname, fail_reason, 0, B_TRUE);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1110
+	} else {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1111
+		sprintf(request_ID, "%s-%d", job->printer->name, job->id);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1112
+		cups_audit_print_request_common(job->ah, request_ID,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1113
+		    job->id, job_state, job->state_value, job->attrs,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1114
+		    printer, job->slabel, job->username, NULL, fail_reason,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1115
+		    job->num_files, B_TRUE);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1116
+	}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1117
+}
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1118
--- scheduler/Makefile	Wed Jan  2 23:21:35 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1119
+++ scheduler/Makefile	Wed Jan  2 21:46:49 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1120
@@ -16,6 +16,7 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1121
 include ../Makedefs
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1122
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1123
 CUPSDOBJS =	\
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1124
+		audit.o \
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1125
 		auth.o \
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1126
 		banners.o \
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1127
 		cert.o \
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1128
--- backend/ipp.c	Thu Jan 14 14:40:19 2010
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1129
+++ backend/ipp.c	Wed Jan  2 21:46:02 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1130
@@ -893,6 +893,15 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1131
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1132
         	 NULL, uri);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1133
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1134
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1135
+    if (is_system_labeled() != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1136
+      /* Keep a track of the remote job-id */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1137
+      if (argv[1][0])
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1138
+	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1139
+		     "job-id-remote", NULL, argv[1]);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1140
+    }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1141
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1142
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1143
     fprintf(stderr, "DEBUG: printer-uri = \"%s\"\n", uri);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1144
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1145
     if (argv[2][0])
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1146
--- cups/util.c	Thu Jan  3 00:07:27 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1147
+++ cups/util.c	Thu Jan  3 02:00:02 2013
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1148
@@ -220,8 +220,11 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1149
 		*response;		/* Create-Job response */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1150
   ipp_attribute_t *attr;		/* job-id attribute */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1151
   int		job_id = 0;		/* job-id value */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1152
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1153
+  const char	*filelist;		/* list of input files */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1154
+  const char	uid[11], gid[11];	/* user id and group id */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1155
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1156
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1157
-
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1158
   DEBUG_printf(("cupsCreateJob(http=%p, name=\"%s\", title=\"%s\", "
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1159
                 "num_options=%d, options=%p)",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1160
                 http, name, title, num_options, options));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1161
@@ -257,6 +260,28 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1162
   if (title)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1163
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1164
                  title);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1165
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1166
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1167
+  if (is_system_labeled() != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1168
+    if ((filelist = cupsGetOption("filelist", num_options, options)) != NULL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1169
+      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-names",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1170
+                   NULL, filelist);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1171
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1172
+     /* Add userID and groupID of the user who submitted the request */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1173
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1174
+     /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1175
+      * When uid and gid are added to the attributes using ippAddInteger,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1176
+      * ippFindAttribute from the scheduler is not able to read the attribute,
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1177
+      * so using ippAddString to add uid and gid.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1178
+      */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1179
+    snprintf(uid, sizeof(uid), "%d", getuid());
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1180
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "userID", NULL, uid);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1181
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1182
+    snprintf(gid, sizeof(gid), "%d", getgid());
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1183
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "groupID", NULL, gid);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1184
+  }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1185
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1186
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1187
   cupsEncodeOptions(request, num_options, options);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1188
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1189
  /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1190
@@ -1462,8 +1487,12 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1191
   _cups_globals_t *cg = _cupsGlobals();	/* Global data */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1192
   ipp_status_t	cancel_status;		/* Status code to preserve */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1193
   char		*cancel_message;	/* Error message to preserve */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1194
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1195
+  int		listlen = 0;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1196
+  char		*filelist;		/* file list */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1197
+  char		resolved_path[PATH_MAX];
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1198
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1199
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1200
-
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1201
   DEBUG_printf(("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, "
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1202
                 "files=%p, title=\"%s\", num_options=%d, options=%p)",
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1203
                 http, name, num_files, files, title, num_options, options));
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1204
@@ -1479,6 +1508,56 @@
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1205
     return (0);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1206
   }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1207
 
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1208
+#if defined(HAVE_TSOL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1209
+  if (is_system_labeled() != 0) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1210
+    /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1211
+     * Read the list of files and add to options.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1212
+     * In options it will be stored like 'filelist=f1,f2,f3'
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1213
+     */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1214
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1215
+    /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1216
+     * Maximum number of files to be printed should not be
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1217
+     * more than 1000.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1218
+     */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1219
+    if (num_files > 1000)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1220
+        num_files = 1000;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1221
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1222
+    for(i=0; i<num_files; i++) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1223
+      if (realpath(files[i], resolved_path) != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1224
+        listlen = listlen + strlen(resolved_path);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1225
+      } else
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1226
+        listlen = listlen + strlen(files[i]);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1227
+    }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1228
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1229
+    /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1230
+     * Add num_files to listlen to make room for ','
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1231
+     * and NULL terminated string.
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1232
+     */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1233
+    listlen = listlen + num_files;
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1234
+    filelist = malloc(listlen);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1235
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1236
+    if (filelist != NULL) {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1237
+      if (realpath(files[0], resolved_path) != NULL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1238
+          strlcpy(filelist, resolved_path, listlen);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1239
+      else
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1240
+          strlcpy(filelist, files[0], listlen);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1241
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1242
+      for (i=1; i<num_files; i++)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1243
+      {
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1244
+          strlcat(filelist, ",", listlen);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1245
+          if (realpath(files[i], resolved_path) != NULL)
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1246
+            strlcat(filelist, resolved_path, listlen);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1247
+          else
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1248
+            strlcat(filelist, files[i], listlen);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1249
+      }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1250
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1251
+      num_options = cupsAddOption("filelist", filelist, num_options, &options);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1252
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1253
+      free(filelist);
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1254
+    }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1255
+  }
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1256
+#endif /* HAVE_TSOL */
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1257
+
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1258
  /*
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1259
   * Create the print job...
eb04a6ca141d 15698471 cups should audit printing information in TX environments
Sonam Gupta <sonam.x.gupta@oracle.com>
parents:
diff changeset
  1260
   */