/*
- * "$Id: client.c,v 1.19 1999/05/10 21:35:40 mike Exp $"
+ * "$Id: client.c,v 1.20 1999/06/09 20:07:02 mike Exp $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
break;
case HTTP_POST_RECV :
+ /*
+ * See if the POST request includes a Content-Length field, and if
+ * so check the length against any limits that are set...
+ */
+
+ if (con->http.fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
+ atoi(con->http.fields[HTTP_FIELD_CONTENT_LENGTH]) > MaxRequestSize &&
+ MaxRequestSize > 0)
+ {
+ /*
+ * Request too large...
+ */
+
+ if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
+ {
+ CloseClient(con);
+ return (0);
+ }
+
+ break;
+ }
+
/*
* See what kind of POST request this is; for IPP requests the
* content-type field will be "application/ipp"...
{
if (con->file)
{
+ fstat(con->file, &filestats);
close(con->file);
con->file = 0;
+
+ if (filestats.st_size > MaxRequestSize &&
+ MaxRequestSize > 0)
+ {
+ /*
+ * Request is too big; remove it and send an error...
+ */
+
+ unlink(con->filename);
+
+ if (con->request)
+ {
+ /*
+ * Delete any IPP request data...
+ */
+
+ ippDelete(con->request);
+ con->request = NULL;
+ }
+
+ if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
+ {
+ CloseClient(con);
+ return (0);
+ }
+ }
}
if (con->request)
/*
- * End of "$Id: client.c,v 1.19 1999/05/10 21:35:40 mike Exp $".
+ * End of "$Id: client.c,v 1.20 1999/06/09 20:07:02 mike Exp $".
*/
/*
- * "$Id: dirsvc.c,v 1.18 1999/05/20 18:43:05 mike Exp $"
+ * "$Id: dirsvc.c,v 1.19 1999/06/09 20:07:03 mike Exp $"
*
* Directory services routines for the Common UNIX Printing System (CUPS).
*
void
UpdateBrowseList(void)
{
+ int i; /* Looping var */
+ int len; /* Length of name string */
int bytes; /* Number of bytes left */
char packet[1540]; /* Broadcast packet */
cups_ptype_t type; /* Printer type */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
char name[IPP_MAX_NAME], /* Name of printer */
- *ptr; /* Pointer into hostname */
- printer_t *p; /* Printer information */
+ *hptr, /* Pointer into hostname */
+ *sptr; /* Pointer into ServerName */
+ printer_t *p, /* Printer information */
+ *pclass, /* Printer class */
+ *first; /* First printer in class */
/*
type |= CUPS_PRINTER_REMOTE;
- if ((ptr = strchr(host, '.')) != NULL)
- *ptr = '\0';
+ hptr = strchr(host, '.');
+ sptr = strchr(ServerName, '.');
+
+ if (hptr != NULL && sptr != NULL &&
+ strcasecmp(hptr, sptr) == 0)
+ *hptr = '\0';
if (type & CUPS_PRINTER_CLASS)
{
p->state = state;
p->accepting = state != IPP_PRINTER_STOPPED;
p->browse_time = time(NULL);
+
+ /*
+ * Do auto-classing if needed...
+ */
+
+ if (ImplicitClasses)
+ {
+ /*
+ * Loop through all available printers and create classes as needed...
+ */
+
+ for (p = Printers, len = 0; p != NULL; p = p->next)
+ {
+ /*
+ * Skip classes...
+ */
+
+ if (p->type & CUPS_PRINTER_CLASS)
+ {
+ len = 0;
+ continue;
+ }
+
+ /*
+ * If len == 0, get the length of this printer name up to the "@"
+ * sign (if any).
+ */
+
+ if (len > 0 &&
+ strncasecmp(p->name, name + 3, len) == 0 &&
+ (p->name[len] == '\0' || p->name[len] == '@'))
+ {
+ /*
+ * We have more than one printer with the same name; see if
+ * we have a class, and if this printer is a member...
+ */
+
+ if ((pclass = FindClass(name)) == NULL)
+ pclass = AddClass(name);
+
+ if (first != NULL)
+ {
+ for (i = 0; i < pclass->num_printers; i ++)
+ if (pclass->printers[i] == first)
+ break;
+
+ if (i >= pclass->num_printers)
+ AddPrinterToClass(pclass, first);
+
+ first = NULL;
+ }
+
+ for (i = 0; i < pclass->num_printers; i ++)
+ if (pclass->printers[i] == p)
+ break;
+
+ if (i >= pclass->num_printers)
+ AddPrinterToClass(pclass, p);
+ }
+ else
+ {
+ /*
+ * First time around; just get name length and mark it as first
+ * in the list...
+ */
+
+ if ((hptr = strchr(p->name, '@')) != NULL)
+ len = hptr - p->name;
+ else
+ len = strlen(p->name);
+
+ strcpy(name, "Any");
+ strncpy(name + 3, p->name, len);
+ name[len + 3] = '\0';
+ first = p;
+ }
+ }
+ }
}
/*
- * End of "$Id: dirsvc.c,v 1.18 1999/05/20 18:43:05 mike Exp $".
+ * End of "$Id: dirsvc.c,v 1.19 1999/06/09 20:07:03 mike Exp $".
*/
/*
- * "$Id: job.c,v 1.24 1999/06/04 21:07:23 mike Exp $"
+ * "$Id: job.c,v 1.25 1999/06/09 20:07:04 mike Exp $"
*
* Job management routines for the Common UNIX Printing System (CUPS).
*
{
DEBUG_printf(("CheckJobs: current->dest = \'%s\'\n", current->dest));
- if ((printer = FindPrinter(current->dest)) == NULL)
+ if (FindClass(current->dest) != NULL)
printer = FindAvailablePrinter(current->dest);
+ else
+ printer = FindPrinter(current->dest);
if (printer == NULL && FindClass(current->dest) == NULL)
{
LogMessage(LOG_ERROR, "Unable to convert file to printable format for job %s-%d!",
printer->name, current->id);
CancelJob(current->id);
+ return;
}
/*
/*
- * End of "$Id: job.c,v 1.24 1999/06/04 21:07:23 mike Exp $".
+ * End of "$Id: job.c,v 1.25 1999/06/09 20:07:04 mike Exp $".
*/
/*
- * "$Id: main.c,v 1.18 1999/05/26 20:05:05 mike Exp $"
+ * "$Id: main.c,v 1.19 1999/06/09 20:07:04 mike Exp $"
*
* Scheduler main loop for the Common UNIX Printing System (CUPS).
*
#define _MAIN_C_
#include "cupsd.h"
+#include <sys/resource.h>
/*
listener_t *lis; /* Current listener */
time_t activity; /* Activity timer */
struct timeval timeout; /* select() timeout */
+ struct rlimit limit; /* Runtime limit */
#ifdef HAVE_SIGACTION
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION */
putenv("TZ=GMT");
tzset();
+#ifndef DEBUG
+ /*
+ * Disable core dumps...
+ */
+
+ getrlimit(RLIMIT_CORE, &limit);
+ limit.rlim_cur = 0;
+ setrlimit(RLIMIT_CORE, &limit);
+#endif /* DEBUG */
+
+ /*
+ * Set the maximum number of files...
+ */
+
+ getrlimit(RLIMIT_NOFILE, &limit);
+ limit.rlim_cur = limit.rlim_max;
+ setrlimit(RLIMIT_NOFILE, &limit);
+
/*
* Catch hangup and child signals and ignore broken pipes...
*/
/*
- * End of "$Id: main.c,v 1.18 1999/05/26 20:05:05 mike Exp $".
+ * End of "$Id: main.c,v 1.19 1999/06/09 20:07:04 mike Exp $".
*/