From 879062a99862ef1d1106cf950f6b7bdc4bb3d348 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 21 Aug 2002 02:06:27 +0000 Subject: [PATCH] Mirror 1.1.x changes. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@2711 7a7537e8-13f0-0310-91df-b6672ffda945 --- CHANGES-1.1.txt | 4 +++ scheduler/client.c | 81 ++++++++++++++++++++++++++++------------------ scheduler/ipp.c | 34 +++++++++++++++++-- scheduler/job.c | 23 +++++++++++-- scheduler/main.c | 9 ++++-- 5 files changed, 113 insertions(+), 38 deletions(-) diff --git a/CHANGES-1.1.txt b/CHANGES-1.1.txt index cb83f366b..c2722d7ed 100644 --- a/CHANGES-1.1.txt +++ b/CHANGES-1.1.txt @@ -3,6 +3,10 @@ CHANGES-1.1.txt CHANGES IN CUPS V1.1.16 + - The scheduler now rejects jobs with copies outside the + range of 1 to 100, inclusive. + - The scheduler didn't block signals while it processed + others and when it forked processes. - Updated the CUPS startup script to better support different timezones and to support the RedHat/Mandrake init script functions, if available. diff --git a/scheduler/client.c b/scheduler/client.c index 57243c73a..0f833fda0 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1,5 +1,5 @@ /* - * "$Id: client.c,v 1.91.2.15 2002/06/07 20:40:10 mike Exp $" + * "$Id: client.c,v 1.91.2.16 2002/08/21 02:06:22 mike Exp $" * * Client routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -2236,36 +2236,40 @@ install_conf_file(client_t *con) /* I - Connection */ * 'pipe_command()' - Pipe the output of a command to the remote client. */ -static int /* O - Process ID */ -pipe_command(client_t *con, /* I - Client connection */ - int infile, /* I - Standard input for command */ - int *outfile, /* O - Standard output for command */ - char *command, /* I - Command to run */ - char *options) /* I - Options for command */ +static int /* O - Process ID */ +pipe_command(client_t *con, /* I - Client connection */ + int infile, /* I - Standard input for command */ + int *outfile, /* O - Standard output for command */ + char *command, /* I - Command to run */ + char *options) /* I - Options for command */ { - int pid; /* Process ID */ - char *commptr; /* Command string pointer */ - int fd; /* Looping var */ - int fds[2]; /* Pipe FDs */ - int argc; /* Number of arguments */ - int envc; /* Number of environment variables */ - char argbuf[10240], /* Argument buffer */ - *argv[100], /* Argument strings */ - *envp[100]; /* Environment variables */ - char lang[1024], /* LANG env variable */ - content_length[1024], /* CONTENT_LENGTH env variable */ - content_type[1024], /* CONTENT_TYPE env variable */ - ipp_port[1024], /* Default listen port */ - server_port[1024], /* Default server port */ - server_name[1024], /* Default listen hostname */ - remote_host[1024], /* REMOTE_HOST env variable */ - remote_user[1024], /* REMOTE_USER env variable */ - tmpdir[1024], /* TMPDIR environment variable */ - ldpath[1024], /* LD_LIBRARY_PATH environment variable */ - nlspath[1024], /* NLSPATH environment variable */ - datadir[1024], /* CUPS_DATADIR environment variable */ - root[1024], /* CUPS_SERVERROOT environment variable */ - query_string[10240]; /* QUERY_STRING env variable */ + int pid; /* Process ID */ + char *commptr; /* Command string pointer */ + int fd; /* Looping var */ + int fds[2]; /* Pipe FDs */ + int argc; /* Number of arguments */ + int envc; /* Number of environment variables */ + char argbuf[10240], /* Argument buffer */ + *argv[100], /* Argument strings */ + *envp[100]; /* Environment variables */ + char lang[1024], /* LANG env variable */ + content_length[1024], /* CONTENT_LENGTH env variable */ + content_type[1024], /* CONTENT_TYPE env variable */ + ipp_port[1024], /* Default listen port */ + server_port[1024], /* Default server port */ + server_name[1024], /* Default listen hostname */ + remote_host[1024], /* REMOTE_HOST env variable */ + remote_user[1024], /* REMOTE_USER env variable */ + tmpdir[1024], /* TMPDIR environment variable */ + ldpath[1024], /* LD_LIBRARY_PATH environment variable */ + nlspath[1024], /* NLSPATH environment variable */ + datadir[1024], /* CUPS_DATADIR environment variable */ + root[1024], /* CUPS_SERVERROOT environment variable */ + query_string[10240]; /* QUERY_STRING env variable */ +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + sigset_t oldmask, /* POSIX signal masks */ + newmask; +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ /* @@ -2437,6 +2441,17 @@ pipe_command(client_t *con, /* I - Client connection */ return (0); } + /* + * Block signals before forking... + */ + +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + sigemptyset(&newmask); + sigaddset(&newmask, SIGTERM); + sigaddset(&newmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &newmask, &oldmask); +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + /* * Then execute the command... */ @@ -2531,11 +2546,15 @@ pipe_command(client_t *con, /* I - Client connection */ *outfile = fds[0]; close(fds[1]); +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + sigprocmask(SIG_SETMASK, &oldmask, NULL); +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + return (pid); } } /* - * End of "$Id: client.c,v 1.91.2.15 2002/06/07 20:40:10 mike Exp $". + * End of "$Id: client.c,v 1.91.2.16 2002/08/21 02:06:22 mike Exp $". */ diff --git a/scheduler/ipp.c b/scheduler/ipp.c index c340045b0..ee5b1c413 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c,v 1.127.2.20 2002/08/19 18:47:25 mike Exp $" + * "$Id: ipp.c,v 1.127.2.21 2002/08/21 02:06:23 mike Exp $" * * IPP routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -2119,6 +2119,21 @@ create_job(client_t *con, /* I - Client connection */ return; } + /* + * Validate job template attributes; for now just copies... + */ + + if ((attr = ippFindAttribute(con->request, "copies", IPP_TAG_INTEGER)) != NULL) + { + if (attr->values[0].integer < 1 || attr->values[0].integer > 100) + { + LogMessage(L_INFO, "create_job: bad copies value %d.", + attr->values[0].integer); + send_ipp_error(con, IPP_ATTRIBUTES); + return; + } + } + /* * Make sure we aren't over our limit... */ @@ -3846,6 +3861,21 @@ print_job(client_t *con, /* I - Client connection */ return; } + /* + * Validate job template attributes; for now just copies... + */ + + if ((attr = ippFindAttribute(con->request, "copies", IPP_TAG_INTEGER)) != NULL) + { + if (attr->values[0].integer < 1 || attr->values[0].integer > 100) + { + LogMessage(L_INFO, "print_job: bad copies value %d.", + attr->values[0].integer); + send_ipp_error(con, IPP_ATTRIBUTES); + return; + } + } + /* * OK, see if the client is sending the document compressed - CUPS * doesn't support compression yet... @@ -5812,5 +5842,5 @@ validate_user(client_t *con, /* I - Client connection */ /* - * End of "$Id: ipp.c,v 1.127.2.20 2002/08/19 18:47:25 mike Exp $". + * End of "$Id: ipp.c,v 1.127.2.21 2002/08/21 02:06:23 mike Exp $". */ diff --git a/scheduler/job.c b/scheduler/job.c index f26dd80df..b51821d59 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1,5 +1,5 @@ /* - * "$Id: job.c,v 1.124.2.27 2002/08/12 17:47:45 mike Exp $" + * "$Id: job.c,v 1.124.2.28 2002/08/21 02:06:25 mike Exp $" * * Job management routines for the Common UNIX Printing System (CUPS). * @@ -2275,11 +2275,26 @@ start_process(const char *command, /* I - Full path to command */ { int fd; /* Looping var */ int pid; /* Process ID */ +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + sigset_t oldmask, /* POSIX signal masks */ + newmask; +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ LogMessage(L_DEBUG, "start_process(\"%s\", %p, %p, %d, %d, %d)", command, argv, envp, infd, outfd, errfd); + /* + * Block signals before forking... + */ + +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + sigemptyset(&newmask); + sigaddset(&newmask, SIGTERM); + sigaddset(&newmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &newmask, &oldmask); +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + if ((pid = fork()) == 0) { /* @@ -2370,10 +2385,14 @@ start_process(const char *command, /* I - Full path to command */ return (0); } +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + sigprocmask(SIG_SETMASK, &oldmask, NULL); +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + return (pid); } /* - * End of "$Id: job.c,v 1.124.2.27 2002/08/12 17:47:45 mike Exp $". + * End of "$Id: job.c,v 1.124.2.28 2002/08/21 02:06:25 mike Exp $". */ diff --git a/scheduler/main.c b/scheduler/main.c index 48ff2bba7..bc5d5732e 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -1,5 +1,5 @@ /* - * "$Id: main.c,v 1.57.2.18 2002/07/22 12:37:12 mike Exp $" + * "$Id: main.c,v 1.57.2.19 2002/08/21 02:06:27 mike Exp $" * * Scheduler main loop for the Common UNIX Printing System (CUPS). * @@ -277,6 +277,7 @@ main(int argc, /* I - Number of command-line arguments */ sigemptyset(&action.sa_mask); sigaddset(&action.sa_mask, SIGTERM); + sigaddset(&action.sa_mask, SIGCHLD); action.sa_handler = sigterm_handler; sigaction(SIGTERM, &action, NULL); #else @@ -635,6 +636,7 @@ CatchChildSignals(void) memset(&action, 0, sizeof(action)); sigemptyset(&action.sa_mask); + sigaddset(&action.sa_mask, SIGTERM); sigaddset(&action.sa_mask, SIGCHLD); action.sa_handler = sigchld_handler; sigaction(SIGCHLD, &action, NULL); @@ -723,7 +725,8 @@ sigchld_handler(int sig) /* I - Signal number */ } for (job = Jobs; job != NULL; job = job->next) - if (job->state->values[0].integer == IPP_JOB_PROCESSING) + if (job->state != NULL && + job->state->values[0].integer == IPP_JOB_PROCESSING) { for (i = 0; job->filters[i]; i ++) if (job->filters[i] == pid) @@ -885,5 +888,5 @@ usage(void) /* - * End of "$Id: main.c,v 1.57.2.18 2002/07/22 12:37:12 mike Exp $". + * End of "$Id: main.c,v 1.57.2.19 2002/08/21 02:06:27 mike Exp $". */ -- 2.39.2