rpms/cups/devel cups-parallel-id.patch, NONE, 1.1 cups.spec, 1.366, 1.367 cups-libieee1284.patch, 1.2, NONE

Tim Waugh (twaugh) fedora-extras-commits at redhat.com
Wed Oct 10 11:25:22 UTC 2007


Author: twaugh

Update of /cvs/pkgs/rpms/cups/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9724

Modified Files:
	cups.spec 
Added Files:
	cups-parallel-id.patch 
Removed Files:
	cups-libieee1284.patch 
Log Message:
* Wed Oct 10 2007 Tim Waugh <twaugh at redhat.com> 1:1.3.3-3
- Use ppdev instead of libieee1284 for parallel port Device ID
  retrieval (bug #311671).  This avoids SELinux audit messages.


cups-parallel-id.patch:

--- NEW FILE cups-parallel-id.patch ---
diff -up cups-1.3.3/backend/ieee1284.c.parallel-id cups-1.3.3/backend/ieee1284.c
--- cups-1.3.3/backend/ieee1284.c.parallel-id	2007-07-11 22:46:42.000000000 +0100
+++ cups-1.3.3/backend/ieee1284.c	2007-10-10 12:15:21.000000000 +0100
@@ -32,6 +32,10 @@
 #  include <linux/lp.h>
 #  define IOCNR_GET_DEVICE_ID		1
 #  define LPIOC_GET_DEVICE_ID(len)	_IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
+#  include <linux/parport.h>
+#  include <linux/ppdev.h>
+#  include <unistd.h>
+#  include <fcntl.h>
 #endif /* __linux */
 
 #ifdef __sun
@@ -68,6 +72,7 @@ backendGetDeviceID(
   int	manulen;			/* Length of manufacturer string */
 #ifdef __linux
   int	length;				/* Length of device ID info */
+  int   got_id = 0;
 #endif /* __linux */
 #if defined(__sun) && defined(ECPPIOC_GETDEVID)
   struct ecpp_device_id did;		/* Device ID buffer */
@@ -93,9 +98,6 @@ backendGetDeviceID(
   if (make_model)
     *make_model = '\0';
 
-  if (uri)
-    *uri = '\0';
-
   if (fd >= 0)
   {
    /*
@@ -105,7 +107,74 @@ backendGetDeviceID(
     *device_id = '\0';
 
 #ifdef __linux
-    if (!ioctl(fd, LPIOC_GET_DEVICE_ID(device_id_size), device_id))
+  if (ioctl(fd, LPIOC_GET_DEVICE_ID(device_id_size), device_id))
+  {
+#  ifdef DEBUG
+    printf("backendGetDeviceID: ioctl failed - %s\n", strerror(errno));
+#  endif /* DEBUG */
+
+    if (!strcmp (scheme, "parallel") &&
+	uri && !strncmp (uri, "parallel:/dev/", 14))
+    {
+      const char *n;
+      char devparport[16];
+      int devparportfd;
+      n = uri + strcspn (uri, "0123456789");
+      strcpy (devparport, "/dev/parport");
+      strncpy (devparport + 12, n, 3);
+      devparport[15] = '\0';
+      devparportfd = open (devparport, O_RDWR | O_NOCTTY);
+      if (devparportfd != -1)
+      {
+	/* Put the device into Device ID mode */
+	int err = ioctl (devparportfd, PPCLAIM);
+	int m = IEEE1284_MODE_COMPAT;
+
+	if (err)
+	{
+	  close (devparportfd);
+	  devparportfd = -1;
+	}
+
+	if (!err)
+	  err = ioctl (devparportfd, PPNEGOT, &m);
+
+	if (!err)
+	{
+	  m = IEEE1284_MODE_NIBBLE | IEEE1284_DEVICEID;
+	  err = ioctl (devparportfd, PPNEGOT, &m);
+	}
+
+	/* Make the file descriptor non-blocking to guard against
+	 * bugs in the device. */
+	if (!err)
+	{
+	  int f = fcntl (devparportfd, F_GETFL);
+	  f |= O_NONBLOCK;
+	  err = fcntl (devparportfd, F_SETFL, f);
+	}
+
+	/* Read the ID */
+	if (!err)
+	{
+	  if (read (devparportfd, device_id, device_id_size) < 2)
+	    err = 1;
+	  else
+	    got_id = 1;
+	}
+
+	if (devparportfd > -1)
+	{
+	  ioctl (devparportfd, PPRELEASE);
+	  close (devparportfd);
+	}
+      }
+    }
+  }
+  else
+    got_id = 1;
+
+  if (got_id)
     {
      /*
       * Extract the length of the device ID string from the first two
@@ -168,6 +237,9 @@ backendGetDeviceID(
 
   DEBUG_printf(("backendGetDeviceID: device_id=\"%s\"\n", device_id));
 
+  if (uri)
+    *uri = '\0';
+
   if (!*device_id)
     return (-1);
 
diff -up cups-1.3.3/backend/parallel.c.parallel-id cups-1.3.3/backend/parallel.c
--- cups-1.3.3/backend/parallel.c.parallel-id	2007-08-22 19:34:34.000000000 +0100
+++ cups-1.3.3/backend/parallel.c	2007-10-10 12:14:23.000000000 +0100
@@ -350,9 +350,12 @@ list_devices(void)
       * Now grab the IEEE 1284 device ID string...
       */
 
+      char device_uri[255 + 9];
+      strcpy (device_uri, "parallel:");
+      strcpy (device_uri + 9, device);
       if (!backendGetDeviceID(fd, device_id, sizeof(device_id),
                               make_model, sizeof(make_model),
-			      NULL, NULL, 0))
+			      "parallel", device_uri, sizeof (device_uri)))
 	printf("direct parallel:%s \"%s\" \"%s LPT #%d\" \"%s\"\n", device,
 	       make_model, make_model, i + 1, device_id);
       else


Index: cups.spec
===================================================================
RCS file: /cvs/pkgs/rpms/cups/devel/cups.spec,v
retrieving revision 1.366
retrieving revision 1.367
diff -u -r1.366 -r1.367
--- cups.spec	9 Oct 2007 16:23:59 -0000	1.366
+++ cups.spec	10 Oct 2007 11:24:50 -0000	1.367
@@ -6,7 +6,7 @@
 Summary: Common Unix Printing System
 Name: cups
 Version: 1.3.3
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2
 Group: System Environment/Daemons
 Source: ftp://ftp.easysw.com/pub/cups/test//cups-%{version}-source.tar.bz2
@@ -41,7 +41,7 @@
 Patch15: cups-str2512.patch
 Patch16: cups-pid.patch
 Patch17: cups-foomatic-recommended.patch
-Patch18: cups-libieee1284.patch
+Patch18: cups-parallel-id.patch
 Patch19: cups-eggcups.patch
 Patch20: cups-getpass.patch
 Patch21: cups-driverd-timeout.patch
@@ -52,7 +52,6 @@
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 PreReq: /sbin/chkconfig /sbin/service
 Requires: %{name}-libs = %{epoch}:%{version}
-Requires: libieee1284
 %if %use_alternatives
 Provides: /usr/bin/lpq /usr/bin/lpr /usr/bin/lp /usr/bin/cancel /usr/bin/lprm /usr/bin/lpstat
 Prereq: /usr/sbin/alternatives
@@ -75,7 +74,6 @@
 BuildRequires: libtiff-devel
 BuildRequires: krb5-devel
 BuildRequires: avahi-compat-libdns_sd-devel
-BuildRequires: libieee1284-devel
 
 %if %lspp
 BuildPrereq: libselinux-devel >= 1.23
@@ -155,7 +153,7 @@
 %patch15 -p1 -b .str2512
 %patch16 -p1 -b .pid
 %patch17 -p1 -b .foomatic-recommended
-%patch18 -p1 -b .libieee1284
+%patch18 -p1 -b .parallel-id
 %patch19 -p1 -b .eggcups
 %patch20 -p1 -b .getpass
 %patch21 -p1 -b .driverd-timeout
@@ -451,6 +449,10 @@
 %{cups_serverbin}/daemon/cups-lpd
 
 %changelog
+* Wed Oct 10 2007 Tim Waugh <twaugh at redhat.com> 1:1.3.3-3
+- Use ppdev instead of libieee1284 for parallel port Device ID
+  retrieval (bug #311671).  This avoids SELinux audit messages.
+
 * Tue Oct  9 2007 Tim Waugh <twaugh at redhat.com> 1:1.3.3-2
 - Use libieee1284 for parallel port Device ID retrieval (bug #311671).
 


--- cups-libieee1284.patch DELETED ---




More information about the fedora-extras-commits mailing list