files.
- Added new "cupsaddsmb" utility for exporting
CUPS printer drivers to SAMBA/Windows clients.
+ - Added preliminary support for Darwin/MacOS X.
- The CUPS-Add-Printer operation no longer allows
arbitrary scheme names in device URIs to be used - it
now restricts the available schemes to those found in
using the subdirectory approach, e.g. the "es"
subdirectory under /usr/share/cups/banners is used for
the Spanish banner files.
- - Added support for Darwin/MacOS X builds (compiles
- but does not work 100%).
- Updated the scheduler so it knows the correct
language abbreviation to use for all supported
PPD LanguageVersion values. The new code also
- *BSD static library creation fixes.
- Use mkstemps() instead of tmpnam() in pdftops whenever
possible.
+ - Added httpGetHostByName() function as a wrapper around
+ gethostbyname() - some implementations of this
+ function do not support IP addresses (e.g. MacOS X.)
+ - Added casts to all printf's of file lengths, since
+ there is currently no standard way of formatting long
+ long values.
+ - The client filename field was not cleared in all
+ instances, resulting in old form data being submitted
+ to CGIs.
+ - The httpConnect*() functions now try all available
+ addresses for a host when connecting for the first
+ time.
CHANGES IN CUPS V1.1.10-1
#
-# "$Id: Makefile,v 1.37 2001/10/26 03:16:46 mike Exp $"
+# "$Id: Makefile,v 1.38 2001/10/30 20:37:13 mike Exp $"
#
# Top-level Makefile for the Common UNIX Printing System (CUPS).
#
fi
if test "x$(INITDIR)" = "x" -a "x$(INITDDIR)" != "x"; then \
$(INSTALL_DIR) $(BUILDROOT)$(INITDDIR); \
- $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
- if test "$(INITDDIR)" = "/System/Library/StartupItems/cups"; then \
- $(INSTALL_DATA) cups.plist $(BUILDROOT)$(INITDDIR)/cups.plist; \
+ if test "$(INITDDIR)" = "/System/Library/StartupItems/CUPS"; then \
+ $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR)/CUPS; \
+ $(INSTALL_DATA) cups.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
+ $(INSTALL_DIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
+ $(INSTALL_DATA) cups.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
+ else \
+ $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
fi \
fi
epm $(EPMFLAGS) -f tardist cups
#
-# End of "$Id: Makefile,v 1.37 2001/10/26 03:16:46 mike Exp $".
+# End of "$Id: Makefile,v 1.38 2001/10/30 20:37:13 mike Exp $".
#
/*
- * "$Id: lpd.c,v 1.29 2001/06/06 16:47:52 mike Exp $"
+ * "$Id: lpd.c,v 1.30 2001/10/30 20:37:13 mike Exp $"
*
* Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
*
* First try to reserve a port for this connection...
*/
- if ((hostaddr = gethostbyname(hostname)) == NULL)
+ if ((hostaddr = httpGetHostByName(hostname)) == NULL)
{
fprintf(stderr, "ERROR: Unable to locate printer \'%s\' - %s",
hostname, strerror(errno));
/*
- * End of "$Id: lpd.c,v 1.29 2001/06/06 16:47:52 mike Exp $".
+ * End of "$Id: lpd.c,v 1.30 2001/10/30 20:37:13 mike Exp $".
*/
/*
- * "$Id: socket.c,v 1.23 2001/07/30 19:38:25 mike Exp $"
+ * "$Id: socket.c,v 1.24 2001/10/30 20:37:13 mike Exp $"
*
* AppSocket backend for the Common UNIX Printing System (CUPS).
*
* Then try to connect to the remote host...
*/
- if ((hostaddr = gethostbyname(hostname)) == NULL)
+ if ((hostaddr = httpGetHostByName(hostname)) == NULL)
{
fprintf(stderr, "ERROR: Unable to locate printer \'%s\' - %s\n",
hostname, strerror(errno));
/*
- * End of "$Id: socket.c,v 1.23 2001/07/30 19:38:25 mike Exp $".
+ * End of "$Id: socket.c,v 1.24 2001/10/30 20:37:13 mike Exp $".
*/
dnl
-dnl "$Id: cups-directories.m4,v 1.3 2001/10/07 12:16:08 mike Exp $"
+dnl "$Id: cups-directories.m4,v 1.4 2001/10/30 20:37:14 mike Exp $"
dnl
dnl Directory stuff for the Common UNIX Printing System (CUPS).
dnl
Darwin*)
# Darwin and MacOS X - this is just strange...
INITDIR=""
- INITDDIR="/System/Library/StartupItems/cups"
+ INITDDIR="/System/Library/StartupItems/CUPS"
;;
Linux*)
dnl See what directory to put server executables...
case "$uname" in
- FreeBSD* | NetBSD* | OpenBSD*)
+ FreeBSD* | NetBSD* | OpenBSD* | Darwin*)
# *BSD
INSTALL_SYSV=""
CUPS_SERVERBIN='${exec_prefix}/libexec/cups'
dnl Set the CUPS_LOCALE directory...
case "$uname" in
- Linux* | FreeBSD* | NetBSD* | OpenBSD*)
+ Linux* | FreeBSD* | NetBSD* | OpenBSD* | Darwin*)
CUPS_LOCALEDIR='${datadir}/locale'
AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$datadir/locale")
;;
AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$fontpath")
dnl
-dnl End of "$Id: cups-directories.m4,v 1.3 2001/10/07 12:16:08 mike Exp $".
+dnl End of "$Id: cups-directories.m4,v 1.4 2001/10/30 20:37:14 mike Exp $".
dnl
--- /dev/null
+{
+ Description = "CUPS Printing";
+ Provides = ("CUPS");
+ Requires = ("Resolver");
+ OrderPreference = "None";
+ Messages =
+ {
+ start = "Starting CUPS";
+ stop = "Stopping CUPS";
+ };
+}
#!/bin/sh
#
-# "$Id: cups.sh.in,v 1.12 2001/05/21 21:32:50 mike Exp $"
+# "$Id: cups.sh.in,v 1.13 2001/10/30 20:37:13 mike Exp $"
#
# Startup/shutdown script for the Common UNIX Printing System (CUPS).
#
#### OS-Dependent Configuration
+
case "`uname`" in
IRIX*)
IS_ON=/sbin/chkconfig
IS_ON=:
;;
+ Darwin*)
+ . /etc/rc.common
+
+ if test "${CUPS:=-YES-}" = "-NO-"; then
+ exit 0
+ fi
+
+ IS_ON=:
+ ;;
+
*)
IS_ON=/bin/true
;;
# all but IRIX, which can configure verbose bootup messages.
#
-if $IS_ON verbose; then
- ECHO=echo
+if "`uname`" = "Darwin"; then
+ ECHO=ConsoleMessage
else
- ECHO=:
+ if $IS_ON verbose; then
+ ECHO=echo
+ else
+ ECHO=:
+ fi
fi
#
OSF1*)
pid=`ps -e | awk '{print $1,$5}' | grep cupsd | awk '{print $1}'`
;;
- Linux* | NetBSD*)
+ Linux* | NetBSD* | Darwin*)
pid=`ps ax | awk '{print $1,$5}' | grep cupsd | awk '{print $1}'`
;;
*)
#
-# End of "$Id: cups.sh.in,v 1.12 2001/05/21 21:32:50 mike Exp $".
+# End of "$Id: cups.sh.in,v 1.13 2001/10/30 20:37:13 mike Exp $".
#
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+ <key>Starting CUPS</key>
+ <string>Starting CUPS</string>
+</dict>
+</plist>
+
#
-# "$Id: Makefile,v 1.62 2001/10/07 12:16:09 mike Exp $"
+# "$Id: Makefile,v 1.63 2001/10/30 20:37:14 mike Exp $"
#
# Support library Makefile for the Common UNIX Printing System (CUPS).
#
libcups.la: $(LIBOBJS) ../Makedefs
echo Linking $@...
$(DSO) $(DSOFLAGS) -o $@ $(LIBOBJS:.o=.lo) -rpath $(LIBDIR) \
- -version-info 2:3 $(SSLLIBS)
+ -version-info 2:4 $(SSLLIBS)
#
#
-# End of "$Id: Makefile,v 1.62 2001/10/07 12:16:09 mike Exp $".
+# End of "$Id: Makefile,v 1.63 2001/10/30 20:37:14 mike Exp $".
#
/*
- * "$Id: http.c,v 1.87 2001/09/14 16:52:06 mike Exp $"
+ * "$Id: http.c,v 1.88 2001/10/30 20:37:14 mike Exp $"
*
* HTTP routines for the Common UNIX Printing System (CUPS) scheduler.
*
* httpConnectEncrypt() - Connect to a HTTP server using encryption.
* httpEncryption() - Set the required encryption on the link.
* httpReconnect() - Reconnect to a HTTP server...
+ * httpGetHostByName() - Lookup a hostname or IP address, and return
+ * address records for the specified name.
* httpSeparate() - Separate a Universal Resource Identifier into its
* components.
* httpGetSubField() - Get a sub-field value.
http_encryption_t encrypt)
/* I - Type of encryption to use */
{
+ int i; /* Looping var */
http_t *http; /* New HTTP connection */
struct hostent *hostaddr; /* Host address data */
* Lookup the host...
*/
- if ((hostaddr = gethostbyname(host)) == NULL)
+ if ((hostaddr = httpGetHostByName(host)) == NULL)
{
/*
* This hack to make users that don't have a localhost entry in
if (strcasecmp(host, "localhost") != 0)
return (NULL);
- else if ((hostaddr = gethostbyname("127.0.0.1")) == NULL)
+ else if ((hostaddr = httpGetHostByName("127.0.0.1")) == NULL)
return (NULL);
}
http->encryption = encrypt;
/*
- * Connect to the remote system...
+ * Loop through the addresses we have until one of them connects...
*/
- if (httpReconnect(http))
+ for (i = 0; hostaddr->h_addr_list[i]; i ++)
{
- free(http);
- return (NULL);
+ /*
+ * Load the address...
+ */
+
+ httpAddrLoad(hostaddr, port, i, &(http->hostaddr));
+
+ /*
+ * Connect to the remote system...
+ */
+
+ if (!httpReconnect(http))
+ return (http);
}
- else
- return (http);
+
+ /*
+ * Could not connect to any known address - bail out!
+ */
+
+ free(http);
+ return (NULL);
}
}
+/*
+ * 'httpGetHostByName()' - Lookup a hostname or IP address, and return
+ * address records for the specified name.
+ */
+
+struct hostent * /* O - Host entry */
+httpGetHostByName(const char *name) /* I - Hostname or IP address */
+{
+ unsigned ip[4]; /* IP address components */
+ static unsigned packed_ip; /* Packed IPv4 address */
+ static char *packed_ptr[2]; /* Pointer to packed address */
+ static struct hostent host_ip; /* Host entry for IP address */
+
+
+ /*
+ * This function is needed because some operating systems have a
+ * buggy implementation of httpGetHostByName() that does not support
+ * IP addresses. If the first character of the name string is a
+ * number, then sscanf() is used to extract the IP components.
+ * We then pack the components into an IPv4 address manually,
+ * since the inet_aton() function is deprecated. We use the
+ * htonl() macro to get the right byte order for the address.
+ */
+
+ if (isdigit(name[0]))
+ {
+ /*
+ * We have an IP address; break it up and provide the host entry
+ * to the caller. Currently only supports IPv4 addresses, although
+ * it should be trivial to support IPv6 in CUPS 1.2.
+ */
+
+ if (sscanf(name, "%u.%u.%u.%u", ip, ip + 1, ip + 2, ip + 3) != 4)
+ return (NULL); /* Must have 4 numbers */
+
+ packed_ip = htonl(((((((ip[0] << 8) | ip[1]) << 8) | ip[2]) << 8) | ip[3]));
+
+ /*
+ * Fill in the host entry and return it...
+ */
+
+ host_ip.h_name = (char *)name;
+ host_ip.h_aliases = NULL;
+ host_ip.h_addrtype = AF_INET;
+ host_ip.h_length = 4;
+ host_ip.h_addr_list = packed_ptr;
+ packed_ptr[0] = (char *)(&packed_ip);
+ packed_ptr[1] = NULL;
+
+ return (&host_ip);
+ }
+ else
+ {
+ /*
+ * Use the gethostbyname() function to get the IP address for
+ * the name...
+ */
+
+ return (gethostbyname(name));
+ }
+}
+
+
/*
* 'httpSeparate()' - Separate a Universal Resource Identifier into its
* components.
/*
- * End of "$Id: http.c,v 1.87 2001/09/14 16:52:06 mike Exp $".
+ * End of "$Id: http.c,v 1.88 2001/10/30 20:37:14 mike Exp $".
*/
/*
- * "$Id: http.h,v 1.34 2001/05/06 00:11:24 mike Exp $"
+ * "$Id: http.h,v 1.35 2001/10/30 20:37:15 mike Exp $"
*
* Hyper-Text Transport Protocol definitions for the Common UNIX Printing
* System (CUPS).
extern const char *httpGetDateString(time_t t);
extern time_t httpGetDateTime(const char *s);
# define httpGetField(http,field) (http)->fields[field]
+extern struct hostent *httpGetHostByName(const char *name);
extern char *httpGetSubField(http_t *http, http_field_t field,
const char *name, char *value);
extern int httpHead(http_t *http, const char *uri);
#endif /* !_CUPS_HTTP_H_ */
/*
- * End of "$Id: http.h,v 1.34 2001/05/06 00:11:24 mike Exp $".
+ * End of "$Id: http.h,v 1.35 2001/10/30 20:37:15 mike Exp $".
*/
/*
- * "$Id: util.c,v 1.87 2001/10/29 13:30:08 mike Exp $"
+ * "$Id: util.c,v 1.88 2001/10/30 20:37:15 mike Exp $"
*
* Printing utilities for the Common UNIX Printing System (CUPS).
*
*/
if (filename != NULL)
- sprintf(length, "%u", ippLength(request) + (size_t)fileinfo.st_size);
+ sprintf(length, "%lu", (unsigned long)(ippLength(request) +
+ (size_t)fileinfo.st_size));
else
- sprintf(length, "%u", ippLength(request));
+ sprintf(length, "%lu", (unsigned long)ippLength(request));
httpClearFields(http);
httpSetField(http, HTTP_FIELD_CONTENT_LENGTH, length);
/*
- * End of "$Id: util.c,v 1.87 2001/10/29 13:30:08 mike Exp $".
+ * End of "$Id: util.c,v 1.88 2001/10/30 20:37:15 mike Exp $".
*/
/*
- * "$Id: client.c,v 1.104 2001/10/29 13:30:08 mike Exp $"
+ * "$Id: client.c,v 1.105 2001/10/30 20:37:15 mike Exp $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
* Do double lookups as needed...
*/
- if ((host = gethostbyname(con->http.hostname)) != NULL)
+ if ((host = httpGetHostByName(con->http.hostname)) != NULL)
{
/*
* See if the hostname maps to the IP address...
return (0);
}
- if (httpPrintf(HTTP(con), "Content-Length: %d\r\n",
- filestats.st_size) < 0)
+ if (httpPrintf(HTTP(con), "Content-Length: %lu\r\n",
+ (unsigned long)filestats.st_size) < 0)
{
CloseClient(con);
return (0);
close(con->file);
con->file = 0;
unlink(con->filename);
+ con->filename[0] = '\0';
if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
{
LogMessage(L_DEBUG2, "ReadClient() %d Removing temp file %s",
con->http.fd, con->filename);
unlink(con->filename);
+ con->filename[0] = '\0';
if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
{
close(con->file);
con->file = 0;
unlink(con->filename);
+ con->filename[0] = '\0';
if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
{
LogMessage(L_DEBUG2, "ReadClient() %d Removing temp file %s",
con->http.fd, con->filename);
unlink(con->filename);
+ con->filename[0] = '\0';
if (con->request)
{
if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n", httpGetDateString(filestats->st_mtime)) < 0)
return (0);
- if (httpPrintf(HTTP(con), "Content-Length: %d\r\n", filestats->st_size) < 0)
+ if (httpPrintf(HTTP(con), "Content-Length: %lu\r\n",
+ (unsigned long)filestats->st_size) < 0)
return (0);
if (httpPrintf(HTTP(con), "\r\n") < 0)
return (0);
}
con->bytes += bytes;
-
-#ifdef __APPLE__ /* Currently just test code... */
- printf("Wrote %d initial bytes...\n", bytes);
-
- if (!con->pipe_pid)
- {
- /*
- * Copy rest of file...
- */
-
- while ((bytes = read(con->file, buf, HTTP_MAX_BUFFER)) > 0)
- {
- con->bytes += bytes;
- printf("Writing %d more bytes...\n", bytes);
-
- if (httpWrite(HTTP(con), buf, bytes) < 0)
- {
- CloseClient(con);
- return (0);
- }
- }
- }
-#endif /* __APPLE__ */
}
if (bytes <= 0)
LogMessage(L_DEBUG2, "WriteClient: %d Removing temp file %s",
con->http.fd, con->filename);
unlink(con->filename);
+ con->filename[0] = '\0';
}
if (con->request != NULL)
if (getuid() == 0)
{
/*
- * Running as root, so change to non-priviledged user...
+ * Running as root, so change to a non-priviledged user...
*/
if (setgid(Group))
if (infile)
{
close(0);
- dup(infile);
+ if (dup(infile) < 0)
+ exit(errno);
}
close(1);
- dup(fds[1]);
+ if (dup(fds[1]) < 0)
+ exit(errno);
/*
* Close extra file descriptors...
*/
execve(command, argv, envp);
- perror("execve failed");
exit(errno);
return (0);
}
/*
- * End of "$Id: client.c,v 1.104 2001/10/29 13:30:08 mike Exp $".
+ * End of "$Id: client.c,v 1.105 2001/10/30 20:37:15 mike Exp $".
*/
/*
- * "$Id: conf.c,v 1.91 2001/09/14 16:52:08 mike Exp $"
+ * "$Id: conf.c,v 1.92 2001/10/30 20:37:16 mike Exp $"
*
* Configuration routines for the Common UNIX Printing System (CUPS).
*
if (hostname[0] && strcmp(hostname, "*") != 0)
{
- if ((host = gethostbyname(hostname)) == NULL)
+ if ((host = httpGetHostByName(hostname)) == NULL)
{
- LogMessage(L_ERROR, "gethostbyname(\"%s\") failed - %s!", hostname,
+ LogMessage(L_ERROR, "httpGetHostByName(\"%s\") failed - %s!", hostname,
strerror(errno));
return (0);
}
/*
- * End of "$Id: conf.c,v 1.91 2001/09/14 16:52:08 mike Exp $".
+ * End of "$Id: conf.c,v 1.92 2001/10/30 20:37:16 mike Exp $".
*/
/*
- * "$Id: listen.c,v 1.10 2001/06/05 18:28:43 mike Exp $"
+ * "$Id: listen.c,v 1.11 2001/10/30 20:37:16 mike Exp $"
*
* Server listening routines for the Common UNIX Printing System (CUPS)
* scheduler.
memset(&ServerAddr, 0, sizeof(ServerAddr));
- if ((host = gethostbyname(ServerName)) != NULL)
+ if ((host = httpGetHostByName(ServerName)) != NULL)
{
/*
* Found the server's address!
/*
- * End of "$Id: listen.c,v 1.10 2001/06/05 18:28:43 mike Exp $".
+ * End of "$Id: listen.c,v 1.11 2001/10/30 20:37:16 mike Exp $".
*/
/*
- * "$Id: main.c,v 1.61 2001/10/25 16:26:02 mike Exp $"
+ * "$Id: main.c,v 1.62 2001/10/30 20:37:16 mike Exp $"
*
* Scheduler main loop for the Common UNIX Printing System (CUPS).
*
* Process the input buffer...
*/
-#ifdef __APPLE__
- printf("Client %d, fd = %d, input = %d, output = %d\n", con - Clients,
- con->http.fd, FD_ISSET(con->http.fd, &input),
- FD_ISSET(con->http.fd, &output));
-#endif /* __APPLE__ */
-
if (FD_ISSET(con->http.fd, &input) || con->http.used)
if (!ReadClient(con))
{
/*
- * End of "$Id: main.c,v 1.61 2001/10/25 16:26:02 mike Exp $".
+ * End of "$Id: main.c,v 1.62 2001/10/30 20:37:16 mike Exp $".
*/