- Use ppdev instead of libieee1284 for parallel port Device ID retrieval
(bug #311671). This avoids SELinux audit messages.
This commit is contained in:
parent
6d4e0a0903
commit
2e7d27e1b6
@ -1,171 +0,0 @@
|
|||||||
diff -up cups-1.3.3/backend/ieee1284.c.libieee1284 cups-1.3.3/backend/ieee1284.c
|
|
||||||
--- cups-1.3.3/backend/ieee1284.c.libieee1284 2007-07-11 22:46:42.000000000 +0100
|
|
||||||
+++ cups-1.3.3/backend/ieee1284.c 2007-10-09 17:00:54.000000000 +0100
|
|
||||||
@@ -32,6 +32,8 @@
|
|
||||||
# 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 <ieee1284.h>
|
|
||||||
+# include <dlfcn.h>
|
|
||||||
#endif /* __linux */
|
|
||||||
|
|
||||||
#ifdef __sun
|
|
||||||
@@ -93,11 +95,10 @@ backendGetDeviceID(
|
|
||||||
if (make_model)
|
|
||||||
*make_model = '\0';
|
|
||||||
|
|
||||||
- if (uri)
|
|
||||||
- *uri = '\0';
|
|
||||||
-
|
|
||||||
if (fd >= 0)
|
|
||||||
{
|
|
||||||
+ int got_id = 0;
|
|
||||||
+
|
|
||||||
/*
|
|
||||||
* Get the device ID string...
|
|
||||||
*/
|
|
||||||
@@ -105,7 +106,66 @@ 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"))
|
|
||||||
+ {
|
|
||||||
+ struct parport_list ports;
|
|
||||||
+ int i;
|
|
||||||
+ const char *n;
|
|
||||||
+ int (*find_ports) (struct parport_list *, int);
|
|
||||||
+ void (*free_ports) (struct parport_list *);
|
|
||||||
+ ssize_t (*get_deviceid) (struct parport *, int, int,
|
|
||||||
+ char *, size_t);
|
|
||||||
+ void *libieee1284;
|
|
||||||
+
|
|
||||||
+ libieee1284 = dlopen ("libieee1284.so", RTLD_LAZY);
|
|
||||||
+ if (libieee1284)
|
|
||||||
+ {
|
|
||||||
+ dlerror ();
|
|
||||||
+ find_ports = dlsym (libieee1284, "ieee1284_find_ports");
|
|
||||||
+ free_ports = dlsym (libieee1284, "ieee1284_free_ports");
|
|
||||||
+ get_deviceid = dlsym (libieee1284, "ieee1284_get_deviceid");
|
|
||||||
+ if (dlerror () != NULL)
|
|
||||||
+ {
|
|
||||||
+ dlclose (libieee1284);
|
|
||||||
+ libieee1284 = NULL;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (libieee1284)
|
|
||||||
+ {
|
|
||||||
+ n = uri + strcspn (uri, "0123456789");
|
|
||||||
+ if (n && *n && (*find_ports) (&ports, 0) == E1284_OK)
|
|
||||||
+ {
|
|
||||||
+ for (i = 0; i < ports.portc; i++)
|
|
||||||
+ {
|
|
||||||
+ const char *filename = ports.portv[i]->filename;
|
|
||||||
+ if (!strncmp (filename, "/dev/parport", 12) &&
|
|
||||||
+ !strcmp (filename + 12, n))
|
|
||||||
+ {
|
|
||||||
+ device_id_size = (*get_deviceid) (ports.portv[i], -1,
|
|
||||||
+ F1284_FRESH, device_id,
|
|
||||||
+ device_id_size);
|
|
||||||
+ got_id = 1;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ (*free_ports) (&ports);
|
|
||||||
+ dlclose (libieee1284);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ got_id = 1;
|
|
||||||
+
|
|
||||||
+ if (got_id)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Extract the length of the device ID string from the first two
|
|
||||||
@@ -136,10 +196,6 @@ backendGetDeviceID(
|
|
||||||
memmove(device_id, device_id + 2, length);
|
|
||||||
device_id[length] = '\0';
|
|
||||||
}
|
|
||||||
-# ifdef DEBUG
|
|
||||||
- else
|
|
||||||
- printf("backendGetDeviceID: ioctl failed - %s\n", strerror(errno));
|
|
||||||
-# endif /* DEBUG */
|
|
||||||
#endif /* __linux */
|
|
||||||
|
|
||||||
#if defined(__sun) && defined(ECPPIOC_GETDEVID)
|
|
||||||
@@ -168,6 +224,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/Makefile.libieee1284 cups-1.3.3/backend/Makefile
|
|
||||||
--- cups-1.3.3/backend/Makefile.libieee1284 2007-08-08 20:27:51.000000000 +0100
|
|
||||||
+++ cups-1.3.3/backend/Makefile 2007-10-09 17:07:00.000000000 +0100
|
|
||||||
@@ -99,7 +99,7 @@ betest: betest.o ../cups/$(LIBCUPS)
|
|
||||||
test1284: test1284.o ../cups/libcups.a
|
|
||||||
echo Linking $@...
|
|
||||||
$(CC) $(LDFLAGS) -o test1284 test1284.o ../cups/libcups.a \
|
|
||||||
- $(SSLLIBS) $(COMMONLIBS) $(LIBZ)
|
|
||||||
+ $(SSLLIBS) $(COMMONLIBS) $(LIBZ) -ldl
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
@@ -160,7 +160,7 @@ pap: pap.o ../cups/$(LIBCUPS)
|
|
||||||
|
|
||||||
parallel: parallel.o ../cups/$(LIBCUPS) libbackend.a
|
|
||||||
echo Linking $@...
|
|
||||||
- $(CC) $(LDFLAGS) -o parallel parallel.o libbackend.a $(LIBS)
|
|
||||||
+ $(CC) $(LDFLAGS) -o parallel parallel.o libbackend.a -ldl $(LIBS)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
@@ -189,7 +189,7 @@ serial: serial.o ../cups/$(LIBCUPS) libb
|
|
||||||
|
|
||||||
snmp: snmp.o ../cups/$(LIBCUPS) libbackend.a
|
|
||||||
echo Linking $@...
|
|
||||||
- $(CC) $(LDFLAGS) -o snmp snmp.o libbackend.a $(LIBS)
|
|
||||||
+ $(CC) $(LDFLAGS) -o snmp snmp.o libbackend.a $(LIBS) -ldl
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
@@ -207,7 +207,7 @@ socket: socket.o ../cups/$(LIBCUPS) libb
|
|
||||||
|
|
||||||
usb: usb.o ../cups/$(LIBCUPS) libbackend.a
|
|
||||||
echo Linking $@...
|
|
||||||
- $(CC) $(LDFLAGS) -o usb usb.o libbackend.a $(BACKLIBS) $(LIBS)
|
|
||||||
+ $(CC) $(LDFLAGS) -o usb usb.o libbackend.a $(BACKLIBS) $(LIBS) -ldl
|
|
||||||
usb.o: usb.c usb-darwin.c usb-unix.c
|
|
||||||
|
|
||||||
|
|
||||||
diff -up cups-1.3.3/backend/parallel.c.libieee1284 cups-1.3.3/backend/parallel.c
|
|
||||||
--- cups-1.3.3/backend/parallel.c.libieee1284 2007-08-22 19:34:34.000000000 +0100
|
|
||||||
+++ cups-1.3.3/backend/parallel.c 2007-10-09 16:49:50.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
|
|
135
cups-parallel-id.patch
Normal file
135
cups-parallel-id.patch
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
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
|
12
cups.spec
12
cups.spec
@ -6,7 +6,7 @@
|
|||||||
Summary: Common Unix Printing System
|
Summary: Common Unix Printing System
|
||||||
Name: cups
|
Name: cups
|
||||||
Version: 1.3.3
|
Version: 1.3.3
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
Source: ftp://ftp.easysw.com/pub/cups/test//cups-%{version}-source.tar.bz2
|
Source: ftp://ftp.easysw.com/pub/cups/test//cups-%{version}-source.tar.bz2
|
||||||
@ -41,7 +41,7 @@ Patch14: cups-lpr-help.patch
|
|||||||
Patch15: cups-str2512.patch
|
Patch15: cups-str2512.patch
|
||||||
Patch16: cups-pid.patch
|
Patch16: cups-pid.patch
|
||||||
Patch17: cups-foomatic-recommended.patch
|
Patch17: cups-foomatic-recommended.patch
|
||||||
Patch18: cups-libieee1284.patch
|
Patch18: cups-parallel-id.patch
|
||||||
Patch19: cups-eggcups.patch
|
Patch19: cups-eggcups.patch
|
||||||
Patch20: cups-getpass.patch
|
Patch20: cups-getpass.patch
|
||||||
Patch21: cups-driverd-timeout.patch
|
Patch21: cups-driverd-timeout.patch
|
||||||
@ -52,7 +52,6 @@ Url: http://www.cups.org/
|
|||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
PreReq: /sbin/chkconfig /sbin/service
|
PreReq: /sbin/chkconfig /sbin/service
|
||||||
Requires: %{name}-libs = %{epoch}:%{version}
|
Requires: %{name}-libs = %{epoch}:%{version}
|
||||||
Requires: libieee1284
|
|
||||||
%if %use_alternatives
|
%if %use_alternatives
|
||||||
Provides: /usr/bin/lpq /usr/bin/lpr /usr/bin/lp /usr/bin/cancel /usr/bin/lprm /usr/bin/lpstat
|
Provides: /usr/bin/lpq /usr/bin/lpr /usr/bin/lp /usr/bin/cancel /usr/bin/lprm /usr/bin/lpstat
|
||||||
Prereq: /usr/sbin/alternatives
|
Prereq: /usr/sbin/alternatives
|
||||||
@ -75,7 +74,6 @@ BuildRequires: libpng-devel
|
|||||||
BuildRequires: libtiff-devel
|
BuildRequires: libtiff-devel
|
||||||
BuildRequires: krb5-devel
|
BuildRequires: krb5-devel
|
||||||
BuildRequires: avahi-compat-libdns_sd-devel
|
BuildRequires: avahi-compat-libdns_sd-devel
|
||||||
BuildRequires: libieee1284-devel
|
|
||||||
|
|
||||||
%if %lspp
|
%if %lspp
|
||||||
BuildPrereq: libselinux-devel >= 1.23
|
BuildPrereq: libselinux-devel >= 1.23
|
||||||
@ -155,7 +153,7 @@ lpd emulation.
|
|||||||
%patch15 -p1 -b .str2512
|
%patch15 -p1 -b .str2512
|
||||||
%patch16 -p1 -b .pid
|
%patch16 -p1 -b .pid
|
||||||
%patch17 -p1 -b .foomatic-recommended
|
%patch17 -p1 -b .foomatic-recommended
|
||||||
%patch18 -p1 -b .libieee1284
|
%patch18 -p1 -b .parallel-id
|
||||||
%patch19 -p1 -b .eggcups
|
%patch19 -p1 -b .eggcups
|
||||||
%patch20 -p1 -b .getpass
|
%patch20 -p1 -b .getpass
|
||||||
%patch21 -p1 -b .driverd-timeout
|
%patch21 -p1 -b .driverd-timeout
|
||||||
@ -451,6 +449,10 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%{cups_serverbin}/daemon/cups-lpd
|
%{cups_serverbin}/daemon/cups-lpd
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Oct 10 2007 Tim Waugh <twaugh@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@redhat.com> 1:1.3.3-2
|
* Tue Oct 9 2007 Tim Waugh <twaugh@redhat.com> 1:1.3.3-2
|
||||||
- Use libieee1284 for parallel port Device ID retrieval (bug #311671).
|
- Use libieee1284 for parallel port Device ID retrieval (bug #311671).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user