rpms/cups/devel cups-scm_credentials.patch,1.1,1.2
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Thu Mar 8 12:07:56 UTC 2007
Author: twaugh
Update of /cvs/dist/rpms/cups/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv6487
Modified Files:
cups-scm_credentials.patch
Log Message:
Use select().
cups-scm_credentials.patch:
cups/auth.c | 62 +++++++++++++++++++++++++++++++++
cups/http.c | 57 +++++++++++++++++++++++++++++++
scheduler/auth.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 220 insertions(+)
Index: cups-scm_credentials.patch
===================================================================
RCS file: /cvs/dist/rpms/cups/devel/cups-scm_credentials.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cups-scm_credentials.patch 7 Mar 2007 18:13:53 -0000 1.1
+++ cups-scm_credentials.patch 8 Mar 2007 12:07:54 -0000 1.2
@@ -1,10 +1,22 @@
---- cups-1.2.8/cups/http.c.scm_credentials 2007-03-07 18:01:09.000000000 +0000
-+++ cups-1.2.8/cups/http.c 2007-03-07 18:03:00.000000000 +0000
-@@ -2515,6 +2515,46 @@
+--- cups-1.2.8/cups/http.c.scm_credentials 2007-03-08 10:10:38.000000000 +0000
++++ cups-1.2.8/cups/http.c 2007-03-08 10:52:19.000000000 +0000
+@@ -109,6 +109,11 @@
+ # include <sys/resource.h>
+ #endif /* !WIN32 */
+
++#include <sys/socket.h>
++#include <sys/types.h>
++#if !defined(WIN32) && !defined(__EMX__)
++# include <unistd.h>
++#endif
+
+ /*
+ * Some operating systems have done away with the Fxxxx constants for
+@@ -2515,6 +2520,58 @@
httpGetLength2(http);
httpClearFields(http);
-+#ifdef AF_LOCAL
++#ifdef SCM_CREDENTIALS
+ if (!strncmp(http->authstring, "SCM_CREDENTIALS", 15))
+ {
+ struct msghdr msg;
@@ -13,8 +25,15 @@
+ char dummy;
+ char buf[CMSG_SPACE(sizeof(struct ucred))];
+ struct ucred *uptr;
++ fd_set fds;
++ struct timeval tv;
+
-+ if (recv(http->fd, &dummy, 1, 0) != 1)
++ FD_ZERO(&fds);
++ FD_SET(http->fd, &fds);
++ tv.tv_sec = 5; /* Wait up to 5 seconds. */
++ tv.tv_usec = 0;
++ if (select(http->fd + 1, &fds, NULL, &fds, &tv) < 1 ||
++ recv(http->fd, &dummy, 1, 0) != 1)
+ {
+ DEBUG_printf(("http_send: failed to synchronize for SCM_CREDENTIALS"));
+ return (-1);
@@ -36,20 +55,35 @@
+ uptr->gid = getgid();
+ uptr->pid = getpid();
+ msg.msg_controllen = cmsg->cmsg_len;
-+ if (sendmsg(http->fd, &msg, 0) == -1)
++ FD_ZERO(&fds);
++ FD_SET(http->fd, &fds);
++ tv.tv_sec = 5;
++ tv.tv_usec = 0;
++ if (select(http->fd + 1, NULL, &fds, &fds, &tv) < 1 ||
++ sendmsg(http->fd, &msg, 0) == -1)
+ {
+ DEBUG_printf(("http_send: failed to send SCM_CREDENTIALS"));
+ return (-1);
+ }
+ }
-+#endif /* AF_LOCAL */
++#endif /* SCM_CREDENTIALS */
+
return (0);
}
--- cups-1.2.8/cups/auth.c.scm_credentials 2007-01-10 16:48:37.000000000 +0000
-+++ cups-1.2.8/cups/auth.c 2007-03-07 18:01:09.000000000 +0000
-@@ -47,6 +47,8 @@
++++ cups-1.2.8/cups/auth.c 2007-03-08 10:53:43.000000000 +0000
+@@ -26,6 +26,9 @@
+ * Contents:
+ *
+ * cupsDoAuthentication() - Authenticate a request.
++ * cups_scm_credentials_auth
++ * - Find out if SCM_CREDENTIALS authentication
++ * is possible
+ * cups_local_auth() - Get the local authorization certificate if
+ * available/applicable...
+ */
+@@ -47,6 +50,8 @@
# include <unistd.h>
#endif /* WIN32 || __EMX__ */
@@ -58,11 +92,11 @@
/*
* Local functions...
-@@ -177,6 +179,54 @@
+@@ -177,6 +182,57 @@
return (0);
}
-+#ifdef AF_LOCAL
++#ifdef SCM_CREDENTIALS
+/*
+ * 'cups_scm_credentials_auth()'
+ * - UNIX Domain Sockets authentication
@@ -86,16 +120,19 @@
+ buf = malloc (buflen);
+ if (buf == NULL)
+ return (-1);
++
+ if (getpwnam_r (cupsUser(), &pwbuf, buf, buflen, &pwbufptr) != 0)
+ {
+ free (buf);
+ return (-1);
+ }
++
+ if (pwbuf.pw_uid != getuid())
+ {
+ free (buf);
+ return (-1);
+ }
++
+ free (buf);
+
+ /*
@@ -109,11 +146,11 @@
+
+ return (0);
+}
-+#endif /* AF_LOCAL */
++#endif /* SCM_CREDENTIALS */
/*
* 'cups_local_auth()' - Get the local authorization certificate if
-@@ -234,7 +284,13 @@
+@@ -234,7 +290,13 @@
{
DEBUG_printf(("cups_local_auth: Unable to open file %s: %s\n",
filename, strerror(errno)));
@@ -128,23 +165,27 @@
/*
--- cups-1.2.8/scheduler/auth.c.scm_credentials 2006-09-12 14:58:39.000000000 +0100
-+++ cups-1.2.8/scheduler/auth.c 2007-03-07 18:03:15.000000000 +0000
-@@ -80,6 +80,10 @@
++++ cups-1.2.8/scheduler/auth.c 2007-03-08 10:50:19.000000000 +0000
+@@ -80,6 +80,14 @@
# include <membership.h>
#endif /* HAVE_MEMBERSHIP_H */
+#include <sys/socket.h>
++#include <sys/time.h>
+#include <sys/types.h>
+#include <pwd.h>
++#if !defined(WIN32) && !defined(__EMX__)
++# include <unistd.h>
++#endif
+
/*
* Local functions...
-@@ -384,6 +388,87 @@
+@@ -384,6 +392,99 @@
"cupsdAuthorize: No authentication data provided.");
return;
}
-+#ifdef AF_LOCAL
++#ifdef SCM_CREDENTIALS
+ else if (!strncmp(authorization, "SCM_CREDENTIALS", 3) &&
+ con->http.hostaddr->addr.sa_family == AF_LOCAL)
+ {
@@ -154,6 +195,8 @@
+ struct iovec vec;
+ char dummy;
+ char buf[CMSG_SPACE(sizeof(struct ucred))];
++ fd_set fds;
++ struct timeval tv;
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "SCM_CREDENTIALS authentication");
+
@@ -169,7 +212,12 @@
+ * until we send them this zero byte to synchronize.
+ */
+ dummy = '\0';
-+ if (send(con->http.fd, &dummy, 1, 0) != 1)
++ FD_ZERO(&fds);
++ FD_SET(con->http.fd, &fds);
++ tv.tv_sec = 5; /* Wait up to 5 seconds */
++ tv.tv_usec = 0;
++ if (select(con->http.fd + 1, NULL, &fds, &fds, &tv) < 1 ||
++ send(con->http.fd, &dummy, 1, 0) != 1)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "SCM_CREDENTIALS sync failed");
+ return;
@@ -182,7 +230,12 @@
+ msg.msg_iovlen = 1;
+ msg.msg_control = buf;
+ msg.msg_controllen = sizeof(buf);
-+ if (recvmsg(con->http.fd, &msg, 0) == -1)
++ FD_ZERO(&fds);
++ FD_SET(con->http.fd, &fds);
++ tv.tv_sec = 5; /* Wait up to 5 seconds */
++ tv.tv_usec = 0;
++ if (select(con->http.fd + 1, &fds, NULL, &fds, &tv) < 1 ||
++ recvmsg(con->http.fd, &msg, 0) == -1)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "SCM_CREDENTIALS recvmsg failed!");
+ return;
@@ -224,7 +277,7 @@
+ }
+ }
+ }
-+#endif /* AF_LOCAL */
++#endif /* SCM_CREDENTIALS */
else if (!strncmp(authorization, "Local", 5) &&
!strcasecmp(con->http.hostname, "localhost"))
{
More information about the fedora-cvs-commits
mailing list