summaryrefslogtreecommitdiff
path: root/usr.sbin/lpr
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r--usr.sbin/lpr/lpc/cmds.c11
-rw-r--r--usr.sbin/lpr/lpd/lpd.c12
-rw-r--r--usr.sbin/lpr/lpd/printjob.c36
-rw-r--r--usr.sbin/lpr/lpd/recvjob.c2
-rw-r--r--usr.sbin/lpr/lpr/lpr.c8
-rw-r--r--usr.sbin/lpr/pac/pac.c6
6 files changed, 41 insertions, 34 deletions
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index 512d5c50005..a03238d72ca 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -181,9 +181,12 @@ abortpr(dis)
goto out;
}
(void) fclose(fp);
- if (kill(pid = atoi(line), SIGTERM) < 0)
- printf("\tWarning: daemon (pid %d) not killed\n", pid);
- else
+ if (kill(pid = atoi(line), SIGTERM) < 0) {
+ if (errno == ESRCH)
+ printf("\tno daemon to abort\n");
+ else
+ printf("\tWarning: daemon (pid %d) not killed\n", pid);
+ } else
printf("\tdaemon (pid %d) killed\n", pid);
out:
seteuid(uid);
@@ -1051,7 +1054,7 @@ doarg(job)
* Look for a job item consisting of system name, colon, number
* (example: ucbarpa:114)
*/
- if ((cp = index(job, ':')) != NULL) {
+ if ((cp = strchr(job, ':')) != NULL) {
machine = job;
*cp++ = '\0';
job = cp;
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 973346682a6..a9780fe2285 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpd.c,v 1.10 1996/10/26 12:33:41 deraadt Exp $ */
+/* $OpenBSD: lpd.c,v 1.11 1996/11/03 23:24:08 millert Exp $ */
/* $NetBSD: lpd.c,v 1.7 1996/04/24 14:54:06 mrg Exp $ */
/*
@@ -126,7 +126,11 @@ main(argc, argv)
uid = getuid();
options = 0;
gethostname(host, sizeof(host));
- name = argv[0];
+
+ if (euid != 0) {
+ fprintf(stderr,"lpd: must run as root\n");
+ exit(1);
+ }
while (--argc > 0) {
argv++;
@@ -289,9 +293,9 @@ static void
reapchild(signo)
int signo;
{
- union wait status;
+ int status;
- while (wait3((int *)&status, WNOHANG, 0) > 0)
+ while (waitpid((pid_t)-1, &status, WNOHANG) > 0)
;
}
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 21370f43bd9..5c15e12b6fb 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printjob.c,v 1.9 1996/10/25 19:38:23 deraadt Exp $ */
+/* $OpenBSD: printjob.c,v 1.10 1996/11/03 23:24:10 millert Exp $ */
/* $NetBSD: printjob.c,v 1.9.4.3 1996/07/12 22:31:39 jtc Exp $ */
/*
@@ -266,7 +266,7 @@ again:
syslog(LOG_WARNING, "%s: job could not be %s (%s)", printer,
remote ? "sent to remote host" : "printed", q->q_name);
if (i == REPRINT) {
- /* insure we don't attempt this job again */
+ /* ensure we don't attempt this job again */
(void) unlink(q->q_name);
q->q_name[0] = 'd';
(void) unlink(q->q_name);
@@ -574,7 +574,7 @@ print(format, file)
dup2(fi, 0); /* file is stdin */
dup2(p[1], 1); /* pipe is stdout */
closelog();
- for (n = 3, nofile = getdtablesize(); n < nofile; n++)
+ for (n = 3, nofile = sysconf(_SC_OPEN_MAX); n < nofile; n++)
(void) close(n);
execl(_PATH_PR, "pr", width, length,
"-h", *title ? title : " ", 0);
@@ -663,7 +663,7 @@ print(format, file)
printer, format);
return(ERROR);
}
- if ((av[0] = rindex(prog, '/')) != NULL)
+ if ((av[0] = strrchr(prog, '/')) != NULL)
av[0]++;
else
av[0] = prog;
@@ -676,14 +676,14 @@ print(format, file)
fo = pfd;
if (ofilter > 0) { /* stop output filter */
write(ofd, "\031\1", 2);
- while ((pid =
- wait3((int *)&status, WUNTRACED, 0)) > 0 && pid != ofilter)
+ while ((pid = waitpid((pid_t)-1, (int *)&status, WUNTRACED)) > 0
+ && pid != ofilter)
;
if (status.w_stopval != WSTOPPED) {
(void) close(fi);
syslog(LOG_WARNING,
- "%s: output filter died (retcode=%d termsig=%d)",
- printer, status.w_retcode, status.w_termsig);
+ "%s: output filter died (retcode=%d termsig=%d)",
+ printer, status.w_retcode, status.w_termsig);
return(REPRINT);
}
stopped++;
@@ -696,7 +696,7 @@ start:
if (n >= 0)
dup2(n, 2);
closelog();
- for (n = 3, nofile = getdtablesize(); n < nofile; n++)
+ for (n = 3, nofile = sysconf(_SC_OPEN_MAX); n < nofile; n++)
(void) close(n);
execv(prog, av);
syslog(LOG_ERR, "cannot execv %s", prog);
@@ -889,9 +889,6 @@ sendfile(type, file)
}
}
-
-
-
(void) close(f);
if (sizerr) {
syslog(LOG_INFO, "%s: %s: changed size", printer, file);
@@ -1057,9 +1054,9 @@ sendmail(user, bombed)
if ((s = dofork(DORETURN)) == 0) { /* child */
dup2(p[0], 0);
closelog();
- for (i = 3, nofile = getdtablesize(); i < nofile; i++)
+ for (i = 3, nofile = sysconf(_SC_OPEN_MAX); i < nofile; i++)
(void) close(i);
- if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
+ if ((cp = strrchr(_PATH_SENDMAIL, '/')) != NULL)
cp++;
else
cp = _PATH_SENDMAIL;
@@ -1266,7 +1263,7 @@ openpr()
char *cp;
if (!remote && *LP) {
- if (cp = index(LP, '@'))
+ if (cp = strchr(LP, '@'))
opennet(cp);
else
opentty();
@@ -1290,9 +1287,9 @@ openpr()
dup2(p[0], 0); /* pipe is std in */
dup2(pfd, 1); /* printer is std out */
closelog();
- for (i = 3, nofile = getdtablesize(); i < nofile; i++)
+ for (i = 3, nofile = sysconf(_SC_OPEN_MAX); i < nofile; i++)
(void) close(i);
- if ((cp = rindex(OF, '/')) == NULL)
+ if ((cp = strrchr(OF, '/')) == NULL)
cp = OF;
else
cp++;
@@ -1494,7 +1491,10 @@ setty()
p = strdup(MS);
ap = argv;
while ((val = strsep(&p, " \t,")) != NULL) {
- *ap++ = strdup(val);
+ if ((*ap++ = strdup(val)) == NULL) {
+ syslog(LOG_ERR, "%s: strdup: %m", printer);
+ exit(1);
+ }
}
for (; *argv; ++argv) {
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index ea2128cd31e..9af9e8bb89c 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -203,7 +203,7 @@ readjob()
}
(void) strncpy(dfname, cp, sizeof dfname-1);
dfname[sizeof dfname-1] = '\0';
- if (index(dfname, '/'))
+ if (strchr(dfname, '/'))
frecverr("readjob: %s: illegal path name",
dfname);
(void) readfile(dfname, size);
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c
index b9626c435f8..ee2986aadcd 100644
--- a/usr.sbin/lpr/lpr/lpr.c
+++ b/usr.sbin/lpr/lpr/lpr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpr.c,v 1.9 1996/08/13 18:13:29 millert Exp $ */
+/* $OpenBSD: lpr.c,v 1.10 1996/11/03 23:24:12 millert Exp $ */
/* $NetBSD: lpr.c,v 1.10 1996/03/21 18:12:25 jtc Exp $ */
/*
@@ -320,7 +320,7 @@ main(argc, argv)
if (argc == 1)
jobname = "stdin";
else
- jobname = (arg = rindex(argv[1], '/')) ? arg+1 : argv[1];
+ jobname = (arg = strrchr(argv[1], '/')) ? arg+1 : argv[1];
}
card('J', jobname);
card('C', class);
@@ -474,7 +474,7 @@ linked(file)
continue;
case '.':
if (file[2] == '/') {
- if ((cp = rindex(buf, '/')) != NULL)
+ if ((cp = strrchr(buf, '/')) != NULL)
*cp = '\0';
file += 3;
continue;
@@ -621,7 +621,7 @@ test(file)
}
(void) close(fd);
if (rflag) {
- if ((cp = rindex(file, '/')) == NULL) {
+ if ((cp = strrchr(file, '/')) == NULL) {
if (access(".", 2) == 0)
return(1);
} else {
diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c
index e1a002102f0..b40d7000daf 100644
--- a/usr.sbin/lpr/pac/pac.c
+++ b/usr.sbin/lpr/pac/pac.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pac.c,v 1.6 1996/05/15 13:41:59 pefo Exp $ */
+/* $OpenBSD: pac.c,v 1.7 1996/11/03 23:24:13 millert Exp $ */
/* $NetBSD: pac.c,v 1.7 1996/03/21 18:21:20 jtc Exp $ */
/*
@@ -229,8 +229,8 @@ account(acct)
;
ic = atoi(cp2);
*cp2 = '\0';
- if (mflag && index(cp, ':'))
- cp = index(cp, ':') + 1;
+ if (mflag && strchr(cp, ':'))
+ cp = strchr(cp, ':') + 1;
hp = lookup(cp);
if (hp == NULL) {
if (!allflag)