summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2009-02-11 16:34:01 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2009-02-11 16:34:01 +0000
commitbf3816c7edd01247b850a12e52856819190b66fd (patch)
tree24dcfae7bdd3378ab3153f03f78da4507afad8c6 /backend
parent745129beebf8651dd9ce221cc7c046460b4ae8f6 (diff)
Merge changes from CUPS 1.4svn-r8346.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1212 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'backend')
-rw-r--r--backend/dnssd.c11
-rw-r--r--backend/usb-darwin.c95
2 files changed, 69 insertions, 37 deletions
diff --git a/backend/dnssd.c b/backend/dnssd.c
index ec32bba48..97c0d6071 100644
--- a/backend/dnssd.c
+++ b/backend/dnssd.c
@@ -3,7 +3,7 @@
*
* DNS-SD discovery backend for the Common UNIX Printing System (CUPS).
*
- * Copyright 2008 by Apple Inc.
+ * Copyright 2008-2009 by Apple Inc.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
@@ -122,6 +122,7 @@ main(int argc, /* I - Number of command-line args */
struct timeval timeout; /* Timeout for select() */
cups_array_t *devices; /* Device array */
cups_device_t *device; /* Current device */
+ char uriName[1024]; /* Unquoted fullName for URI */
/*
@@ -297,8 +298,10 @@ main(int argc, /* I - Number of command-line args */
else if (strcasecmp(best->name, device->name) ||
strcasecmp(best->domain, device->domain))
{
+ unquote(uriName, best->fullName, sizeof(uriName));
+
httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
- schemes[best->type], NULL, best->fullName, 0,
+ schemes[best->type], NULL, uriName, 0,
best->cups_shared ? "/cups" : "/");
cupsBackendReport("network", device_uri, best->make_and_model,
@@ -319,8 +322,10 @@ main(int argc, /* I - Number of command-line args */
if (best)
{
+ unquote(uriName, best->fullName, sizeof(uriName));
+
httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
- schemes[best->type], NULL, best->fullName, 0,
+ schemes[best->type], NULL, uriName, 0,
best->cups_shared ? "/cups" : "/");
cupsBackendReport("network", device_uri, best->make_and_model,
diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c
index 23b7baecd..fe2dabdd3 100644
--- a/backend/usb-darwin.c
+++ b/backend/usb-darwin.c
@@ -1,7 +1,7 @@
/*
* "$Id: usb-darwin.c 7953 2008-09-17 01:43:19Z mike $"
*
-* Copyright 2005-2008 Apple Inc. All rights reserved.
+* Copyright 2005-2009 Apple Inc. All rights reserved.
*
* IMPORTANT: This Apple software is supplied to you by Apple Computer,
* Inc. ("Apple") in consideration of your agreement to the following
@@ -1241,56 +1241,83 @@ static kern_return_t load_classdriver(CFStringRef driverPath,
printer_interface_t intf,
classdriver_t ***printerDriver)
{
- kern_return_t kr = kUSBPrinterClassDeviceNotOpen;
- classdriver_t **driver = NULL;
- CFStringRef bundle = (driverPath == NULL ? kUSBGenericTOPrinterClassDriver : driverPath);
+ kern_return_t kr = kUSBPrinterClassDeviceNotOpen;
+ classdriver_t **driver = NULL;
+ CFStringRef bundle = driverPath ? driverPath : kUSBGenericTOPrinterClassDriver;
+ char bundlestr[1024]; /* Bundle path */
+ struct stat bundleinfo; /* File information for bundle */
+ CFURLRef url; /* URL for driver */
+ CFPlugInRef plugin = NULL; /* Plug-in address */
- if (bundle != NULL)
+
+ CFStringGetCString(bundle, bundlestr, sizeof(bundlestr), kCFStringEncodingUTF8);
+
+ /*
+ * Validate permissions for the class driver...
+ */
+
+ if (stat(bundlestr, &bundleinfo))
{
- CFURLRef url = CFURLCreateWithFileSystemPath(NULL, bundle, kCFURLPOSIXPathStyle, true);
- CFPlugInRef plugin = (url != NULL ? CFPlugInCreate(NULL, url) : NULL);
+ fprintf(stderr, "Unable to load class driver \"%s\": %s", bundlestr,
+ strerror(errno));
+ return (kr);
+ }
+ else if (bundleinfo.st_mode & S_IWOTH)
+ {
+ fprintf(stderr, "Unable to load class driver \"%s\": insecure file "
+ "permissions (0%o)", bundlestr, bundleinfo.st_mode);
+ return (kr);
+ }
+
+ /*
+ * Try loading the class driver...
+ */
- if (url != NULL)
- CFRelease(url);
+ url = CFURLCreateWithFileSystemPath(NULL, bundle, kCFURLPOSIXPathStyle, true);
- if (plugin != NULL)
+ if (url)
+ {
+ plugin = CFPlugInCreate(NULL, url);
+ CFRelease(url);
+ }
+ else
+ plugin = NULL;
+
+ if (plugin)
+ {
+ CFArrayRef factories = CFPlugInFindFactoriesForPlugInTypeInPlugIn(kUSBPrinterClassTypeID, plugin);
+ if (factories != NULL && CFArrayGetCount(factories) > 0)
{
- CFArrayRef factories = CFPlugInFindFactoriesForPlugInTypeInPlugIn(kUSBPrinterClassTypeID, plugin);
- if (factories != NULL && CFArrayGetCount(factories) > 0)
+ CFUUIDRef factoryID = CFArrayGetValueAtIndex(factories, 0);
+ IUnknownVTbl **iunknown = CFPlugInInstanceCreate(NULL, factoryID, kUSBPrinterClassTypeID);
+ if (iunknown != NULL)
{
- CFUUIDRef factoryID = CFArrayGetValueAtIndex(factories, 0);
- IUnknownVTbl **iunknown = CFPlugInInstanceCreate(NULL, factoryID, kUSBPrinterClassTypeID);
- if (iunknown != NULL)
+ kr = (*iunknown)->QueryInterface(iunknown, CFUUIDGetUUIDBytes(kUSBPrinterClassInterfaceID), (LPVOID *)&driver);
+ if (kr == kIOReturnSuccess && driver != NULL)
{
- kr = (*iunknown)->QueryInterface(iunknown, CFUUIDGetUUIDBytes(kUSBPrinterClassInterfaceID), (LPVOID *)&driver);
- if (kr == kIOReturnSuccess && driver != NULL)
- {
- classdriver_t **genericDriver = NULL;
- if (driverPath != NULL && CFStringCompare(driverPath, kUSBGenericTOPrinterClassDriver, 0) != kCFCompareEqualTo)
- kr = load_classdriver(NULL, intf, &genericDriver);
+ classdriver_t **genericDriver = NULL;
+ if (driverPath != NULL && CFStringCompare(driverPath, kUSBGenericTOPrinterClassDriver, 0) != kCFCompareEqualTo)
+ kr = load_classdriver(NULL, intf, &genericDriver);
- if (kr == kIOReturnSuccess)
- {
- (*driver)->interface = intf;
- (*driver)->Initialize(driver, genericDriver);
+ if (kr == kIOReturnSuccess)
+ {
+ (*driver)->interface = intf;
+ (*driver)->Initialize(driver, genericDriver);
- (*driver)->plugin = plugin;
- (*driver)->interface = intf;
- *printerDriver = driver;
- }
+ (*driver)->plugin = plugin;
+ (*driver)->interface = intf;
+ *printerDriver = driver;
}
- (*iunknown)->Release(iunknown);
}
- CFRelease(factories);
+ (*iunknown)->Release(iunknown);
}
+ CFRelease(factories);
}
}
- char bundlestr[1024];
- CFStringGetCString(bundle, bundlestr, sizeof(bundlestr), kCFStringEncodingUTF8);
fprintf(stderr, "DEBUG: load_classdriver(%s) (kr:0x%08x)\n", bundlestr, (int)kr);
- return kr;
+ return (kr);
}