2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/config.h.in.lspp cups-2.2.2/config.h.in
|
|
|
|
--- cups-2.2.2/config.h.in.lspp 2017-01-17 20:27:22.000000000 +0100
|
|
|
|
+++ cups-2.2.2/config.h.in 2017-01-19 11:34:39.235988617 +0100
|
|
|
|
@@ -730,4 +730,11 @@ static __inline int _cups_abs(int i) { r
|
2014-01-08 17:53:40 +00:00
|
|
|
# endif /* __GNUC__ || __STDC_VERSION__ */
|
|
|
|
#endif /* !HAVE_ABS && !abs */
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Are we trying to meet LSPP requirements?
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#undef WITH_LSPP
|
|
|
|
+
|
|
|
|
+
|
|
|
|
#endif /* !_CUPS_CONFIG_H_ */
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/config-scripts/cups-lspp.m4.lspp cups-2.2.2/config-scripts/cups-lspp.m4
|
|
|
|
--- cups-2.2.2/config-scripts/cups-lspp.m4.lspp 2017-01-19 11:34:39.235988617 +0100
|
|
|
|
+++ cups-2.2.2/config-scripts/cups-lspp.m4 2017-01-19 11:34:39.235988617 +0100
|
2008-07-18 12:12:59 +00:00
|
|
|
@@ -0,0 +1,36 @@
|
|
|
|
+dnl
|
|
|
|
+dnl LSPP code for the Common UNIX Printing System (CUPS).
|
|
|
|
+dnl
|
|
|
|
+dnl Copyright 2005-2006 by Hewlett-Packard Development Company, L.P.
|
|
|
|
+dnl
|
|
|
|
+dnl This program is free software; you can redistribute it and/or modify
|
|
|
|
+dnl it under the terms of the GNU General Public License as published by
|
|
|
|
+dnl the Free Software Foundation; version 2.
|
|
|
|
+dnl
|
|
|
|
+dnl This program is distributed in the hope that it will be useful, but
|
|
|
|
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
+dnl General Public License for more details.
|
|
|
|
+dnl
|
|
|
|
+dnl You should have received a copy of the GNU General Public License
|
|
|
|
+dnl along with this program; if not, write to the Free Software Foundation,
|
|
|
|
+dnl Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301 USA
|
|
|
|
+dnl
|
|
|
|
+
|
|
|
|
+dnl Are we trying to meet LSPP requirements
|
|
|
|
+AC_ARG_ENABLE(lspp, [ --enable-lspp turn on auditing and label support, default=no])
|
|
|
|
+
|
|
|
|
+if test x"$enable_lspp" != xno; then
|
|
|
|
+ case "$uname" in
|
|
|
|
+ Linux)
|
|
|
|
+ AC_CHECK_LIB(audit,audit_log_user_message, [LIBAUDIT="-laudit" AC_SUBST(LIBAUDIT)])
|
|
|
|
+ AC_CHECK_HEADER(libaudit.h)
|
|
|
|
+ AC_CHECK_LIB(selinux,getpeercon, [LIBSELINUX="-lselinux" AC_SUBST(LIBSELINUX)])
|
|
|
|
+ AC_CHECK_HEADER(selinux/selinux.h)
|
|
|
|
+ AC_DEFINE(WITH_LSPP)
|
|
|
|
+ ;;
|
|
|
|
+ *)
|
|
|
|
+ # All others
|
|
|
|
+ ;;
|
|
|
|
+ esac
|
|
|
|
+fi
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/configure.ac.lspp cups-2.2.2/configure.ac
|
|
|
|
--- cups-2.2.2/configure.ac.lspp 2017-01-17 20:27:22.000000000 +0100
|
|
|
|
+++ cups-2.2.2/configure.ac 2017-01-19 11:34:39.235988617 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -38,6 +38,8 @@ sinclude(config-scripts/cups-startup.m4)
|
2012-08-08 11:28:28 +00:00
|
|
|
sinclude(config-scripts/cups-defaults.m4)
|
2008-07-18 12:12:59 +00:00
|
|
|
sinclude(config-scripts/cups-scripting.m4)
|
|
|
|
|
|
|
|
+sinclude(config-scripts/cups-lspp.m4)
|
|
|
|
+
|
|
|
|
INSTALL_LANGUAGES=""
|
|
|
|
UNINSTALL_LANGUAGES=""
|
|
|
|
LANGFILES=""
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/filter/common.c.lspp cups-2.2.2/filter/common.c
|
|
|
|
--- cups-2.2.2/filter/common.c.lspp 2017-01-17 20:27:22.000000000 +0100
|
|
|
|
+++ cups-2.2.2/filter/common.c 2017-01-19 11:34:39.235988617 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -17,6 +17,12 @@
|
2008-07-18 12:12:59 +00:00
|
|
|
* Include necessary headers...
|
|
|
|
*/
|
|
|
|
|
|
|
|
+#include "config.h"
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+#define _GNU_SOURCE
|
|
|
|
+#include <string.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
+
|
|
|
|
#include "common.h"
|
|
|
|
#include <locale.h>
|
|
|
|
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -299,6 +305,18 @@ WriteLabelProlog(const char *label, /* I
|
2008-07-18 12:12:59 +00:00
|
|
|
{
|
|
|
|
const char *classification; /* CLASSIFICATION environment variable */
|
|
|
|
const char *ptr; /* Temporary string pointer */
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ int i, /* counter */
|
|
|
|
+ n, /* counter */
|
|
|
|
+ lines, /* number of lines needed */
|
|
|
|
+ line_len, /* index into tmp_label */
|
|
|
|
+ label_len, /* length of the label in characters */
|
|
|
|
+ label_index, /* index into the label */
|
|
|
|
+ longest, /* length of the longest line */
|
|
|
|
+ longest_line, /* index to the longest line */
|
|
|
|
+ max_width; /* maximum width in characters */
|
|
|
|
+ char **wrapped_label; /* label with line breaks */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -321,6 +339,124 @@ WriteLabelProlog(const char *label, /* I
|
2008-07-18 12:12:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (strncmp(classification, "LSPP:", 5) == 0 && label == NULL)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * Based on the 12pt fixed width font below determine the max_width
|
|
|
|
+ */
|
|
|
|
+ max_width = width / 8;
|
|
|
|
+ longest_line = 0;
|
|
|
|
+ longest = 0;
|
|
|
|
+ classification += 5; // Skip the "LSPP:"
|
|
|
|
+ label_len = strlen(classification);
|
|
|
|
+
|
|
|
|
+ if (label_len > max_width)
|
|
|
|
+ {
|
|
|
|
+ lines = 1 + (int)(label_len / max_width);
|
|
|
|
+ line_len = (int)(label_len / lines);
|
2011-03-25 15:56:11 +00:00
|
|
|
+ wrapped_label = malloc(sizeof(*wrapped_label) * lines);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ label_index = i = n = 0;
|
|
|
|
+ while (classification[label_index])
|
|
|
|
+ {
|
|
|
|
+ if ((label_index + line_len) > label_len)
|
|
|
|
+ break;
|
|
|
|
+ switch (classification[label_index + line_len + i])
|
|
|
|
+ {
|
|
|
|
+ case ':':
|
|
|
|
+ case ',':
|
|
|
|
+ case '-':
|
|
|
|
+ i++;
|
|
|
|
+ wrapped_label[n++] = strndup(&classification[label_index], (line_len + i));
|
|
|
|
+ label_index += line_len + i;
|
|
|
|
+ i = 0;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ i++;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if ((i + line_len) == max_width)
|
|
|
|
+ {
|
|
|
|
+ wrapped_label[n++] = strndup(&(classification[label_index]), (line_len + i));
|
|
|
|
+ label_index = label_index + line_len + i;
|
|
|
|
+ i = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wrapped_label[n] = strndup(&classification[label_index], label_len - label_index);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ lines = 1;
|
2011-03-25 15:56:11 +00:00
|
|
|
+ wrapped_label = malloc(sizeof(*wrapped_label));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ wrapped_label[0] = (char*)classification;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (n = 0; n < lines; n++ )
|
|
|
|
+ {
|
|
|
|
+ printf("userdict/ESPp%c(", ('a' + n));
|
|
|
|
+ for (ptr = wrapped_label[n], i = 0; *ptr; ptr ++, i++)
|
|
|
|
+ if (*ptr < 32 || *ptr > 126)
|
|
|
|
+ printf("\\%03o", *ptr);
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (*ptr == '(' || *ptr == ')' || *ptr == '\\')
|
|
|
|
+ putchar('\\');
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ printf("%c", *ptr);
|
|
|
|
+ }
|
|
|
|
+ if (i > longest)
|
|
|
|
+ {
|
|
|
|
+ longest = i;
|
|
|
|
+ longest_line = n;
|
|
|
|
+ }
|
|
|
|
+ printf(")put\n");
|
|
|
|
+ }
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * For LSPP use a fixed width font so that line wrapping can be calculated
|
|
|
|
+ */
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ puts("userdict/ESPlf /Nimbus-Mono findfont 12 scalefont put");
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * Finally, the procedure to write the labels on the page...
|
|
|
|
+ */
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ printf("userdict/ESPwl{\n"
|
|
|
|
+ " ESPlf setfont\n");
|
|
|
|
+ printf(" ESPp%c stringwidth pop dup 12 add exch -0.5 mul %.0f add\n ",
|
|
|
|
+ 'a' + longest_line, width * 0.5f);
|
|
|
|
+ for (n = 1; n < lines; n++)
|
|
|
|
+ printf(" dup");
|
|
|
|
+ printf("\n 1 setgray\n");
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrf\n",
|
|
|
|
+ (bottom - 2.0), (2 + lines), 6.0 + (16.0 * lines));
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrf\n",
|
|
|
|
+ (top - 6.0 - (16.0 * lines)), (2 + lines), 4.0 + (16.0 * lines));
|
|
|
|
+ printf(" 0 setgray\n");
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrs\n",
|
|
|
|
+ (bottom - 2.0), (2 + lines), 6.0 + (16.0 * lines));
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrs\n",
|
|
|
|
+ (top - 6.0 - (16.0 * lines)), (2 + lines), 4.0 + (16.0 * lines));
|
|
|
|
+ for (n = 0; n < lines; n ++)
|
|
|
|
+ {
|
|
|
|
+ printf(" dup %.0f moveto ESPp%c show\n",
|
|
|
|
+ bottom + 6.0 + ((lines - (n+1)) * 16.0), 'a' + n);
|
|
|
|
+ printf(" %.0f moveto ESPp%c show\n", top + 2.0 - ((n + 1) * 16.0), 'a' + n);
|
|
|
|
+ }
|
|
|
|
+ printf(" pop\n"
|
|
|
|
+ "}bind put\n");
|
2006-10-03 10:57:31 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * Do some clean up at the end of the LSPP special case
|
|
|
|
+ */
|
|
|
|
+ free(wrapped_label);
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+#endif /* !WITH_LSPP */
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Set the classification + page label string...
|
|
|
|
*/
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -401,7 +537,10 @@ WriteLabelProlog(const char *label, /* I
|
2008-07-18 12:12:59 +00:00
|
|
|
printf(" %.0f moveto ESPpl show\n", top - 14.0);
|
|
|
|
puts("pop");
|
|
|
|
puts("}bind put");
|
|
|
|
+ }
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
}
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
2008-10-30 14:31:23 +00:00
|
|
|
/*
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/filter/pstops.c.lspp cups-2.2.2/filter/pstops.c
|
|
|
|
--- cups-2.2.2/filter/pstops.c.lspp 2017-01-17 20:27:22.000000000 +0100
|
|
|
|
+++ cups-2.2.2/filter/pstops.c 2017-01-19 11:34:39.236988608 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -3176,6 +3176,18 @@ write_label_prolog(pstops_doc_t *doc, /*
|
2008-10-30 14:31:23 +00:00
|
|
|
{
|
|
|
|
const char *classification; /* CLASSIFICATION environment variable */
|
|
|
|
const char *ptr; /* Temporary string pointer */
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ int i, /* counter */
|
|
|
|
+ n, /* counter */
|
|
|
|
+ lines, /* number of lines needed */
|
|
|
|
+ line_len, /* index into tmp_label */
|
|
|
|
+ label_len, /* length of the label in characters */
|
|
|
|
+ label_index, /* index into the label */
|
|
|
|
+ longest, /* length of the longest line */
|
|
|
|
+ longest_line, /* index to the longest line */
|
|
|
|
+ max_width; /* maximum width in characters */
|
|
|
|
+ char **wrapped_label; /* label with line breaks */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -3198,6 +3210,124 @@ write_label_prolog(pstops_doc_t *doc, /*
|
2008-10-30 14:31:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (strncmp(classification, "LSPP:", 5) == 0 && label == NULL)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * Based on the 12pt fixed width font below determine the max_width
|
|
|
|
+ */
|
|
|
|
+ max_width = width / 8;
|
|
|
|
+ longest_line = 0;
|
|
|
|
+ longest = 0;
|
|
|
|
+ classification += 5; // Skip the "LSPP:"
|
|
|
|
+ label_len = strlen(classification);
|
|
|
|
+
|
|
|
|
+ if (label_len > max_width)
|
|
|
|
+ {
|
|
|
|
+ lines = 1 + (int)(label_len / max_width);
|
|
|
|
+ line_len = (int)(label_len / lines);
|
2011-03-25 15:56:11 +00:00
|
|
|
+ wrapped_label = malloc(sizeof(*wrapped_label) * lines);
|
2008-10-30 14:31:23 +00:00
|
|
|
+ label_index = i = n = 0;
|
|
|
|
+ while (classification[label_index])
|
|
|
|
+ {
|
|
|
|
+ if ((label_index + line_len) > label_len)
|
|
|
|
+ break;
|
|
|
|
+ switch (classification[label_index + line_len + i])
|
|
|
|
+ {
|
|
|
|
+ case ':':
|
|
|
|
+ case ',':
|
|
|
|
+ case '-':
|
|
|
|
+ i++;
|
|
|
|
+ wrapped_label[n++] = strndup(&classification[label_index], (line_len + i));
|
|
|
|
+ label_index += line_len + i;
|
|
|
|
+ i = 0;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ i++;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if ((i + line_len) == max_width)
|
|
|
|
+ {
|
|
|
|
+ wrapped_label[n++] = strndup(&(classification[label_index]), (line_len + i));
|
|
|
|
+ label_index = label_index + line_len + i;
|
|
|
|
+ i = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wrapped_label[n] = strndup(&classification[label_index], label_len - label_index);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ lines = 1;
|
2011-03-25 15:56:11 +00:00
|
|
|
+ wrapped_label = malloc(sizeof(*wrapped_label));
|
2008-10-30 14:31:23 +00:00
|
|
|
+ wrapped_label[0] = (char*)classification;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (n = 0; n < lines; n++ )
|
|
|
|
+ {
|
|
|
|
+ printf("userdict/ESPp%c(", ('a' + n));
|
|
|
|
+ for (ptr = wrapped_label[n], i = 0; *ptr; ptr ++, i++)
|
|
|
|
+ if (*ptr < 32 || *ptr > 126)
|
|
|
|
+ printf("\\%03o", *ptr);
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (*ptr == '(' || *ptr == ')' || *ptr == '\\')
|
|
|
|
+ putchar('\\');
|
|
|
|
+
|
|
|
|
+ printf("%c", *ptr);
|
|
|
|
+ }
|
|
|
|
+ if (i > longest)
|
|
|
|
+ {
|
|
|
|
+ longest = i;
|
|
|
|
+ longest_line = n;
|
|
|
|
+ }
|
|
|
|
+ printf(")put\n");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * For LSPP use a fixed width font so that line wrapping can be calculated
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ puts("userdict/ESPlf /Nimbus-Mono findfont 12 scalefont put");
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Finally, the procedure to write the labels on the page...
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ printf("userdict/ESPwl{\n"
|
|
|
|
+ " ESPlf setfont\n");
|
|
|
|
+ printf(" ESPp%c stringwidth pop dup 12 add exch -0.5 mul %.0f add\n ",
|
|
|
|
+ 'a' + longest_line, width * 0.5f);
|
|
|
|
+ for (n = 1; n < lines; n++)
|
|
|
|
+ printf(" dup");
|
|
|
|
+ printf("\n 1 setgray\n");
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrf\n",
|
|
|
|
+ (bottom - 2.0), (2 + lines), 6.0 + (16.0 * lines));
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrf\n",
|
|
|
|
+ (top - 6.0 - (16.0 * lines)), (2 + lines), 4.0 + (16.0 * lines));
|
|
|
|
+ printf(" 0 setgray\n");
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrs\n",
|
|
|
|
+ (bottom - 2.0), (2 + lines), 6.0 + (16.0 * lines));
|
|
|
|
+ printf(" dup 6 sub %.0f %d index %.0f ESPrs\n",
|
|
|
|
+ (top - 6.0 - (16.0 * lines)), (2 + lines), 4.0 + (16.0 * lines));
|
|
|
|
+ for (n = 0; n < lines; n ++)
|
|
|
|
+ {
|
|
|
|
+ printf(" dup %.0f moveto ESPp%c show\n",
|
|
|
|
+ bottom + 6.0 + ((lines - (n+1)) * 16.0), 'a' + n);
|
|
|
|
+ printf(" %.0f moveto ESPp%c show\n", top + 2.0 - ((n + 1) * 16.0), 'a' + n);
|
|
|
|
+ }
|
|
|
|
+ printf(" pop\n"
|
|
|
|
+ "}bind put\n");
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Do some clean up at the end of the LSPP special case
|
|
|
|
+ */
|
|
|
|
+ free(wrapped_label);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+#endif /* !WITH_LSPP */
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Set the classification + page label string...
|
|
|
|
*/
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -3276,7 +3406,10 @@ write_label_prolog(pstops_doc_t *doc, /*
|
2008-10-30 14:31:23 +00:00
|
|
|
doc_printf(doc, " %.0f moveto ESPpl show\n", top - 14.0);
|
|
|
|
doc_puts(doc, "pop\n");
|
|
|
|
doc_puts(doc, "}bind put\n");
|
|
|
|
+ }
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
}
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/Makedefs.in.lspp cups-2.2.2/Makedefs.in
|
|
|
|
--- cups-2.2.2/Makedefs.in.lspp 2017-01-19 11:34:39.206988873 +0100
|
|
|
|
+++ cups-2.2.2/Makedefs.in 2017-01-19 11:34:39.236988608 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -143,7 +143,7 @@ LDFLAGS = -L../cgi-bin -L../cups -L../f
|
2014-01-08 17:53:40 +00:00
|
|
|
@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
|
2014-09-12 16:19:24 +00:00
|
|
|
LINKCUPS = @LINKCUPS@ $(LIBGSSAPI) $(DNSSDLIBS) $(LIBZ)
|
2014-01-08 17:53:40 +00:00
|
|
|
LINKCUPSIMAGE = @LINKCUPSIMAGE@
|
|
|
|
-LIBS = $(LINKCUPS) $(COMMONLIBS)
|
|
|
|
+LIBS = $(LINKCUPS) $(COMMONLIBS) @LIBAUDIT@ @LIBSELINUX@
|
2014-09-12 16:19:24 +00:00
|
|
|
ONDEMANDFLAGS = @ONDEMANDFLAGS@
|
|
|
|
ONDEMANDLIBS = @ONDEMANDLIBS@
|
2014-01-08 17:53:40 +00:00
|
|
|
OPTIM = @OPTIM@
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/client.c.lspp cups-2.2.2/scheduler/client.c
|
|
|
|
--- cups-2.2.2/scheduler/client.c.lspp 2017-01-17 20:27:22.000000000 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/client.c 2017-01-19 11:34:39.281988212 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -22,12 +22,20 @@
|
2014-09-12 16:19:24 +00:00
|
|
|
#define _HTTP_NO_PRIVATE
|
2008-07-18 12:12:59 +00:00
|
|
|
#include "cupsd.h"
|
|
|
|
|
2014-11-06 14:48:42 +00:00
|
|
|
+#ifndef _GNU_SOURCE
|
2008-11-12 16:09:54 +00:00
|
|
|
+#define _GNU_SOURCE
|
2014-11-06 14:48:42 +00:00
|
|
|
+#endif /* !defined(_GNU_SOURCE) */
|
2013-04-19 10:52:50 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
# include <libproc.h>
|
|
|
|
#endif /* __APPLE__ */
|
2014-11-06 14:48:42 +00:00
|
|
|
#ifdef HAVE_TCPD_H
|
2008-11-12 16:09:54 +00:00
|
|
|
# include <tcpd.h>
|
|
|
|
#endif /* HAVE_TCPD_H */
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
2014-11-06 14:48:42 +00:00
|
|
|
+# include <selinux/selinux.h>
|
|
|
|
+# include <selinux/context.h>
|
|
|
|
+# include <fcntl.h>
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
2014-11-06 14:48:42 +00:00
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -266,6 +274,59 @@ cupsdAcceptClient(cupsd_listener_t *lis)
|
2008-07-18 12:12:59 +00:00
|
|
|
}
|
2008-11-12 16:09:54 +00:00
|
|
|
#endif /* HAVE_TCPD_H */
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (is_lspp_config())
|
|
|
|
+ {
|
|
|
|
+ struct ucred cr;
|
|
|
|
+ unsigned int cl=sizeof(cr);
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2014-09-12 16:19:24 +00:00
|
|
|
+ if (getsockopt(httpGetFd(con->http), SOL_SOCKET, SO_PEERCRED, &cr, &cl) == 0)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * client_pid_to_auid() can be racey
|
|
|
|
+ * In this case the pid is based on a socket connected to the client
|
|
|
|
+ */
|
|
|
|
+ if ((con->auid = client_pid_to_auid(cr.pid)) == -1)
|
|
|
|
+ {
|
2014-09-12 16:19:24 +00:00
|
|
|
+ httpClose(con->http);
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogClient(con, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to determine client auid for client pid=%d",
|
|
|
|
+ cr.pid);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ free(con);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogClient(con, CUPSD_LOG_INFO,
|
|
|
|
+ "peer's pid=%d, uid=%d, gid=%d, auid=%d",
|
|
|
|
+ cr.pid, cr.uid, cr.gid, con->auid);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
2014-09-12 16:19:24 +00:00
|
|
|
+ httpClose(con->http);
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogClient(con, CUPSD_LOG_ERROR, "getsockopt() failed");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ free(con);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * get the context of the peer connection
|
|
|
|
+ */
|
2014-09-12 16:19:24 +00:00
|
|
|
+ if (getpeercon(httpGetFd(con->http), &con->scon))
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
2014-09-12 16:19:24 +00:00
|
|
|
+ httpClose(con->http);
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogClient(con, CUPSD_LOG_ERROR, "getpeercon() failed");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ free(con);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogClient(con, CUPSD_LOG_INFO, "client context=%s", con->scon);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogClient(con, CUPSD_LOG_DEBUG, "skipping getpeercon()");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ cupsdSetString(&con->scon, UNKNOWN_SL);
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
+
|
2011-05-24 12:27:29 +00:00
|
|
|
#ifdef AF_LOCAL
|
2014-09-12 16:19:24 +00:00
|
|
|
if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL)
|
2013-04-19 10:52:50 +00:00
|
|
|
{
|
2015-06-09 15:56:57 +00:00
|
|
|
@@ -560,6 +621,13 @@ cupsdReadClient(cupsd_client_t *con) /*
|
2008-07-18 12:12:59 +00:00
|
|
|
mime_type_t *type; /* MIME type of file */
|
|
|
|
cupsd_printer_t *p; /* Printer */
|
|
|
|
static unsigned request_id = 0; /* Request ID for temp files */
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ security_context_t spoolcon; /* context of the job file */
|
|
|
|
+ context_t clicon; /* contex_t container for con->scon */
|
|
|
|
+ context_t tmpcon; /* temp context to swap the level */
|
|
|
|
+ char *clirange; /* SELinux sensitivity range */
|
|
|
|
+ char *cliclearance; /* SELinux low end clearance */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
2014-09-12 16:19:24 +00:00
|
|
|
status = HTTP_STATUS_CONTINUE;
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -1924,6 +1992,73 @@ cupsdReadClient(cupsd_client_t *con) /*
|
2008-07-18 12:12:59 +00:00
|
|
|
fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
|
2014-11-06 14:48:42 +00:00
|
|
|
}
|
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
2014-11-06 14:48:42 +00:00
|
|
|
+ if (strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
|
|
|
|
+ {
|
|
|
|
+ if (getfilecon(con->filename, &spoolcon) == -1)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
2014-11-06 14:48:42 +00:00
|
|
|
+ cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE);
|
|
|
|
+ cupsdCloseClient(con);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ clicon = context_new(con->scon);
|
|
|
|
+ tmpcon = context_new(spoolcon);
|
|
|
|
+ freecon(spoolcon);
|
|
|
|
+ if (!clicon || !tmpcon)
|
|
|
|
+ {
|
|
|
|
+ cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE);
|
|
|
|
+ if (clicon)
|
|
|
|
+ context_free(clicon);
|
|
|
|
+ if (tmpcon)
|
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ cupsdCloseClient(con);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ clirange = (char *) context_range_get(clicon);
|
|
|
|
+ if (clirange)
|
|
|
|
+ {
|
|
|
|
+ clirange = strdup(clirange);
|
|
|
|
+ if ((cliclearance = strtok(clirange, "-")) != NULL)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
2014-11-06 14:48:42 +00:00
|
|
|
+ if (context_range_set(tmpcon, cliclearance) == -1)
|
|
|
|
+ {
|
|
|
|
+ cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE);
|
|
|
|
+ free(clirange);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(tmpcon);
|
2014-11-06 14:48:42 +00:00
|
|
|
+ context_free(clicon);
|
|
|
|
+ cupsdCloseClient(con);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
2014-11-06 14:48:42 +00:00
|
|
|
+ else
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
2014-11-06 14:48:42 +00:00
|
|
|
+ if (context_range_set(tmpcon, (context_range_get(clicon))) == -1)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
2014-11-06 14:48:42 +00:00
|
|
|
+ cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE);
|
|
|
|
+ free(clirange);
|
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ context_free(clicon);
|
|
|
|
+ cupsdCloseClient(con);
|
|
|
|
+ return;
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
2014-11-06 14:48:42 +00:00
|
|
|
+ free(clirange);
|
|
|
|
+ }
|
|
|
|
+ if (setfilecon(con->filename, context_str(tmpcon)) == -1)
|
|
|
|
+ {
|
|
|
|
+ cupsdSendError(con, HTTP_STATUS_SERVER_ERROR, CUPSD_AUTH_NONE);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ context_free(clicon);
|
2014-11-06 14:48:42 +00:00
|
|
|
+ cupsdCloseClient(con);
|
|
|
|
+ return;
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "%s set to %s",
|
|
|
|
+ con->filename, context_str(tmpcon));
|
2014-11-06 14:48:42 +00:00
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ context_free(clicon);
|
|
|
|
+ }
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
2014-11-06 14:48:42 +00:00
|
|
|
+
|
2014-09-12 16:19:24 +00:00
|
|
|
if (httpGetState(con->http) != HTTP_STATE_POST_SEND)
|
2014-11-06 14:48:42 +00:00
|
|
|
{
|
|
|
|
if (!httpWait(con->http, 0))
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -3456,6 +3591,49 @@ is_path_absolute(const char *path) /* I
|
2012-08-08 11:28:28 +00:00
|
|
|
return (1);
|
|
|
|
}
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+/*
|
|
|
|
+ * 'client_pid_to_auid()' - Using the client's pid, read /proc and determine the loginuid.
|
|
|
|
+ */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+uid_t client_pid_to_auid(pid_t clipid)
|
|
|
|
+{
|
|
|
|
+ uid_t uid;
|
|
|
|
+ int len, in;
|
|
|
|
+ char buf[16] = {0};
|
|
|
|
+ char fname[32] = {0};
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * Hopefully this pid is still the one we are interested in.
|
|
|
|
+ */
|
|
|
|
+ snprintf(fname, 32, "/proc/%d/loginuid", clipid);
|
|
|
|
+ in = open(fname, O_NOFOLLOW|O_RDONLY);
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (in < 0)
|
2014-11-06 14:48:42 +00:00
|
|
|
+ return (uid_t) -1;
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ errno = 0;
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ do {
|
|
|
|
+ len = read(in, buf, sizeof(buf));
|
|
|
|
+ } while (len < 0 && errno == EINTR);
|
2006-10-03 10:57:31 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ close(in);
|
2007-07-31 12:28:40 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (len < 0 || len >= sizeof(buf))
|
2014-11-06 14:48:42 +00:00
|
|
|
+ return (uid_t) -1;
|
2007-07-31 12:28:40 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ errno = 0;
|
|
|
|
+ buf[len] = 0;
|
|
|
|
+ uid = strtol(buf, 0, 10);
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (errno != 0)
|
2014-11-06 14:48:42 +00:00
|
|
|
+ return (uid_t) -1;
|
2008-07-18 12:12:59 +00:00
|
|
|
+ else
|
|
|
|
+ return uid;
|
|
|
|
+}
|
|
|
|
+#endif /* WITH_LSPP */
|
2012-08-08 11:28:28 +00:00
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* 'pipe_command()' - Pipe the output of a command to the remote client.
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/client.h.lspp cups-2.2.2/scheduler/client.h
|
|
|
|
--- cups-2.2.2/scheduler/client.h.lspp 2017-01-17 20:27:22.000000000 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/client.h 2017-01-19 11:34:39.281988212 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -16,6 +16,13 @@
|
2008-07-18 12:12:59 +00:00
|
|
|
#endif /* HAVE_AUTHORIZATION_H */
|
|
|
|
|
2008-11-12 16:09:54 +00:00
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
|
|
|
|
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
|
2006-08-21 16:26:28 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+#include <selinux/selinux.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
2006-11-22 11:59:57 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* HTTP client structure...
|
|
|
|
*/
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -65,6 +72,10 @@ struct cupsd_client_s
|
2008-07-18 12:12:59 +00:00
|
|
|
#ifdef HAVE_AUTHORIZATION_H
|
|
|
|
AuthorizationRef authref; /* Authorization ref */
|
|
|
|
#endif /* HAVE_AUTHORIZATION_H */
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ security_context_t scon; /* Security context of connection */
|
|
|
|
+ uid_t auid; /* Audit loginuid of the client */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
};
|
|
|
|
|
2014-09-12 16:19:24 +00:00
|
|
|
#define HTTP(con) ((con)->http)
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -138,6 +149,9 @@ extern void cupsdStartListening(void);
|
2008-07-18 12:12:59 +00:00
|
|
|
extern void cupsdStopListening(void);
|
|
|
|
extern void cupsdUpdateCGI(void);
|
|
|
|
extern void cupsdWriteClient(cupsd_client_t *con);
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+extern uid_t client_pid_to_auid(pid_t clipid);
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
2012-08-08 11:28:28 +00:00
|
|
|
#ifdef HAVE_SSL
|
|
|
|
extern int cupsdEndTLS(cupsd_client_t *con);
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/conf.c.lspp cups-2.2.2/scheduler/conf.c
|
|
|
|
--- cups-2.2.2/scheduler/conf.c.lspp 2017-01-19 11:34:39.232988644 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/conf.c 2017-01-19 11:34:39.282988203 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -40,6 +40,9 @@
|
2008-07-18 12:12:59 +00:00
|
|
|
# define INADDR_NONE 0xffffffff
|
|
|
|
#endif /* !INADDR_NONE */
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+# include <libaudit.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configuration variable structure...
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -131,6 +134,10 @@ static const cupsd_var_t cupsd_vars[] =
|
2012-11-27 11:33:25 +00:00
|
|
|
{ "ServerName", &ServerName, CUPSD_VARTYPE_STRING },
|
|
|
|
{ "StrictConformance", &StrictConformance, CUPSD_VARTYPE_BOOLEAN },
|
|
|
|
{ "Timeout", &Timeout, CUPSD_VARTYPE_TIME },
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ { "AuditLog", &AuditLog, CUPSD_VARTYPE_INTEGER },
|
|
|
|
+ { "PerPageLabels", &PerPageLabels, CUPSD_VARTYPE_BOOLEAN },
|
|
|
|
+#endif /* WITH_LSPP */
|
2012-11-27 11:33:25 +00:00
|
|
|
{ "WebInterface", &WebInterface, CUPSD_VARTYPE_BOOLEAN }
|
|
|
|
};
|
|
|
|
static const cupsd_var_t cupsfiles_vars[] =
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -544,6 +551,9 @@ cupsdReadConfiguration(void)
|
2008-07-18 12:12:59 +00:00
|
|
|
const char *tmpdir; /* TMPDIR environment variable */
|
|
|
|
struct stat tmpinfo; /* Temporary directory info */
|
2008-11-12 16:09:54 +00:00
|
|
|
cupsd_policy_t *p; /* Policy */
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ char *audit_message; /* Audit message string */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -866,6 +876,25 @@ cupsdReadConfiguration(void)
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
RunUser = getuid();
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (AuditLog != -1)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * ClassifyOverride is set during read_configuration, if its ON, report it now
|
|
|
|
+ */
|
|
|
|
+ if (ClassifyOverride)
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_USYS_CONFIG,
|
|
|
|
+ "[Config] ClassifyOverride=enabled Users can override print banners",
|
|
|
|
+ ServerName, NULL, NULL, 1);
|
|
|
|
+ /*
|
|
|
|
+ * PerPageLabel is set during read_configuration, if its OFF, report it now
|
|
|
|
+ */
|
|
|
|
+ if (!PerPageLabels)
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_USYS_CONFIG,
|
|
|
|
+ "[Config] PerPageLabels=disabled", ServerName, NULL, NULL, 1);
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2009-03-05 13:31:30 +00:00
|
|
|
cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
|
2009-06-17 11:30:03 +00:00
|
|
|
RemotePort ? "enabled" : "disabled");
|
2009-03-05 13:31:30 +00:00
|
|
|
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1276,7 +1305,19 @@ cupsdReadConfiguration(void)
|
2008-07-18 12:12:59 +00:00
|
|
|
cupsdClearString(&Classification);
|
|
|
|
|
|
|
|
if (Classification)
|
|
|
|
+ {
|
|
|
|
cupsdLogMessage(CUPSD_LOG_INFO, "Security set to \"%s\"", Classification);
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (AuditLog != -1)
|
|
|
|
+ {
|
|
|
|
+ audit_message = NULL;
|
|
|
|
+ cupsdSetStringf(&audit_message, "[Config] Classification=%s", Classification);
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_LABEL_LEVEL_CHANGE, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 1);
|
|
|
|
+ cupsdClearString(&audit_message);
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/*
|
2008-11-12 16:09:54 +00:00
|
|
|
* Check the MaxClients setting, and then allocate memory for it...
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -3753,6 +3794,18 @@ read_location(cups_file_t *fp, /* I - C
|
2008-09-10 15:20:58 +00:00
|
|
|
return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
|
2008-07-18 12:12:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+int is_lspp_config()
|
|
|
|
+{
|
|
|
|
+ if (Classification != NULL)
|
2011-05-26 14:27:09 +00:00
|
|
|
+ return ((_cups_strcasecmp(Classification, MLS_CONFIG) == 0)
|
|
|
|
+ || (_cups_strcasecmp(Classification, TE_CONFIG) == 0)
|
|
|
|
+ || (_cups_strcasecmp(Classification, SELINUX_CONFIG) == 0));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ else
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+#endif /* WITH_LSPP */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
/*
|
2008-09-10 15:20:58 +00:00
|
|
|
* 'read_policy()' - Read a <Policy name> definition.
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/conf.h.lspp cups-2.2.2/scheduler/conf.h
|
|
|
|
--- cups-2.2.2/scheduler/conf.h.lspp 2017-01-19 11:34:39.175989146 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/conf.h 2017-01-19 11:34:39.283988194 +0100
|
|
|
|
@@ -250,6 +250,13 @@ VAR char *ServerKeychain VALUE(NULL);
|
2014-09-12 16:19:24 +00:00
|
|
|
/* Keychain holding cert + key */
|
2008-07-18 12:12:59 +00:00
|
|
|
#endif /* HAVE_SSL */
|
2012-08-08 11:28:28 +00:00
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+VAR int AuditLog VALUE(-1),
|
|
|
|
+ /* File descriptor for audit */
|
|
|
|
+ PerPageLabels VALUE(TRUE);
|
|
|
|
+ /* Put the label on each page */
|
|
|
|
+#endif /* WITH_LSPP */
|
2012-08-08 11:28:28 +00:00
|
|
|
+
|
2016-06-27 16:29:55 +00:00
|
|
|
#ifdef HAVE_ONDEMAND
|
2014-09-12 16:19:24 +00:00
|
|
|
VAR int IdleExitTimeout VALUE(60);
|
2012-08-08 11:28:28 +00:00
|
|
|
/* Time after which an idle cupsd will exit */
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -268,6 +275,9 @@ VAR int HaveServerCreds VALUE(0);
|
2016-06-27 16:29:55 +00:00
|
|
|
VAR gss_cred_id_t ServerCreds; /* Server's GSS credentials */
|
2012-08-08 11:28:28 +00:00
|
|
|
#endif /* HAVE_GSSAPI */
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
2012-08-08 11:28:28 +00:00
|
|
|
+extern int is_lspp_config(void);
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes...
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/cupsd.h.lspp cups-2.2.2/scheduler/cupsd.h
|
|
|
|
--- cups-2.2.2/scheduler/cupsd.h.lspp 2017-01-19 11:34:39.224988714 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/cupsd.h 2017-01-19 11:34:39.283988194 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -11,6 +11,8 @@
|
2014-09-12 16:19:24 +00:00
|
|
|
* file is missing or damaged, see the license at "http://www.cups.org/".
|
2011-05-31 15:29:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
|
|
|
|
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Include necessary headers.
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -36,13 +38,20 @@
|
2011-05-31 15:29:17 +00:00
|
|
|
# include <unistd.h>
|
|
|
|
#endif /* WIN32 */
|
|
|
|
|
|
|
|
+#include "config.h"
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+# define MLS_CONFIG "mls"
|
|
|
|
+# define TE_CONFIG "te"
|
|
|
|
+# define SELINUX_CONFIG "SELinux"
|
|
|
|
+# define UNKNOWN_SL "UNKNOWN SL"
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
+
|
|
|
|
#include "mime.h"
|
|
|
|
|
|
|
|
#if defined(HAVE_CDSASSL)
|
|
|
|
# include <CoreFoundation/CoreFoundation.h>
|
|
|
|
#endif /* HAVE_CDSASSL */
|
|
|
|
|
|
|
|
-
|
|
|
|
/*
|
|
|
|
* Some OS's don't have hstrerror(), most notably Solaris...
|
|
|
|
*/
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/ipp.c.lspp cups-2.2.2/scheduler/ipp.c
|
|
|
|
--- cups-2.2.2/scheduler/ipp.c.lspp 2017-01-19 11:34:39.190989014 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/ipp.c 2017-01-19 11:49:37.704922404 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -14,6 +14,9 @@
|
2017-01-19 11:02:44 +00:00
|
|
|
* missing or damaged, see the license at "http://www.cups.org/".
|
2008-07-18 12:12:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
|
|
|
|
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* Include necessary headers...
|
|
|
|
*/
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -37,6 +40,14 @@ extern int mbr_check_membership_by_id(uu
|
2008-07-18 12:12:59 +00:00
|
|
|
# endif /* HAVE_MEMBERSHIPPRIV_H */
|
|
|
|
#endif /* __APPLE__ */
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+#include <libaudit.h>
|
|
|
|
+#include <selinux/selinux.h>
|
|
|
|
+#include <selinux/context.h>
|
|
|
|
+#include <selinux/avc.h>
|
|
|
|
+#include <selinux/flask.h>
|
|
|
|
+#include <selinux/av_permissions.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local functions...
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -61,6 +72,9 @@ static void cancel_all_jobs(cupsd_client
|
2008-07-18 12:12:59 +00:00
|
|
|
static void cancel_job(cupsd_client_t *con, ipp_attribute_t *uri);
|
|
|
|
static void cancel_subscription(cupsd_client_t *con, int id);
|
2008-07-28 15:40:15 +00:00
|
|
|
static int check_rss_recipient(const char *recipient);
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+static int check_context(cupsd_client_t *con, cupsd_job_t *job);
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
static int check_quotas(cupsd_client_t *con, cupsd_printer_t *p);
|
2012-08-08 11:28:28 +00:00
|
|
|
static void close_job(cupsd_client_t *con, ipp_attribute_t *uri);
|
|
|
|
static void copy_attrs(ipp_t *to, ipp_t *from, cups_array_t *ra,
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1265,6 +1279,21 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2013-03-18 18:26:09 +00:00
|
|
|
"time-at-creation",
|
|
|
|
"time-at-processing"
|
|
|
|
};
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ char *audit_message; /* Audit message string */
|
|
|
|
+ char *printerfile; /* device file pointed to by the printer */
|
|
|
|
+ char *userheader = NULL; /* User supplied job-sheets[0] */
|
|
|
|
+ char *userfooter = NULL; /* User supplied job-sheets[1] */
|
|
|
|
+ int override = 0; /* Was a banner overrode on a job */
|
|
|
|
+ security_id_t clisid; /* SELinux SID for the client */
|
|
|
|
+ security_id_t psid; /* SELinux SID for the printer */
|
|
|
|
+ context_t printercon; /* Printer's context string */
|
|
|
|
+ struct stat printerstat; /* Printer's stat buffer */
|
|
|
|
+ security_context_t devcon; /* Printer's SELinux context */
|
|
|
|
+ struct avc_entry_ref avcref; /* Pointer to the access vector cache */
|
|
|
|
+ security_class_t tclass; /* Object class for the SELinux check */
|
|
|
|
+ access_vector_t avr; /* Access method being requested */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
|
|
|
cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1576,6 +1605,106 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2013-04-19 10:52:50 +00:00
|
|
|
return (NULL);
|
2013-03-18 18:26:09 +00:00
|
|
|
}
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (is_lspp_config())
|
|
|
|
+ {
|
|
|
|
+ if (!con->scon || strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) == 0)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_ERROR, "add_job: missing classification for connection \'%s\'!", printer->name);
|
|
|
|
+ send_ipp_status(con, IPP_INTERNAL_ERROR, _("Missing required security attributes."));
|
|
|
|
+ return (NULL);
|
|
|
|
+ }
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * Perform an access check so that if the user gets feedback at enqueue time
|
|
|
|
+ */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ printerfile = strstr(printer->device_uri, "/dev/");
|
|
|
|
+ if (printerfile == NULL && (strncmp(printer->device_uri, "file:/", 6) == 0))
|
2009-11-23 13:08:59 +00:00
|
|
|
+ printerfile = printer->device_uri + strlen("file:");
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (printerfile != NULL)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "add_job: Attempting an access check on printer device %s",
|
|
|
|
+ printerfile);
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (lstat(printerfile, &printerstat) < 0)
|
|
|
|
+ {
|
|
|
|
+ if (errno != ENOENT)
|
|
|
|
+ {
|
|
|
|
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Unable to stat the printer"));
|
|
|
|
+ return (NULL);
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ * The printer does not exist, so for now assume it's a FileDevice
|
|
|
|
+ */
|
|
|
|
+ tclass = SECCLASS_FILE;
|
|
|
|
+ avr = FILE__WRITE;
|
|
|
|
+ }
|
|
|
|
+ else if (S_ISCHR(printerstat.st_mode))
|
|
|
|
+ {
|
|
|
|
+ tclass = SECCLASS_CHR_FILE;
|
|
|
|
+ avr = CHR_FILE__WRITE;
|
|
|
|
+ }
|
|
|
|
+ else if (S_ISREG(printerstat.st_mode))
|
|
|
|
+ {
|
|
|
|
+ tclass = SECCLASS_FILE;
|
|
|
|
+ avr = FILE__WRITE;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Printer is not a character device or regular file"));
|
|
|
|
+ return (NULL);
|
|
|
|
+ }
|
2014-11-06 13:43:32 +00:00
|
|
|
+ static int avc_initialized = 0;
|
2010-12-13 14:07:55 +00:00
|
|
|
+ if (!avc_initialized++)
|
|
|
|
+ avc_init("cupsd_enqueue_", NULL, NULL, NULL, NULL);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ avc_entry_ref_init(&avcref);
|
|
|
|
+ if (avc_context_to_sid(con->scon, &clisid) != 0)
|
|
|
|
+ {
|
|
|
|
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Unable to get the SELinux sid of the client"));
|
|
|
|
+ return (NULL);
|
|
|
|
+ }
|
|
|
|
+ if (getfilecon(printerfile, &devcon) == -1)
|
|
|
|
+ {
|
|
|
|
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Unable to get the SELinux context of the printer"));
|
|
|
|
+ return (NULL);
|
|
|
|
+ }
|
|
|
|
+ printercon = context_new(devcon);
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "add_job: printer context %s client context %s",
|
|
|
|
+ context_str(printercon), con->scon);
|
|
|
|
+ context_free(printercon);
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (avc_context_to_sid(devcon, &psid) != 0)
|
|
|
|
+ {
|
|
|
|
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Unable to get the SELinux sid of the printer"));
|
|
|
|
+ freecon(devcon);
|
|
|
|
+ return (NULL);
|
|
|
|
+ }
|
|
|
|
+ freecon(devcon);
|
|
|
|
+ if (avc_has_perm(clisid, psid, tclass, avr, &avcref, NULL) != 0)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * The access check failed, so cancel the job and send an audit message
|
|
|
|
+ */
|
|
|
|
+ if (AuditLog != -1)
|
|
|
|
+ {
|
|
|
|
+ audit_message = NULL;
|
|
|
|
+ cupsdSetStringf(&audit_message, "job=? auid=%u acct=%s obj=%s refused"
|
|
|
|
+ " unable to access printer=%s", con->auid,
|
|
|
|
+ con->username, con->scon, printer->name);
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_USER_LABELED_EXPORT, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 0);
|
|
|
|
+ cupsdClearString(&audit_message);
|
|
|
|
+ }
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ send_ipp_status(con, IPP_NOT_AUTHORIZED, _("SELinux prohibits access to the printer"));
|
|
|
|
+ return (NULL);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
if ((job = cupsdAddJob(priority, printer->name)) == NULL)
|
|
|
|
{
|
|
|
|
send_ipp_status(con, IPP_INTERNAL_ERROR,
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1584,6 +1713,32 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2008-07-18 12:12:59 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (is_lspp_config())
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * duplicate the security context and auid of the connection into the job structure
|
|
|
|
+ */
|
|
|
|
+ job->scon = strdup(con->scon);
|
|
|
|
+ job->auid = con->auid;
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * add the security context to the request so that on a restart the security
|
|
|
|
+ * attributes will be able to be restored
|
|
|
|
+ */
|
|
|
|
+ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "security-context",
|
|
|
|
+ NULL, job->scon);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * Fill in the security context of the job as unlabeled
|
|
|
|
+ */
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "add_job: setting context of job to %s", UNKNOWN_SL);
|
|
|
|
+ cupsdSetString(&job->scon, UNKNOWN_SL);
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2012-08-08 11:28:28 +00:00
|
|
|
job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE);
|
2008-07-18 12:12:59 +00:00
|
|
|
job->attrs = con->request;
|
2012-08-08 11:28:28 +00:00
|
|
|
job->dirty = 1;
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1773,6 +1928,29 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2015-06-09 15:56:57 +00:00
|
|
|
ippSetString(job->attrs, &attr, 0, printer->job_sheets[0]);
|
|
|
|
ippSetString(job->attrs, &attr, 1, printer->job_sheets[1]);
|
2008-07-18 12:12:59 +00:00
|
|
|
}
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * The option was present, so capture the user supplied strings
|
|
|
|
+ */
|
|
|
|
+ userheader = strdup(attr->values[0].string.text);
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (attr->num_values > 1)
|
|
|
|
+ userfooter = strdup(attr->values[1].string.text);
|
2015-06-09 15:56:57 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (Classification != NULL && (strcmp(userheader, Classification) == 0)
|
|
|
|
+ && userfooter &&(strcmp(userfooter, Classification) == 0))
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * Since both values are Classification, the user is not trying to Override
|
|
|
|
+ */
|
|
|
|
+ free(userheader);
|
|
|
|
+ if (userfooter) free(userfooter);
|
|
|
|
+ userheader = userfooter = NULL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
job->job_sheets = attr;
|
|
|
|
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1803,6 +1981,9 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2008-11-12 16:09:54 +00:00
|
|
|
"job-sheets=\"%s,none\", "
|
|
|
|
"job-originating-user-name=\"%s\"",
|
|
|
|
Classification, job->username);
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
2008-11-12 16:09:54 +00:00
|
|
|
+ override = 1;
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
}
|
|
|
|
else if (attr->num_values == 2 &&
|
|
|
|
strcmp(attr->values[0].string.text,
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1821,6 +2002,9 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2008-11-12 16:09:54 +00:00
|
|
|
"job-originating-user-name=\"%s\"",
|
|
|
|
attr->values[0].string.text,
|
|
|
|
attr->values[1].string.text, job->username);
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
2008-11-12 16:09:54 +00:00
|
|
|
+ override = 1;
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
}
|
|
|
|
else if (strcmp(attr->values[0].string.text, Classification) &&
|
|
|
|
strcmp(attr->values[0].string.text, "none") &&
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1841,6 +2025,9 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2008-11-12 16:09:54 +00:00
|
|
|
"job-originating-user-name=\"%s\"",
|
|
|
|
attr->values[0].string.text,
|
|
|
|
attr->values[1].string.text, job->username);
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
2008-11-12 16:09:54 +00:00
|
|
|
+ override = 1;
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(attr->values[0].string.text, Classification) &&
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1881,8 +2068,52 @@ add_job(cupsd_client_t *con, /* I - Cl
|
2008-11-12 16:09:54 +00:00
|
|
|
"job-sheets=\"%s\", "
|
|
|
|
"job-originating-user-name=\"%s\"",
|
|
|
|
Classification, job->username);
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
2008-11-12 16:09:54 +00:00
|
|
|
+ override = 1;
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
2014-11-06 15:09:52 +00:00
|
|
|
}
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (is_lspp_config() && AuditLog != -1)
|
|
|
|
+ {
|
|
|
|
+ audit_message = NULL;
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (userheader || userfooter)
|
|
|
|
+ {
|
|
|
|
+ if (!override)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * The user overrode the banner, so audit it
|
|
|
|
+ */
|
|
|
|
+ cupsdSetStringf(&audit_message, "job=%d user supplied job-sheets=%s,%s"
|
|
|
|
+ " using banners=%s,%s", job->id, userheader,
|
|
|
|
+ userfooter, attr->values[0].string.text,
|
|
|
|
+ (attr->num_values > 1) ? attr->values[1].string.text : "(null)");
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_LABEL_OVERRIDE, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 1);
|
2008-11-12 16:09:54 +00:00
|
|
|
+ }
|
2008-07-18 12:12:59 +00:00
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * The user tried to override the banner, audit the failure
|
|
|
|
+ */
|
|
|
|
+ cupsdSetStringf(&audit_message, "job=%d user supplied job-sheets=%s,%s"
|
|
|
|
+ " ignored banners=%s,%s", job->id, userheader,
|
|
|
|
+ userfooter, attr->values[0].string.text,
|
|
|
|
+ (attr->num_values > 1) ? attr->values[1].string.text : "(null)");
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_LABEL_OVERRIDE, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 0);
|
2008-11-12 16:09:54 +00:00
|
|
|
+ }
|
2008-07-18 12:12:59 +00:00
|
|
|
+ cupsdClearString(&audit_message);
|
2008-11-12 16:09:54 +00:00
|
|
|
+ }
|
2014-11-06 15:09:52 +00:00
|
|
|
+ }
|
2008-11-12 16:09:54 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (userheader)
|
|
|
|
+ free(userheader);
|
|
|
|
+ if (userfooter)
|
|
|
|
+ free(userfooter);
|
|
|
|
+#endif /* WITH_LSPP */
|
2008-11-12 16:09:54 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* See if we need to add the starting sheet...
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -3659,6 +3890,128 @@ check_rss_recipient(
|
2008-07-18 12:12:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+/*
|
|
|
|
+ * 'check_context()' - Check SELinux security context of a user and job
|
|
|
|
+ */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+static int /* O - 1 if OK, 0 if not, -1 on error */
|
|
|
|
+check_context(cupsd_client_t *con, /* I - Client connection */
|
|
|
|
+ cupsd_job_t *job) /* I - Job */
|
|
|
|
+{
|
|
|
|
+ int enforcing; /* is SELinux in enforcing mode */
|
|
|
|
+ char filename[1024]; /* Filename of the spool file */
|
|
|
|
+ security_id_t clisid; /* SELinux SID of the client */
|
|
|
|
+ security_id_t jobsid; /* SELinux SID of the job */
|
|
|
|
+ security_id_t filesid; /* SELinux SID of the spool file */
|
|
|
|
+ struct avc_entry_ref avcref; /* AVC entry cache pointer */
|
|
|
|
+ security_class_t tclass; /* SELinux security class */
|
|
|
|
+ access_vector_t avr; /* SELinux access being queried */
|
|
|
|
+ security_context_t spoolfilecon; /* SELinux context of the spool file */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * Validate the input to be sure there are contexts to work with...
|
|
|
|
+ */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (con->scon == NULL || job->scon == NULL
|
|
|
|
+ || strncmp(con->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) == 0
|
|
|
|
+ || strncmp(job->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) == 0)
|
|
|
|
+ return -1;
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if ((enforcing = security_getenforce()) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Error while determining SELinux enforcement");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return -1;
|
|
|
|
+ }
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_DEBUG,
|
|
|
|
+ "check_context: client context %s job context %s",
|
|
|
|
+ con->scon, job->scon);
|
2006-07-21 12:00:05 +00:00
|
|
|
+
|
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * Initialize the avc engine...
|
|
|
|
+ */
|
2006-10-03 10:57:31 +00:00
|
|
|
+
|
2014-11-06 13:43:32 +00:00
|
|
|
+ static int avc_initialized = 0;
|
2010-12-13 14:07:55 +00:00
|
|
|
+ if (! avc_initialized++)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
2010-12-13 14:07:55 +00:00
|
|
|
+ if (avc_init("cupsd", NULL, NULL, NULL, NULL) < 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR, "check_context: unable avc_init");
|
2010-12-13 14:07:55 +00:00
|
|
|
+ return -1;
|
|
|
|
+ }
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
|
|
|
+ if (avc_context_to_sid(con->scon, &clisid) != 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "check_context: unable to convert %s to SELinux sid",
|
|
|
|
+ con->scon);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return -1;
|
|
|
|
+ }
|
2011-03-25 15:56:11 +00:00
|
|
|
+ if (avc_context_to_sid(job->scon, &jobsid) != 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "check_context: unable to convert %s to SELinux sid",
|
|
|
|
+ job->scon);
|
2011-03-25 15:56:11 +00:00
|
|
|
+ return -1;
|
|
|
|
+ }
|
2008-07-18 12:12:59 +00:00
|
|
|
+ avc_entry_ref_init(&avcref);
|
|
|
|
+ tclass = SECCLASS_FILE;
|
|
|
|
+ avr = FILE__READ;
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ /*
|
|
|
|
+ * Perform the check with the client as the subject, first with the job as the object
|
|
|
|
+ * if that fails then with the spool file as the object...
|
|
|
|
+ */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (avc_has_perm_noaudit(clisid, jobsid, tclass, avr, &avcref, NULL) != 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_INFO,
|
|
|
|
+ "check_context: SELinux denied access "
|
|
|
|
+ "based on the client context");
|
2006-08-02 09:37:31 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ snprintf(filename, sizeof(filename), "%s/c%05d", RequestRoot, job->id);
|
|
|
|
+ if (getfilecon(filename, &spoolfilecon) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "check_context: Unable to get spoolfile context");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if (avc_context_to_sid(spoolfilecon, &filesid) != 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "check_context: Unable to determine the "
|
|
|
|
+ "SELinux sid for the spool file");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ freecon(spoolfilecon);
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ freecon(spoolfilecon);
|
|
|
|
+ if (avc_has_perm_noaudit(clisid, filesid, tclass, avr, &avcref, NULL) != 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_INFO,
|
|
|
|
+ "check_context: SELinux denied access to the spool file");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_INFO,
|
|
|
|
+ "check_context: SELinux allowed access to the spool file");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ if (enforcing == 0)
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_INFO,
|
|
|
|
+ "check_context: allowing operation due to permissive mode");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ else
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_INFO,
|
|
|
|
+ "check_context: SELinux allowed access based on the "
|
|
|
|
+ "client context");
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* 'check_quotas()' - Check quotas for a printer and user.
|
|
|
|
*/
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -4115,6 +4468,15 @@ copy_banner(cupsd_client_t *con, /* I -
|
2008-07-18 12:12:59 +00:00
|
|
|
char attrname[255], /* Name of attribute */
|
|
|
|
*s; /* Pointer into name */
|
|
|
|
ipp_attribute_t *attr; /* Attribute */
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ const char *mls_label; /* SL of print job */
|
|
|
|
+ char *jobrange; /* SELinux sensitivity range */
|
|
|
|
+ char *jobclearance; /* SELinux low end clearance */
|
|
|
|
+ context_t jobcon; /* SELinux context of the job */
|
|
|
|
+ context_t tmpcon; /* Temp context to set the level */
|
|
|
|
+ security_context_t spoolcon; /* Context of the file in the spool */
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
|
2008-07-28 15:40:15 +00:00
|
|
|
cupsdLogMessage(CUPSD_LOG_DEBUG2,
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -4150,6 +4512,85 @@ copy_banner(cupsd_client_t *con, /* I -
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
fchmod(cupsFileNumber(out), 0640);
|
|
|
|
fchown(cupsFileNumber(out), RunUser, Group);
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (job->scon != NULL &&
|
|
|
|
+ strncmp(job->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
|
|
|
|
+ {
|
|
|
|
+ if (getfilecon(filename, &spoolcon) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to get the context of the banner file %s - %s",
|
|
|
|
+ filename, strerror(errno));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ job->num_files --;
|
|
|
|
+ return (0);
|
|
|
|
+ }
|
|
|
|
+ tmpcon = context_new(spoolcon);
|
|
|
|
+ jobcon = context_new(job->scon);
|
|
|
|
+ freecon(spoolcon);
|
|
|
|
+ if (!tmpcon || !jobcon)
|
|
|
|
+ {
|
|
|
|
+ if (tmpcon)
|
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ if (jobcon)
|
|
|
|
+ context_free(jobcon);
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "copy_banner: Unable to get the SELinux contexts");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ job->num_files --;
|
|
|
|
+ return (0);
|
|
|
|
+ }
|
2014-11-06 13:43:32 +00:00
|
|
|
+ jobrange = (char *) context_range_get(jobcon);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (jobrange)
|
|
|
|
+ {
|
|
|
|
+ jobrange = strdup(jobrange);
|
|
|
|
+ if ((jobclearance = strtok(jobrange, "-")) != NULL)
|
|
|
|
+ {
|
|
|
|
+ if (context_range_set(tmpcon, jobclearance) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "copy_banner: Unable to set the "
|
|
|
|
+ "level of the context for file %s - %s",
|
|
|
|
+ filename, strerror(errno));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ free(jobrange);
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ job->num_files --;
|
|
|
|
+ return (0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (context_range_set(tmpcon, (context_range_get(jobcon))) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "copy_banner: Unable to set the "
|
|
|
|
+ "level of the context for file %s - %s",
|
|
|
|
+ filename, strerror(errno));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ free(jobrange);
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ job->num_files --;
|
|
|
|
+ return (0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ free(jobrange);
|
|
|
|
+ }
|
|
|
|
+ if (setfilecon(filename, context_str(tmpcon)) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "copy_banner: Unable to set the "
|
|
|
|
+ "context of the banner file %s - %s",
|
|
|
|
+ filename, strerror(errno));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(jobcon);
|
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ job->num_files --;
|
|
|
|
+ return (0);
|
|
|
|
+ }
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_DEBUG2, "copy_banner: %s set to %s",
|
|
|
|
+ filename, context_str(tmpcon));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(jobcon);
|
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try the localized banner file under the subdirectory...
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -4244,6 +4685,24 @@ copy_banner(cupsd_client_t *con, /* I -
|
2008-07-18 12:12:59 +00:00
|
|
|
else
|
|
|
|
s = attrname;
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (strcmp(s, "mls-label") == 0)
|
|
|
|
+ {
|
|
|
|
+ if (job->scon != NULL && strncmp(job->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
|
|
|
|
+ {
|
|
|
|
+ jobcon = context_new(job->scon);
|
2011-05-26 14:27:09 +00:00
|
|
|
+ if (_cups_strcasecmp(name, MLS_CONFIG) == 0)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ mls_label = context_range_get(jobcon);
|
2011-05-26 14:27:09 +00:00
|
|
|
+ else if (_cups_strcasecmp(name, TE_CONFIG) == 0)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ mls_label = context_type_get(jobcon);
|
|
|
|
+ else // default to using the whole context string
|
|
|
|
+ mls_label = context_str(jobcon);
|
|
|
|
+ cupsFilePuts(out, mls_label);
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
if (!strcmp(s, "printer-name"))
|
|
|
|
{
|
|
|
|
cupsFilePuts(out, job->dest);
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -6429,6 +6888,22 @@ get_job_attrs(cupsd_client_t *con, /* I
|
2011-05-24 12:27:29 +00:00
|
|
|
|
|
|
|
exclude = cupsdGetPrivateAttrs(policy, con, printer, job->username);
|
2008-07-18 12:12:59 +00:00
|
|
|
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ /*
|
|
|
|
+ * Check SELinux...
|
|
|
|
+ */
|
|
|
|
+ if (is_lspp_config() && check_context(con, job) != 1)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * Unfortunately we have to lie to the user...
|
|
|
|
+ */
|
|
|
|
+ send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2006-11-22 11:59:57 +00:00
|
|
|
+
|
2007-03-29 10:30:29 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* Copy attributes...
|
|
|
|
*/
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -6826,6 +7301,11 @@ get_jobs(cupsd_client_t *con, /* I - C
|
2011-05-24 12:27:29 +00:00
|
|
|
if (username[0] && _cups_strcasecmp(username, job->username))
|
|
|
|
continue;
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
2011-05-24 12:27:29 +00:00
|
|
|
+ if (is_lspp_config() && check_context(con, job) != 1)
|
|
|
|
+ continue;
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2011-05-24 12:27:29 +00:00
|
|
|
if (count > 0)
|
|
|
|
ippAddSeparator(con->response);
|
2008-07-18 12:12:59 +00:00
|
|
|
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -11457,6 +11937,11 @@ validate_user(cupsd_job_t *job, /* I
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
strlcpy(username, get_username(con), userlen);
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (is_lspp_config() && check_context(con, job) != 1)
|
|
|
|
+ return 0;
|
|
|
|
+#endif /* WITH_LSPP */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* Check the username against the owner...
|
|
|
|
*/
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/job.c.lspp cups-2.2.2/scheduler/job.c
|
|
|
|
--- cups-2.2.2/scheduler/job.c.lspp 2017-01-19 11:34:39.202988908 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/job.c 2017-01-19 11:51:43.774763010 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -11,6 +11,9 @@
|
2017-01-19 11:02:44 +00:00
|
|
|
* missing or damaged, see the license at "http://www.cups.org/".
|
2008-07-18 12:12:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
|
|
|
|
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* Include necessary headers...
|
|
|
|
*/
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -26,6 +29,14 @@
|
2011-05-24 12:27:29 +00:00
|
|
|
# endif /* HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H */
|
|
|
|
#endif /* __APPLE__ */
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+#include <libaudit.h>
|
|
|
|
+#include <selinux/selinux.h>
|
|
|
|
+#include <selinux/context.h>
|
|
|
|
+#include <selinux/avc.h>
|
|
|
|
+#include <selinux/flask.h>
|
|
|
|
+#include <selinux/av_permissions.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
/*
|
2009-03-05 13:31:30 +00:00
|
|
|
* Design Notes for Job Management
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -546,6 +557,14 @@ cupsdContinueJob(cupsd_job_t *job) /* I
|
2011-05-24 12:27:29 +00:00
|
|
|
/* PRINTER_STATE_REASONS env var */
|
2009-03-05 13:31:30 +00:00
|
|
|
rip_max_cache[255];
|
|
|
|
/* RIP_MAX_CACHE env variable */
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ char *audit_message = NULL; /* Audit message string */
|
|
|
|
+ context_t jobcon; /* SELinux context of the job */
|
|
|
|
+ char *label_template = NULL; /* SL to put in classification
|
|
|
|
+ env var */
|
|
|
|
+ const char *mls_label = NULL; /* SL to put in classification
|
|
|
|
+ env var */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
|
|
|
cupsdLogMessage(CUPSD_LOG_DEBUG2,
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -1082,6 +1101,67 @@ cupsdContinueJob(cupsd_job_t *job) /* I
|
2013-04-19 10:52:50 +00:00
|
|
|
if (final_content_type[0])
|
|
|
|
envp[envc ++] = final_content_type;
|
2009-03-05 13:31:30 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (is_lspp_config())
|
|
|
|
+ {
|
|
|
|
+ if (!job->scon || strncmp(job->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) == 0)
|
|
|
|
+ {
|
|
|
|
+ if (AuditLog != -1)
|
|
|
|
+ {
|
|
|
|
+ audit_message = NULL;
|
|
|
|
+ cupsdSetStringf(&audit_message, "job=%d auid=%u acct=%s printer=%s title=%s",
|
|
|
|
+ job->id, job->auid, job->username, job->printer->name, title);
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_USER_UNLABELED_EXPORT, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 1);
|
|
|
|
+ cupsdClearString(&audit_message);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ jobcon = context_new(job->scon);
|
|
|
|
+
|
|
|
|
+ if ((attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME)) == NULL)
|
|
|
|
+ label_template = strdup(Classification);
|
|
|
|
+ else if (attr->num_values > 1 &&
|
|
|
|
+ strcmp(attr->values[1].string.text, "none") != 0)
|
|
|
|
+ label_template = strdup(attr->values[1].string.text);
|
|
|
|
+ else
|
|
|
|
+ label_template = strdup(attr->values[0].string.text);
|
|
|
|
+
|
2011-05-26 14:27:09 +00:00
|
|
|
+ if (_cups_strcasecmp(label_template, MLS_CONFIG) == 0)
|
2009-03-05 13:31:30 +00:00
|
|
|
+ mls_label = context_range_get(jobcon);
|
2011-05-26 14:27:09 +00:00
|
|
|
+ else if (_cups_strcasecmp(label_template, TE_CONFIG) == 0)
|
2009-03-05 13:31:30 +00:00
|
|
|
+ mls_label = context_type_get(jobcon);
|
2011-05-26 14:27:09 +00:00
|
|
|
+ else if (_cups_strcasecmp(label_template, SELINUX_CONFIG) == 0)
|
2009-03-05 13:31:30 +00:00
|
|
|
+ mls_label = context_str(jobcon);
|
|
|
|
+ else
|
|
|
|
+ mls_label = label_template;
|
|
|
|
+
|
|
|
|
+ if (mls_label && (PerPageLabels || banner_page))
|
|
|
|
+ {
|
|
|
|
+ snprintf(classification, sizeof(classification), "CLASSIFICATION=LSPP:%s", mls_label);
|
|
|
|
+ envp[envc ++] = classification;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ((AuditLog != -1) && !banner_page)
|
|
|
|
+ {
|
|
|
|
+ audit_message = NULL;
|
|
|
|
+ cupsdSetStringf(&audit_message, "job=%d auid=%u acct=%s printer=%s title=%s"
|
|
|
|
+ " obj=%s label=%s", job->id, job->auid, job->username,
|
|
|
|
+ job->printer->name, title, job->scon, mls_label?mls_label:"none");
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_USER_LABELED_EXPORT, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 1);
|
|
|
|
+ cupsdClearString(&audit_message);
|
|
|
|
+ }
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ free(label_template);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ /*
|
|
|
|
+ * Fall through to the non-LSPP behavior
|
|
|
|
+ */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
if (Classification && !banner_page)
|
|
|
|
{
|
|
|
|
if ((attr = ippFindAttribute(job->attrs, "job-sheets",
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -1905,6 +1985,22 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
|
2012-08-08 11:28:28 +00:00
|
|
|
ippSetString(job->attrs, &job->reasons, 0, "none");
|
2008-07-18 12:12:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if ((attr = ippFindAttribute(job->attrs, "security-context", IPP_TAG_NAME)) != NULL)
|
|
|
|
+ cupsdSetString(&job->scon, attr->values[0].string.text);
|
|
|
|
+ else if (is_lspp_config())
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * There was no security context so delete the job
|
|
|
|
+ */
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Missing or bad security-context attribute "
|
|
|
|
+ "in control file \"%s\"!",
|
|
|
|
+ jobfile);
|
2009-01-28 17:17:46 +00:00
|
|
|
+ goto error;
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2015-06-29 11:47:50 +00:00
|
|
|
job->impressions = ippFindAttribute(job->attrs, "job-impressions-completed", IPP_TAG_INTEGER);
|
|
|
|
job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed", IPP_TAG_INTEGER);
|
|
|
|
job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -2318,6 +2414,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
|
2012-08-08 11:28:28 +00:00
|
|
|
{
|
|
|
|
char filename[1024]; /* Job control filename */
|
2008-07-18 12:12:59 +00:00
|
|
|
cups_file_t *fp; /* Job file */
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ security_context_t spoolcon; /* context of the job control file */
|
|
|
|
+ context_t jobcon; /* contex_t container for job->scon */
|
|
|
|
+ context_t tmpcon; /* Temp context to swap the level */
|
2009-03-05 13:31:30 +00:00
|
|
|
+ char *jobclearance; /* SELinux low end clearance */
|
|
|
|
+ const char *jobrange; /* SELinux sensitivity range */
|
|
|
|
+ char *jobrange_copy; /* SELinux sensitivity range */
|
2008-07-18 12:12:59 +00:00
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
|
|
|
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p",
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -2340,6 +2444,78 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
|
2012-08-08 11:28:28 +00:00
|
|
|
|
2008-07-18 12:12:59 +00:00
|
|
|
fchown(cupsFileNumber(fp), RunUser, Group);
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (job->scon && strncmp(job->scon, UNKNOWN_SL, strlen(UNKNOWN_SL)) != 0)
|
|
|
|
+ {
|
|
|
|
+ if (getfilecon(filename, &spoolcon) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to get context of job control file \"%s\" - %s.",
|
|
|
|
+ filename, strerror(errno));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ jobcon = context_new(job->scon);
|
|
|
|
+ tmpcon = context_new(spoolcon);
|
|
|
|
+ freecon(spoolcon);
|
|
|
|
+ if (!jobcon || !tmpcon)
|
|
|
|
+ {
|
|
|
|
+ if (jobcon)
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ if (tmpcon)
|
|
|
|
+ context_free(tmpcon);
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to get SELinux contexts");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ jobrange = context_range_get(jobcon);
|
|
|
|
+ if (jobrange)
|
|
|
|
+ {
|
2009-03-05 13:31:30 +00:00
|
|
|
+ jobrange_copy = strdup(jobrange);
|
|
|
|
+ if ((jobclearance = strtok(jobrange_copy, "-")) != NULL)
|
2008-07-18 12:12:59 +00:00
|
|
|
+ {
|
|
|
|
+ if (context_range_set(tmpcon, jobclearance) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to set the range for "
|
|
|
|
+ "job control file \"%s\" - %s.",
|
|
|
|
+ filename, strerror(errno));
|
2009-03-05 13:31:30 +00:00
|
|
|
+ free(jobrange_copy);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (context_range_set(tmpcon, (context_range_get(jobcon))) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to set the range for "
|
|
|
|
+ "job control file \"%s\" - %s.",
|
|
|
|
+ filename, strerror(errno));
|
2009-03-05 13:31:30 +00:00
|
|
|
+ free(jobrange_copy);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
2009-03-05 13:31:30 +00:00
|
|
|
+ free(jobrange_copy);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ }
|
|
|
|
+ if (setfilecon(filename, context_str(tmpcon)) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to set context of job control file \"%s\" - %s.",
|
|
|
|
+ filename, strerror(errno));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_DEBUG2, "New spool file context=%s",
|
2015-06-29 11:47:50 +00:00
|
|
|
+ context_str(tmpcon));
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(tmpcon);
|
|
|
|
+ context_free(jobcon);
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
job->attrs->state = IPP_IDLE;
|
|
|
|
|
|
|
|
if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL,
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -3926,6 +4102,19 @@ get_options(cupsd_job_t *job, /* I - Jo
|
2009-03-05 13:31:30 +00:00
|
|
|
banner_page)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ /*
|
|
|
|
+ * In LSPP mode refuse to honor the page-label
|
|
|
|
+ */
|
|
|
|
+ if (is_lspp_config() &&
|
|
|
|
+ !strcmp(attr->name, "page-label"))
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_DEBUG,
|
|
|
|
+ "Ignoring page-label option due to LSPP mode");
|
2009-03-05 13:31:30 +00:00
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Otherwise add them to the list...
|
|
|
|
*/
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -4687,6 +4876,18 @@ start_job(cupsd_job_t *job, /* I -
|
2009-03-05 13:31:30 +00:00
|
|
|
cupsd_printer_t *printer) /* I - Printer to print job */
|
|
|
|
{
|
2013-04-19 10:52:50 +00:00
|
|
|
const char *filename; /* Support filename */
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ char *audit_message = NULL; /* Audit message string */
|
|
|
|
+ char *printerfile = NULL; /* Device file pointed to by the printer */
|
|
|
|
+ security_id_t clisid; /* SELinux SID for the client */
|
|
|
|
+ security_id_t psid; /* SELinux SID for the printer */
|
|
|
|
+ context_t printercon; /* Printer's context string */
|
|
|
|
+ struct stat printerstat; /* Printer's stat buffer */
|
|
|
|
+ security_context_t devcon; /* Printer's SELinux context */
|
|
|
|
+ struct avc_entry_ref avcref; /* Pointer to the access vector cache */
|
|
|
|
+ security_class_t tclass; /* Object class for the SELinux check */
|
|
|
|
+ access_vector_t avr; /* Access method being requested */
|
|
|
|
+#endif /* WITH_LSPP */
|
2014-09-12 16:19:24 +00:00
|
|
|
ipp_attribute_t *cancel_after = ippFindAttribute(job->attrs,
|
|
|
|
"job-cancel-after",
|
|
|
|
IPP_TAG_INTEGER);
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -4863,6 +5064,113 @@ start_job(cupsd_job_t *job, /* I -
|
2009-09-14 17:03:49 +00:00
|
|
|
fcntl(job->side_pipes[1], F_SETFD,
|
|
|
|
fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC);
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (is_lspp_config())
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * Perform an access check before printing, but only if the printer starts with /dev/
|
|
|
|
+ */
|
|
|
|
+ printerfile = strstr(printer->device_uri, "/dev/");
|
|
|
|
+ if (printerfile == NULL && (strncmp(printer->device_uri, "file:/", 6) == 0))
|
2009-11-23 13:08:59 +00:00
|
|
|
+ printerfile = printer->device_uri + strlen("file:");
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (printerfile != NULL)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_DEBUG,
|
|
|
|
+ "Attempting to check access on printer device %s",
|
|
|
|
+ printerfile);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (lstat(printerfile, &printerstat) < 0)
|
|
|
|
+ {
|
|
|
|
+ if (errno != ENOENT)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to stat the printer");
|
2009-03-05 13:31:30 +00:00
|
|
|
+ cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT, NULL);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ * The printer does not exist, so for now assume it's a FileDevice
|
|
|
|
+ */
|
|
|
|
+ tclass = SECCLASS_FILE;
|
|
|
|
+ avr = FILE__WRITE;
|
|
|
|
+ }
|
|
|
|
+ else if (S_ISCHR(printerstat.st_mode))
|
|
|
|
+ {
|
|
|
|
+ tclass = SECCLASS_CHR_FILE;
|
|
|
|
+ avr = CHR_FILE__WRITE;
|
|
|
|
+ }
|
|
|
|
+ else if (S_ISREG(printerstat.st_mode))
|
|
|
|
+ {
|
|
|
|
+ tclass = SECCLASS_FILE;
|
|
|
|
+ avr = FILE__WRITE;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "StartJob: Printer is not a character device or "
|
|
|
|
+ "regular file");
|
2009-03-05 13:31:30 +00:00
|
|
|
+ cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT, NULL);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return ;
|
|
|
|
+ }
|
2014-11-06 13:43:32 +00:00
|
|
|
+ static int avc_initialized = 0;
|
2010-12-13 14:07:55 +00:00
|
|
|
+ if (!avc_initialized++)
|
|
|
|
+ avc_init("cupsd_dequeue_", NULL, NULL, NULL, NULL);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ avc_entry_ref_init(&avcref);
|
|
|
|
+ if (avc_context_to_sid(job->scon, &clisid) != 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to determine the SELinux sid for the job");
|
2009-03-05 13:31:30 +00:00
|
|
|
+ cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT, NULL);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ if (getfilecon(printerfile, &devcon) == -1)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to get the SELinux context of %s",
|
|
|
|
+ printerfile);
|
2009-03-05 13:31:30 +00:00
|
|
|
+ cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT, NULL);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ printercon = context_new(devcon);
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_DEBUG,
|
|
|
|
+ "Printer context %s client context %s",
|
|
|
|
+ context_str(printercon), job->scon);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ context_free(printercon);
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (avc_context_to_sid(devcon, &psid) != 0)
|
|
|
|
+ {
|
2014-11-06 15:09:52 +00:00
|
|
|
+ cupsdLogJob(job, CUPSD_LOG_ERROR,
|
|
|
|
+ "Unable to determine the SELinux sid for the printer");
|
2008-07-18 12:12:59 +00:00
|
|
|
+ freecon(devcon);
|
2009-03-05 13:31:30 +00:00
|
|
|
+ cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT, NULL);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ freecon(devcon);
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (avc_has_perm(clisid, psid, tclass, avr, &avcref, NULL) != 0)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
|
|
+ * The access check failed, so cancel the job and send an audit message
|
|
|
|
+ */
|
|
|
|
+ if (AuditLog != -1)
|
|
|
|
+ {
|
|
|
|
+ audit_message = NULL;
|
|
|
|
+ cupsdSetStringf(&audit_message, "job=%d auid=%u acct=%s obj=%s canceled"
|
|
|
|
+ " unable to access printer=%s", job->id,
|
|
|
|
+ job->auid, (job->username)?job->username:"?", job->scon, printer->name);
|
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_USER_LABELED_EXPORT, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 0);
|
|
|
|
+ cupsdClearString(&audit_message);
|
|
|
|
+ }
|
2007-03-29 10:30:29 +00:00
|
|
|
+
|
2009-03-05 13:31:30 +00:00
|
|
|
+ cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT, NULL);
|
2007-03-29 10:30:29 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-29 10:30:29 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
2009-03-05 13:31:30 +00:00
|
|
|
* Now start the first file in the job...
|
2008-07-18 12:12:59 +00:00
|
|
|
*/
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/job.h.lspp cups-2.2.2/scheduler/job.h
|
|
|
|
--- cups-2.2.2/scheduler/job.h.lspp 2017-01-17 20:27:22.000000000 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/job.h 2017-01-19 11:52:53.997134426 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -11,6 +11,13 @@
|
2017-01-19 11:02:44 +00:00
|
|
|
* missing or damaged, see the license at "http://www.cups.org/".
|
2008-07-18 12:12:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
+/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */
|
|
|
|
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
|
2006-11-22 11:59:57 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+#include <selinux/selinux.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-02 14:13:58 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
2009-03-05 13:31:30 +00:00
|
|
|
* Constants...
|
2008-07-18 12:12:59 +00:00
|
|
|
*/
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -88,6 +95,10 @@ struct cupsd_job_s /**** Job request *
|
2011-05-24 12:27:29 +00:00
|
|
|
int progress; /* Printing progress */
|
2012-08-08 11:28:28 +00:00
|
|
|
int num_keywords; /* Number of PPD keywords */
|
|
|
|
cups_option_t *keywords; /* PPD keywords */
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ security_context_t scon; /* Security context of job */
|
|
|
|
+ uid_t auid; /* Audit loginuid for this job */
|
|
|
|
+#endif /* WITH_LSPP */
|
2009-06-17 11:30:03 +00:00
|
|
|
};
|
2008-07-18 12:12:59 +00:00
|
|
|
|
2009-06-17 11:30:03 +00:00
|
|
|
typedef struct cupsd_joblog_s /**** Job log message ****/
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/main.c.lspp cups-2.2.2/scheduler/main.c
|
|
|
|
--- cups-2.2.2/scheduler/main.c.lspp 2017-01-19 11:34:39.225988705 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/main.c 2017-01-19 11:34:39.286988168 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -56,6 +56,9 @@
|
2013-03-18 18:26:09 +00:00
|
|
|
# include <sys/param.h>
|
|
|
|
#endif /* HAVE_SYS_PARAM_H */
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+# include <libaudit.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local functions...
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -122,6 +125,9 @@ main(int argc, /* I - Number of comm
|
2010-12-24 13:14:06 +00:00
|
|
|
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
|
|
|
|
struct sigaction action; /* Actions for POSIX signals */
|
|
|
|
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
|
2008-07-18 12:12:59 +00:00
|
|
|
+#if WITH_LSPP
|
|
|
|
+ auditfail_t failmode; /* Action for audit_open failure */
|
|
|
|
+#endif /* WITH_LSPP */
|
2013-04-19 10:52:50 +00:00
|
|
|
#ifdef __APPLE__
|
2014-11-15 14:42:30 +00:00
|
|
|
int use_sysman = 1; /* Use system management functions? */
|
|
|
|
#else
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -508,6 +514,25 @@ main(int argc, /* I - Number of comm
|
2014-11-15 14:42:30 +00:00
|
|
|
exit(errno);
|
2008-07-18 12:12:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if ((AuditLog = audit_open()) < 0 )
|
|
|
|
+ {
|
|
|
|
+ if (get_auditfail_action(&failmode) == 0)
|
|
|
|
+ {
|
|
|
|
+ if (failmode == FAIL_LOG)
|
|
|
|
+ {
|
|
|
|
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to connect to audit subsystem.");
|
|
|
|
+ AuditLog = -1;
|
|
|
|
+ }
|
|
|
|
+ else if (failmode == FAIL_TERMINATE)
|
|
|
|
+ {
|
|
|
|
+ fprintf(stderr, "cupsd: unable to start auditing, terminating");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* Set the timezone info...
|
|
|
|
*/
|
2017-01-19 11:02:44 +00:00
|
|
|
@@ -1201,6 +1226,11 @@ main(int argc, /* I - Number of comm
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
cupsdStopSelect();
|
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (AuditLog != -1)
|
|
|
|
+ audit_close(AuditLog);
|
|
|
|
+#endif /* WITH_LSPP */
|
2007-03-29 10:30:29 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
return (!stop_scheduler);
|
|
|
|
}
|
|
|
|
|
2017-01-19 11:02:44 +00:00
|
|
|
diff -up cups-2.2.2/scheduler/printers.c.lspp cups-2.2.2/scheduler/printers.c
|
|
|
|
--- cups-2.2.2/scheduler/printers.c.lspp 2017-01-19 11:34:39.177989128 +0100
|
|
|
|
+++ cups-2.2.2/scheduler/printers.c 2017-01-19 11:53:39.614723905 +0100
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -11,6 +11,8 @@
|
2017-01-19 11:02:44 +00:00
|
|
|
* missing or damaged, see the license at "http://www.cups.org/".
|
2008-07-18 12:12:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
+/* (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P. */
|
2007-03-29 10:30:29 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
/*
|
|
|
|
* Include necessary headers...
|
|
|
|
*/
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -35,6 +37,10 @@
|
2012-08-08 11:28:28 +00:00
|
|
|
# include <asl.h>
|
|
|
|
#endif /* __APPLE__ */
|
2008-07-18 12:12:59 +00:00
|
|
|
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+# include <libaudit.h>
|
|
|
|
+# include <selinux/context.h>
|
|
|
|
+#endif /* WITH_LSPP */
|
2012-08-08 11:28:28 +00:00
|
|
|
|
2011-05-24 12:27:29 +00:00
|
|
|
/*
|
|
|
|
* Local functions...
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -2191,6 +2197,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
|
2013-03-18 18:26:09 +00:00
|
|
|
ipp_attribute_t *attr; /* Attribute data */
|
|
|
|
char *name, /* Current user/group name */
|
|
|
|
*filter; /* Current filter */
|
2008-07-18 12:12:59 +00:00
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ char *audit_message; /* Audit message string */
|
|
|
|
+ char *printerfile; /* Path to a local printer dev */
|
|
|
|
+ char *rangestr; /* Printer's range if its available */
|
|
|
|
+ security_context_t devcon; /* Printer SELinux context */
|
|
|
|
+ context_t printercon; /* context_t for the printer */
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -2318,6 +2331,45 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
|
2008-07-18 12:12:59 +00:00
|
|
|
attr->values[1].string.text = _cupsStrAlloc(Classification ?
|
|
|
|
Classification : p->job_sheets[1]);
|
|
|
|
}
|
|
|
|
+#ifdef WITH_LSPP
|
|
|
|
+ if (AuditLog != -1)
|
|
|
|
+ {
|
|
|
|
+ audit_message = NULL;
|
|
|
|
+ rangestr = NULL;
|
|
|
|
+ printercon = 0;
|
|
|
|
+ printerfile = strstr(p->device_uri, "/dev/");
|
|
|
|
+ if (printerfile == NULL && (strncmp(p->device_uri, "file:/", 6) == 0))
|
2009-11-23 13:08:59 +00:00
|
|
|
+ printerfile = p->device_uri + strlen("file:");
|
2007-07-18 11:55:01 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (printerfile != NULL)
|
|
|
|
+ {
|
|
|
|
+ if (getfilecon(printerfile, &devcon) == -1)
|
2009-11-11 09:51:45 +00:00
|
|
|
+ {
|
|
|
|
+ if(is_selinux_enabled())
|
2011-03-10 13:42:03 +00:00
|
|
|
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSetPrinterAttrs: Unable to get printer context");
|
2009-11-11 09:51:45 +00:00
|
|
|
+ }
|
2008-07-18 12:12:59 +00:00
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ printercon = context_new(devcon);
|
|
|
|
+ freecon(devcon);
|
|
|
|
+ }
|
|
|
|
+ }
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ if (printercon && context_range_get(printercon))
|
|
|
|
+ rangestr = strdup(context_range_get(printercon));
|
|
|
|
+ else
|
|
|
|
+ rangestr = strdup("unknown");
|
2008-05-28 09:04:18 +00:00
|
|
|
+
|
2008-07-18 12:12:59 +00:00
|
|
|
+ cupsdSetStringf(&audit_message, "printer=%s uri=%s banners=%s,%s range=%s",
|
2008-11-12 16:09:54 +00:00
|
|
|
+ p->name, p->sanitized_device_uri, p->job_sheets[0], p->job_sheets[1], rangestr);
|
2008-07-18 12:12:59 +00:00
|
|
|
+ audit_log_user_message(AuditLog, AUDIT_LABEL_LEVEL_CHANGE, audit_message,
|
|
|
|
+ ServerName, NULL, NULL, 1);
|
|
|
|
+ if (printercon)
|
|
|
|
+ context_free(printercon);
|
|
|
|
+ free(rangestr);
|
|
|
|
+ cupsdClearString(&audit_message);
|
|
|
|
+ }
|
|
|
|
+#endif /* WITH_LSPP */
|
|
|
|
}
|
|
|
|
|
|
|
|
p->raw = 0;
|