cups-2.2.7:Ver.Bump

This commit is contained in:
Rmys
2018-05-23 23:59:19 +03:00
parent 03d360893b
commit 90b3f88a18
7 changed files with 401 additions and 36 deletions
@@ -0,0 +1,59 @@
From 4feb1fe2e5bb9f418f51f5f517f70b451159baa2 Mon Sep 17 00:00:00 2001
From: Michael R Sweet <michael.r.sweet@gmail.com>
Date: Mon, 16 Apr 2018 17:16:31 -0400
Subject: [PATCH] - Added a workaround for certain web browsers that do not
support multiple authentication schemes in a single response header (Issue
#5289)
---
scheduler/client.c | 22 +++++++++++++++++-----
scheduler/client.h | 8 +++++---
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/scheduler/client.c b/scheduler/client.c
index f388499dc..95c34877d 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -813,6 +814,18 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
if (status == HTTP_STATUS_OK)
{
+ /*
+ * Record whether the client is a web browser. "Mozilla" was the original
+ * and it seems that every web browser in existence now uses that as the
+ * prefix with additional information identifying *which* browser.
+ *
+ * Chrome (at least) has problems with multiple WWW-Authenticate values in
+ * a single header, so we only report Basic or Negotiate to web browsers and
+ * leave the multiple choices to the native CUPS client...
+ */
+
+ con->is_browser = !strncmp(httpGetField(con->http, HTTP_FIELD_USER_AGENT), "Mozilla/", 8);
+
if (httpGetField(con->http, HTTP_FIELD_ACCEPT_LANGUAGE)[0])
{
/*
@@ -2103,8 +2116,7 @@ cupsdSendHeader(
strlcpy(auth_str, "Negotiate", sizeof(auth_str));
}
- if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE &&
- !_cups_strcasecmp(httpGetHostname(con->http, NULL, 0), "localhost"))
+ if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE && !con->is_browser && !_cups_strcasecmp(httpGetHostname(con->http, NULL, 0), "localhost"))
{
/*
* Add a "trc" (try root certification) parameter for local non-Kerberos
diff --git a/scheduler/client.h b/scheduler/client.h
index aaca8279a..fc7af5400 100644
--- a/scheduler/client.h
+++ b/scheduler/client.h
@@ -26,6 +27,7 @@ struct cupsd_client_s
struct timeval start; /* Request start time */
http_state_t operation; /* Request operation */
off_t bytes; /* Bytes transferred for this request */
+ int is_browser; /* Is the client a web browser? */
int type; /* AuthType for username */
char username[HTTP_MAX_VALUE],
/* Username from Authorization: line */
--
2.17.0
@@ -0,0 +1,48 @@
diff -up cups-2.0.2/scheduler/main.c.ustTJg cups-2.0.2/scheduler/main.c
--- cups-2.0.2/scheduler/main.c.ustTJg 2015-02-10 13:40:24.121547526 +0100
+++ cups-2.0.2/scheduler/main.c 2015-02-10 13:40:24.295545063 +0100
@@ -690,8 +690,15 @@ main(int argc, /* I - Number of comm
#if defined(HAVE_ONDEMAND)
if (OnDemand)
+ {
cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started on demand.");
- else
+# ifdef HAVE_SYSTEMD
+ sd_notifyf(0, "READY=1\n"
+ "STATUS=Scheduler is running...\n"
+ "MAINPID=%lu",
+ (unsigned long) getpid());
+# endif /* HAVE_SYSTEMD */
+ } else
#endif /* HAVE_ONDEMAND */
if (fg)
cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started in foreground.");
diff -up cups-2.0.2/scheduler/org.cups.cupsd.path.in.ustTJg cups-2.0.2/scheduler/org.cups.cupsd.path.in
--- cups-2.0.2/scheduler/org.cups.cupsd.path.in.ustTJg 2014-03-21 15:50:24.000000000 +0100
+++ cups-2.0.2/scheduler/org.cups.cupsd.path.in 2015-02-10 13:40:24.295545063 +0100
@@ -2,7 +2,7 @@
Description=CUPS Scheduler
[Path]
-PathExists=@CUPS_CACHEDIR@/org.cups.cupsd
+PathExistsGlob=@CUPS_REQUESTS@/d*
[Install]
WantedBy=multi-user.target
diff -up cups-2.0.2/scheduler/org.cups.cupsd.service.in.ustTJg cups-2.0.2/scheduler/org.cups.cupsd.service.in
--- cups-2.0.2/scheduler/org.cups.cupsd.service.in.ustTJg 2014-10-21 13:55:01.000000000 +0200
+++ cups-2.0.2/scheduler/org.cups.cupsd.service.in 2015-02-10 13:40:24.296545049 +0100
@@ -1,10 +1,11 @@
[Unit]
Description=CUPS Scheduler
Documentation=man:cupsd(8)
+After=network.target
[Service]
ExecStart=@sbindir@/cupsd -l
-Type=simple
+Type=notify
[Install]
Also=org.cups.cupsd.socket org.cups.cupsd.path
@@ -0,0 +1,42 @@
diff --git a/scheduler/cups-exec.c b/scheduler/cups-exec.c
index aab43a797..46c549075 100644
--- a/scheduler/cups-exec.c
+++ b/scheduler/cups-exec.c
@@ -133,8 +133,13 @@ main(int argc, /* I - Number of command-line args */
if (setgid(gid))
exit(errno + 100);
- if (setgroups(1, &gid))
+#include <pwd.h>
+ struct passwd * pwd = getpwuid(uid);
+ if(initgroups(pwd->pw_name,pwd->pw_gid))
+ {
+ fprintf(stderr, "DEBUG: initgroups failed\n");
exit(errno + 100);
+ }
if (uid && setuid(uid))
exit(errno + 100);
diff --git a/scheduler/util.c b/scheduler/util.c
index 19ebf069b..4638562bd 100644
--- a/scheduler/util.c
+++ b/scheduler/util.c
@@ -300,7 +300,16 @@ cupsdPipeCommand(int *pid, /* O - Process ID or 0 on error */
*/
if (!getuid() && user)
- setuid(user); /* Run as restricted user */
+ {
+#include <pwd.h>
+ struct passwd * pwd = getpwuid(user);
+ if(initgroups(pwd->pw_name,pwd->pw_gid))
+ {
+ fprintf(stderr, "DEBUG: initgroups failed\n");
+ exit(errno + 100);
+ }
+ setuid(user); /* Run as restricted user */
+ }
if ((fd = open("/dev/null", O_RDONLY)) > 0)
{