1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1983, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef lint
|
1997-09-24 06:48:24 +00:00
|
|
|
static const char copyright[] =
|
1994-05-26 05:23:31 +00:00
|
|
|
"@(#) Copyright (c) 1983, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
|
|
|
#endif /* not lint */
|
|
|
|
|
1997-09-24 06:48:24 +00:00
|
|
|
#if 0
|
2003-07-14 19:59:33 +00:00
|
|
|
#ifndef lint
|
1996-05-05 22:40:51 +00:00
|
|
|
static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
|
2003-07-14 19:59:33 +00:00
|
|
|
#endif /* not lint */
|
1997-09-24 06:48:24 +00:00
|
|
|
#endif
|
2003-07-14 15:54:41 +00:00
|
|
|
|
|
|
|
#include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
|
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive printer jobs from the network, queue them and
|
|
|
|
* start the printer daemon.
|
|
|
|
*/
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <dirent.h>
|
2001-07-15 00:09:46 +00:00
|
|
|
#include <errno.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <syslog.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "lp.h"
|
|
|
|
#include "lp.local.h"
|
2001-07-15 05:29:38 +00:00
|
|
|
#include "ctlinfo.h"
|
1994-05-26 05:23:31 +00:00
|
|
|
#include "extern.h"
|
|
|
|
#include "pathnames.h"
|
|
|
|
|
2001-07-23 00:15:37 +00:00
|
|
|
#define ack() (void) write(STDOUT_FILENO, sp, (size_t)1);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2003-08-21 03:43:48 +00:00
|
|
|
/*
|
|
|
|
* The buffer size to use when reading/writing spool files.
|
|
|
|
*/
|
|
|
|
#define SPL_BUFSIZ BUFSIZ
|
|
|
|
|
1997-07-29 04:17:19 +00:00
|
|
|
static char dfname[NAME_MAX]; /* data files */
|
1994-05-26 05:23:31 +00:00
|
|
|
static int minfree; /* keep at least minfree blocks available */
|
2001-06-12 16:38:20 +00:00
|
|
|
static const char *sp = "";
|
1997-07-29 04:17:19 +00:00
|
|
|
static char tfname[NAME_MAX]; /* tmp copy of cf before linking */
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2001-06-12 16:38:20 +00:00
|
|
|
static int chksize(int _size);
|
2001-07-15 00:09:46 +00:00
|
|
|
static void frecverr(const char *_msg, ...) __printf0like(1, 2);
|
2001-06-12 16:38:20 +00:00
|
|
|
static int noresponse(void);
|
|
|
|
static void rcleanup(int _signo);
|
|
|
|
static int read_number(const char *_fn);
|
2001-07-23 00:15:37 +00:00
|
|
|
static int readfile(struct printer *_pp, char *_file, size_t _size);
|
2001-06-12 16:38:20 +00:00
|
|
|
static int readjob(struct printer *_pp);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-06-12 16:38:20 +00:00
|
|
|
recvjob(const char *printer)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
struct stat stb;
|
|
|
|
int status;
|
1997-12-02 20:46:22 +00:00
|
|
|
struct printer myprinter, *pp = &myprinter;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform lookup for printer name or abbreviation
|
|
|
|
*/
|
1998-01-20 14:43:05 +00:00
|
|
|
init_printer(pp);
|
1997-12-02 20:46:22 +00:00
|
|
|
status = getprintcap(printer, pp);
|
|
|
|
switch (status) {
|
|
|
|
case PCAPERR_OSERR:
|
1994-05-26 05:23:31 +00:00
|
|
|
frecverr("cannot open printer description file");
|
1997-12-02 20:46:22 +00:00
|
|
|
break;
|
|
|
|
case PCAPERR_NOTFOUND:
|
1994-05-26 05:23:31 +00:00
|
|
|
frecverr("unknown printer %s", printer);
|
1997-12-02 20:46:22 +00:00
|
|
|
break;
|
|
|
|
case PCAPERR_TCLOOP:
|
|
|
|
fatal(pp, "potential reference loop detected in printcap file");
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1997-07-29 04:17:19 +00:00
|
|
|
|
2003-08-13 20:31:33 +00:00
|
|
|
(void) close(STDERR_FILENO); /* set up log file */
|
1997-12-02 20:46:22 +00:00
|
|
|
if (open(pp->log_file, O_WRONLY|O_APPEND, 0664) < 0) {
|
|
|
|
syslog(LOG_ERR, "%s: %m", pp->log_file);
|
1994-05-26 05:23:31 +00:00
|
|
|
(void) open(_PATH_DEVNULL, O_WRONLY);
|
|
|
|
}
|
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
if (chdir(pp->spool_dir) < 0)
|
2001-07-15 00:09:46 +00:00
|
|
|
frecverr("%s: chdir(%s): %s", pp->printer, pp->spool_dir,
|
|
|
|
strerror(errno));
|
1997-12-02 20:46:22 +00:00
|
|
|
if (stat(pp->lock_file, &stb) == 0) {
|
1994-05-26 05:23:31 +00:00
|
|
|
if (stb.st_mode & 010) {
|
|
|
|
/* queue is disabled */
|
|
|
|
putchar('\1'); /* return error code */
|
|
|
|
exit(1);
|
|
|
|
}
|
1997-12-02 20:46:22 +00:00
|
|
|
} else if (stat(pp->spool_dir, &stb) < 0)
|
2001-07-15 00:09:46 +00:00
|
|
|
frecverr("%s: stat(%s): %s", pp->printer, pp->spool_dir,
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
minfree = 2 * read_number("minfree"); /* scale KB to 512 blocks */
|
|
|
|
signal(SIGTERM, rcleanup);
|
|
|
|
signal(SIGPIPE, rcleanup);
|
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
if (readjob(pp))
|
|
|
|
printjob(pp);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read printer jobs sent by lpd and copy them to the spooling directory.
|
|
|
|
* Return the number of jobs successfully transfered.
|
|
|
|
*/
|
|
|
|
static int
|
2001-06-12 16:38:20 +00:00
|
|
|
readjob(struct printer *pp)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
2000-11-02 19:22:06 +00:00
|
|
|
register int size;
|
2000-11-14 22:08:52 +00:00
|
|
|
int cfcnt, dfcnt;
|
2001-07-23 00:15:37 +00:00
|
|
|
char *cp, *clastp, *errmsg;
|
2000-11-14 22:08:52 +00:00
|
|
|
char givenid[32], givenhost[MAXHOSTNAMELEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
ack();
|
2000-11-02 19:22:06 +00:00
|
|
|
cfcnt = 0;
|
|
|
|
dfcnt = 0;
|
1994-05-26 05:23:31 +00:00
|
|
|
for (;;) {
|
|
|
|
/*
|
|
|
|
* Read a command to tell us what to do
|
|
|
|
*/
|
|
|
|
cp = line;
|
2001-07-23 00:15:37 +00:00
|
|
|
clastp = line + sizeof(line) - 1;
|
1994-05-26 05:23:31 +00:00
|
|
|
do {
|
2001-07-23 00:15:37 +00:00
|
|
|
size = read(STDOUT_FILENO, cp, (size_t)1);
|
|
|
|
if (size != (ssize_t)1) {
|
|
|
|
if (size < (ssize_t)0) {
|
1997-09-24 06:48:24 +00:00
|
|
|
frecverr("%s: lost connection",
|
1997-12-02 20:46:22 +00:00
|
|
|
pp->printer);
|
2000-11-06 04:37:56 +00:00
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2000-11-02 19:22:06 +00:00
|
|
|
return (cfcnt);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
2001-07-23 00:15:37 +00:00
|
|
|
} while ((*cp++ != '\n') && (cp <= clastp));
|
|
|
|
if (cp > clastp) {
|
2000-11-06 04:37:56 +00:00
|
|
|
frecverr("%s: readjob overflow", pp->printer);
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
*--cp = '\0';
|
|
|
|
cp = line;
|
|
|
|
switch (*cp++) {
|
|
|
|
case '\1': /* cleanup because data sent was bad */
|
|
|
|
rcleanup(0);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case '\2': /* read cf file */
|
|
|
|
size = 0;
|
2000-11-02 19:22:06 +00:00
|
|
|
dfcnt = 0;
|
1994-05-26 05:23:31 +00:00
|
|
|
while (*cp >= '0' && *cp <= '9')
|
|
|
|
size = size * 10 + (*cp++ - '0');
|
|
|
|
if (*cp++ != ' ')
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* host name has been authenticated, we use our
|
|
|
|
* view of the host name since we may be passed
|
|
|
|
* something different than what gethostbyaddr()
|
|
|
|
* returns
|
|
|
|
*/
|
2001-07-22 07:25:27 +00:00
|
|
|
strlcpy(cp + 6, from_host, sizeof(line)
|
|
|
|
+ (size_t)(line - cp - 6));
|
2001-12-05 02:07:20 +00:00
|
|
|
if (strchr(cp, '/')) {
|
|
|
|
frecverr("readjob: %s: illegal path name", cp);
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2001-07-22 07:25:27 +00:00
|
|
|
strlcpy(tfname, cp, sizeof(tfname));
|
1997-07-29 04:17:19 +00:00
|
|
|
tfname[sizeof (tfname) - 1] = '\0';
|
1994-05-26 05:23:31 +00:00
|
|
|
tfname[0] = 't';
|
|
|
|
if (!chksize(size)) {
|
2001-07-23 00:15:37 +00:00
|
|
|
(void) write(STDOUT_FILENO, "\2", (size_t)1);
|
1994-05-26 05:23:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
2001-07-23 00:15:37 +00:00
|
|
|
if (!readfile(pp, tfname, (size_t)size)) {
|
1994-05-26 05:23:31 +00:00
|
|
|
rcleanup(0);
|
|
|
|
continue;
|
|
|
|
}
|
2001-07-15 05:29:38 +00:00
|
|
|
errmsg = ctl_renametf(pp->printer, tfname);
|
1994-05-26 05:23:31 +00:00
|
|
|
tfname[0] = '\0';
|
2001-07-15 05:29:38 +00:00
|
|
|
if (errmsg != NULL) {
|
|
|
|
frecverr("%s: %s", pp->printer, errmsg);
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2000-11-02 19:22:06 +00:00
|
|
|
cfcnt++;
|
1994-05-26 05:23:31 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case '\3': /* read df file */
|
2000-11-02 19:22:06 +00:00
|
|
|
*givenid = '\0';
|
|
|
|
*givenhost = '\0';
|
1994-05-26 05:23:31 +00:00
|
|
|
size = 0;
|
|
|
|
while (*cp >= '0' && *cp <= '9')
|
|
|
|
size = size * 10 + (*cp++ - '0');
|
|
|
|
if (*cp++ != ' ')
|
|
|
|
break;
|
2001-12-05 02:07:20 +00:00
|
|
|
if (strchr(cp, '/')) {
|
|
|
|
frecverr("readjob: %s: illegal path name", cp);
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
if (!chksize(size)) {
|
2001-07-23 00:15:37 +00:00
|
|
|
(void) write(STDOUT_FILENO, "\2", (size_t)1);
|
1994-05-26 05:23:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
2001-07-22 07:25:27 +00:00
|
|
|
strlcpy(dfname, cp, sizeof(dfname));
|
2000-11-02 19:22:06 +00:00
|
|
|
dfcnt++;
|
|
|
|
trstat_init(pp, dfname, dfcnt);
|
2001-07-23 00:15:37 +00:00
|
|
|
(void) readfile(pp, dfname, (size_t)size);
|
|
|
|
trstat_write(pp, TR_RECVING, (size_t)size, givenid,
|
|
|
|
from_host, givenhost);
|
1994-05-26 05:23:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
frecverr("protocol screwup: %s", line);
|
2000-11-06 04:37:56 +00:00
|
|
|
/*NOTREACHED*/
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read files send by lpd and copy them to the spooling directory.
|
|
|
|
*/
|
|
|
|
static int
|
2001-07-23 00:15:37 +00:00
|
|
|
readfile(struct printer *pp, char *file, size_t size)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
register char *cp;
|
2003-08-21 03:43:48 +00:00
|
|
|
char buf[SPL_BUFSIZ];
|
2001-07-23 00:15:37 +00:00
|
|
|
size_t amt, i;
|
|
|
|
int err, fd, j;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
fd = open(file, O_CREAT|O_EXCL|O_WRONLY, FILMOD);
|
2000-11-06 04:37:56 +00:00
|
|
|
if (fd < 0) {
|
2001-07-15 00:09:46 +00:00
|
|
|
frecverr("%s: readfile: error on open(%s): %s",
|
|
|
|
pp->printer, file, strerror(errno));
|
2000-11-06 04:37:56 +00:00
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
ack();
|
|
|
|
err = 0;
|
2003-08-21 03:43:48 +00:00
|
|
|
for (i = 0; i < size; i += SPL_BUFSIZ) {
|
|
|
|
amt = SPL_BUFSIZ;
|
1994-05-26 05:23:31 +00:00
|
|
|
cp = buf;
|
|
|
|
if (i + amt > size)
|
|
|
|
amt = size - i;
|
|
|
|
do {
|
2001-07-22 00:03:21 +00:00
|
|
|
j = read(STDOUT_FILENO, cp, amt);
|
2000-11-06 04:37:56 +00:00
|
|
|
if (j <= 0) {
|
|
|
|
frecverr("%s: lost connection", pp->printer);
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
amt -= j;
|
|
|
|
cp += j;
|
|
|
|
} while (amt > 0);
|
2003-08-21 03:43:48 +00:00
|
|
|
amt = SPL_BUFSIZ;
|
1994-05-26 05:23:31 +00:00
|
|
|
if (i + amt > size)
|
|
|
|
amt = size - i;
|
2001-07-23 00:15:37 +00:00
|
|
|
if (write(fd, buf, amt) != (ssize_t)amt) {
|
1994-05-26 05:23:31 +00:00
|
|
|
err++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(void) close(fd);
|
2000-11-06 04:37:56 +00:00
|
|
|
if (err) {
|
|
|
|
frecverr("%s: write error on close(%s)", pp->printer, file);
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
if (noresponse()) { /* file sent had bad data in it */
|
1997-10-06 03:58:48 +00:00
|
|
|
if (strchr(file, '/') == NULL)
|
|
|
|
(void) unlink(file);
|
2000-11-06 04:37:56 +00:00
|
|
|
return (0);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
ack();
|
2000-11-06 04:37:56 +00:00
|
|
|
return (1);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-06-12 16:38:20 +00:00
|
|
|
noresponse(void)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
char resp;
|
|
|
|
|
2001-07-23 00:15:37 +00:00
|
|
|
if (read(STDOUT_FILENO, &resp, (size_t)1) != 1) {
|
2000-11-06 04:37:56 +00:00
|
|
|
frecverr("lost connection in noresponse()");
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
if (resp == '\0')
|
|
|
|
return(0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to see if there is enough space on the disk for size bytes.
|
|
|
|
* 1 == OK, 0 == Not OK.
|
|
|
|
*/
|
|
|
|
static int
|
2001-06-12 16:38:20 +00:00
|
|
|
chksize(int size)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
2008-09-01 12:32:40 +00:00
|
|
|
int64_t spacefree;
|
1994-05-26 05:23:31 +00:00
|
|
|
struct statfs sfb;
|
|
|
|
|
|
|
|
if (statfs(".", &sfb) < 0) {
|
|
|
|
syslog(LOG_ERR, "%s: %m", "statfs(\".\")");
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
spacefree = sfb.f_bavail * (sfb.f_bsize / 512);
|
|
|
|
size = (size + 511) / 512;
|
|
|
|
if (minfree + size > spacefree)
|
|
|
|
return(0);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-06-12 16:38:20 +00:00
|
|
|
read_number(const char *fn)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
char lin[80];
|
|
|
|
register FILE *fp;
|
|
|
|
|
|
|
|
if ((fp = fopen(fn, "r")) == NULL)
|
|
|
|
return (0);
|
2007-03-06 09:32:41 +00:00
|
|
|
if (fgets(lin, sizeof(lin), fp) == NULL) {
|
1994-05-26 05:23:31 +00:00
|
|
|
fclose(fp);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
return (atoi(lin));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove all the files associated with the current job being transfered.
|
|
|
|
*/
|
|
|
|
static void
|
2001-06-12 16:38:20 +00:00
|
|
|
rcleanup(int signo __unused)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
1997-10-06 03:58:48 +00:00
|
|
|
if (tfname[0] && strchr(tfname, '/') == NULL)
|
1994-05-26 05:23:31 +00:00
|
|
|
(void) unlink(tfname);
|
1997-10-06 03:58:48 +00:00
|
|
|
if (dfname[0] && strchr(dfname, '/') == NULL) {
|
1994-05-26 05:23:31 +00:00
|
|
|
do {
|
|
|
|
do
|
|
|
|
(void) unlink(dfname);
|
|
|
|
while (dfname[2]-- != 'A');
|
|
|
|
dfname[2] = 'z';
|
|
|
|
} while (dfname[0]-- != 'd');
|
1997-10-06 03:58:48 +00:00
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
dfname[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
frecverr(const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, msg);
|
2001-06-15 22:03:07 +00:00
|
|
|
syslog(LOG_ERR, "Error receiving job from %s:", from_host);
|
1994-05-26 05:23:31 +00:00
|
|
|
vsyslog(LOG_ERR, msg, ap);
|
|
|
|
va_end(ap);
|
2000-11-05 02:24:20 +00:00
|
|
|
/*
|
2000-11-14 22:08:52 +00:00
|
|
|
* rcleanup is not called until AFTER logging the error message,
|
|
|
|
* because rcleanup will zap some variables which may have been
|
|
|
|
* supplied as parameters for that msg...
|
2000-11-05 02:24:20 +00:00
|
|
|
*/
|
|
|
|
rcleanup(0);
|
|
|
|
/*
|
|
|
|
* Add a minimal delay before returning the final error code to
|
|
|
|
* the sending host. This just in case that machine responds
|
|
|
|
* this error by INSTANTLY retrying (and instantly re-failing...).
|
|
|
|
* It would be stupid of the sending host to do that, but if there
|
|
|
|
* was a broken implementation which did it, the result might be
|
|
|
|
* obscure performance problems and a flood of syslog messages on
|
|
|
|
* the receiving host.
|
|
|
|
*/
|
|
|
|
sleep(2); /* a paranoid throttling measure */
|
1994-05-26 05:23:31 +00:00
|
|
|
putchar('\1'); /* return error code */
|
|
|
|
exit(1);
|
|
|
|
}
|