From 3af9ac9e69ffb72416112ec1a52416d6bd6fe69e Mon Sep 17 00:00:00 2001 From: msweet Date: Mon, 9 Dec 2013 19:26:39 +0000 Subject: [PATCH] The libusb-based USB backend incorrectly used write timeouts () Closer to final server TLS APIs. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11455 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.7.txt | 2 + backend/usb-libusb.c | 6 +-- cups/cups.h | 3 +- cups/http.h | 6 +-- cups/tls-darwin.c | 100 ++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 108 insertions(+), 9 deletions(-) diff --git a/CHANGES-1.7.txt b/CHANGES-1.7.txt index 286e2e1ae6..4e30d9fd3f 100644 --- a/CHANGES-1.7.txt +++ b/CHANGES-1.7.txt @@ -22,6 +22,8 @@ CHANGES IN CUPS V1.7.1 - Japanese PPDs using with the Shift-JIS encoding did not work () - "tel:" URIs incorrectly had slashes () + - The libusb-based USB backend incorrectly used write timeouts + () CHANGES IN CUPS V1.7.0 diff --git a/backend/usb-libusb.c b/backend/usb-libusb.c index 20c3d1b568..0a9162645b 100644 --- a/backend/usb-libusb.c +++ b/backend/usb-libusb.c @@ -496,7 +496,7 @@ print_device(const char *uri, /* I - Device URI */ iostatus = libusb_bulk_transfer(g.printer->handle, g.printer->write_endp, print_buffer, g.print_bytes, - &bytes, 60000); + &bytes, 0); /* * Ignore timeout errors, but retain the number of bytes written to * avoid sending duplicate data... @@ -519,7 +519,7 @@ print_device(const char *uri, /* I - Device URI */ iostatus = libusb_bulk_transfer(g.printer->handle, g.printer->write_endp, print_buffer, g.print_bytes, - &bytes, 60000); + &bytes, 0); } /* @@ -534,7 +534,7 @@ print_device(const char *uri, /* I - Device URI */ iostatus = libusb_bulk_transfer(g.printer->handle, g.printer->write_endp, print_buffer, g.print_bytes, - &bytes, 60000); + &bytes, 0); } if (iostatus) diff --git a/cups/cups.h b/cups/cups.h index dd109be111..1d8ca6ae3d 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -620,7 +620,8 @@ extern void cupsSetUserAgent(const char *user_agent) _CUPS_API_1_7; extern const char *cupsUserAgent(void) _CUPS_API_1_7; /* New in CUPS 2.0 */ -extern int cupsSetServerCredentials(const char *path, const char *common_name) _CUPS_API_2_0; +extern int cupsMakeServerCredentials(const char *path, const char *common_name, int num_alt_names, const char **alt_names, time_t expiration_date) _CUPS_API_2_0; +extern int cupsSetServerCredentials(const char *path, const char *common_name, int auto_create) _CUPS_API_2_0; # ifdef __cplusplus } diff --git a/cups/http.h b/cups/http.h index abc0f91044..db40b8123b 100644 --- a/cups/http.h +++ b/cups/http.h @@ -614,7 +614,9 @@ extern http_state_t httpWriteResponse(http_t *http, extern int httpAddrClose(http_addr_t *addr, int fd) _CUPS_API_2_0; extern int httpAddrFamily(http_addr_t *addr) _CUPS_API_2_0; extern int httpCompareCredentials(cups_array_t *cred1, cups_array_t *cred2) _CUPS_API_2_0; -extern time_t httpCredentialsExpiration(cups_array_t *credentials) _CUPS_API_2_0; +extern int httpCredentialsAreTrusted(cups_array_t *credentials) _CUPS_API_2_0; +extern time_t httpCredentialsGetExpiration(cups_array_t *credentials) _CUPS_API_2_0; +extern int httpCredentialsIsValidName(cups_array_t *credentials, const char *common_name); extern size_t httpCredentialsString(cups_array_t *credentials, char *buffer, size_t bufsize) _CUPS_API_2_0; extern http_field_t httpFieldValue(const char *name) _CUPS_API_2_0; extern time_t httpGetActivity(http_t *http) _CUPS_API_2_0; @@ -627,11 +629,9 @@ extern size_t httpGetRemaining(http_t *http) _CUPS_API_2_0; extern int httpIsChunked(http_t *http) _CUPS_API_2_0; extern int httpIsEncrypted(http_t *http) _CUPS_API_2_0; extern int httpLoadCredentials(const char *path, cups_array_t **credentials, const char *common_name) _CUPS_API_2_0; -extern int httpMakeServerCredentials(const char *path, const char *common_name, int num_alt_names, const char **alt_names, time_t expiration_date) _CUPS_API_2_0; extern const char *httpResolveHostname(http_t *http, char *buffer, size_t bufsize) _CUPS_API_2_0; extern int httpSaveCredentials(const char *path, cups_array_t *credentials, const char *common_name) _CUPS_API_2_0; extern void httpSetKeepAlive(http_t *http, http_keepalive_t keep_alive) _CUPS_API_2_0; -extern int httpSetServerCredentials(http_t *http, const char *path, const char *common_name) _CUPS_API_2_0; extern void httpShutdown(http_t *http) _CUPS_API_2_0; extern const char *httpStateString(http_state_t state); diff --git a/cups/tls-darwin.c b/cups/tls-darwin.c index 4dda4f2d3b..baaccdd28a 100644 --- a/cups/tls-darwin.c +++ b/cups/tls-darwin.c @@ -36,6 +36,52 @@ static OSStatus http_cdsa_write(SSLConnectionRef connection, const void *data, size_t *dataLength); +/* + * 'cupsMakeServerCredentials()' - Make a self-signed certificate and private key pair. + * + * @since CUPS 2.0@ + */ + +int /* O - 1 on success, 0 on failure */ +cupsMakeServerCredentials( + const char *path, /* I - Path to keychain/directory */ + const char *common_name, /* I - Common name */ + int num_alt_names, /* I - Number of subject alternate names */ + const char **alt_names, /* I - Subject Alternate Names */ + time_t expiration_date) /* I - Expiration date */ +{ + (void)path; + (void)common_name; + (void)num_alt_names; + (void)alt_names; + (void)expiration_date; + + return (0); +} + + +/* + * 'cupsSetServerCredentials()' - Set the default server credentials. + * + * Note: The server credentials are used by all threads in the running process. + * This function is threadsafe. + * + * @since CUPS 2.0@ + */ + +int /* O - 1 on success, 0 on failure */ +cupsSetServerCredentials( + const char *path, /* I - Path to keychain/directory */ + const char *common_name, /* I - Default common name for server */ + int auto_create) /* I - 1 = automatically create self-signed certificates */ +{ + (void)path; + (void)common_name; + (void)auto_create; + + return (0); +} + /* * 'httpCopyCredentials()' - Copy the credentials associated with the peer in @@ -132,6 +178,56 @@ _httpCreateCredentials( } +/* + * 'httpCredentialsAreTrusted()' - Return whether the credentials are trusted. + * + * @since CUPS 2.0@ + */ + +int /* O - 1 if trusted, 0 if not/unknown */ +httpCredentialsAreTrusted( + cups_array_t *credentials) /* I - Credentials */ +{ + (void)credentials; + + return (0); +} + + +/* + * 'httpCredentialsGetExpiration()' - Return the expiration date of the credentials. + * + * @since CUPS 2.0@ + */ + +time_t /* O - Expiration date of credentials */ +httpCredentialsGetExpiration( + cups_array_t *credentials) /* I - Credentials */ +{ + (void)credentials; + + return (0); +} + + +/* + * 'httpCredentialsIsValidName()' - Return whether the credentials are valid for the given name. + * + * @since CUPS 2.0@ + */ + +int /* O - 1 if valid, 0 otherwise */ +httpCredentialsIsValidName( + cups_array_t *credentials, /* I - Credentials */ + const char *common_name) /* I - Name to check */ +{ + (void)credentials; + (void)common_name; + + return (0); +} + + /* * 'httpCredentialsString()' - Return a string representing the credentials. * @@ -259,14 +355,14 @@ httpLoadCredentials( #if 0 /* - * 'httpMakeCredentials()' - Create self-signed credentials for the given + * 'cupsMakeCredentials()' - Create self-signed credentials for the given * name. * * @since CUPS 2.0@ */ int /* O - 0 on success, -1 on error */ -httpMakeCredentials( +cupsMakeCredentials( const char *path, /* I - Keychain/PKCS#12 path */ cups_array_t **credentials, /* O - Credentials */ const char *common_name) /* I - Common name for X.509 cert */ -- 2.47.2