summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/lprm
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1997-12-02 20:46:22 +0000
committerwollman <wollman@FreeBSD.org>1997-12-02 20:46:22 +0000
commitbf21e6b4e0e85ae08cb5d1f2335da248f52e2d26 (patch)
tree041fd28f30eaadf848820e6ceed6899636d31478 /usr.sbin/lpr/lprm
parentfa82bf4e17d3b6422eb922374e04631e08af93ef (diff)
downloadFreeBSD-src-bf21e6b4e0e85ae08cb5d1f2335da248f52e2d26.zip
FreeBSD-src-bf21e6b4e0e85ae08cb5d1f2335da248f52e2d26.tar.gz
Mega lpd/lpd upgrade, part I:
- Get rid of a lot of the static variables which were shared by many routines and programs in the suite. - Create an abstract interface to the printcap database, so that other retrieval and iteration mechanisms could be developed (e.g., YP, Hesiod, or automatic retrieval from a trusted server). - Give each capability a human-readable name in addition to the historic two-character one. - Otherwise generally clean up a lot of dark corners. Many still remain. - When submitting jobs, use the official login name record (from getlogin()) if there is one, rather than reverse-mapping the uid. More to come...
Diffstat (limited to 'usr.sbin/lpr/lprm')
-rw-r--r--usr.sbin/lpr/lprm/Makefile8
-rw-r--r--usr.sbin/lpr/lprm/lprm.c34
2 files changed, 28 insertions, 14 deletions
diff --git a/usr.sbin/lpr/lprm/Makefile b/usr.sbin/lpr/lprm/Makefile
index 77c57e5..cb597c5 100644
--- a/usr.sbin/lpr/lprm/Makefile
+++ b/usr.sbin/lpr/lprm/Makefile
@@ -1,13 +1,15 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
+# From: @(#)Makefile 8.1 (Berkeley) 6/6/93
+# $Id$
PROG= lprm
-CFLAGS+=-I${.CURDIR}/../common_source
-SRCS= lprm.c rmjob.c startdaemon.c common.c
+CFLAGS+=-I${.CURDIR}/../common_source -Wall -Werror
+SRCS= lprm.c
BINOWN= root
BINGRP= daemon
BINMODE=6555
BINDIR= /usr/bin
MAN1= lprm.1
.PATH: ${.CURDIR}/../common_source
+LDADD= -L${.OBJDIR}/../common_source -llpr
.include <bsd.prog.mk>
diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c
index e124744..676869a 100644
--- a/usr.sbin/lpr/lprm/lprm.c
+++ b/usr.sbin/lpr/lprm/lprm.c
@@ -43,7 +43,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: lprm.c,v 1.3 1997/09/24 06:48:17 charnier Exp $";
#endif /* not lint */
/*
@@ -89,21 +89,33 @@ main(argc, argv)
int argc;
char *argv[];
{
- register char *arg;
+ char *arg, *printer;
struct passwd *p;
+ static char root[] = "root";
+ printer = NULL;
uid = getuid();
euid = geteuid();
seteuid(uid); /* be safe */
name = argv[0];
gethostname(host, sizeof(host));
openlog("lpd", 0, LOG_LPR);
- if ((p = getpwuid(getuid())) == NULL)
- fatal("Who are you?");
- if (strlen(p->pw_name) >= sizeof(luser))
- fatal("Your name is too long");
- strcpy(luser, p->pw_name);
- person = luser;
+
+ /*
+ * Bogus code later checks for string equality between
+ * `person' and "root", so if we are root, better make sure
+ * that code will succeed.
+ */
+ if (getuid() == 0) {
+ person = root;
+ } else if ((person = getlogin()) == NULL) {
+ if ((p = getpwuid(getuid())) == NULL)
+ fatal(0, "Who are you?");
+ if (strlen(p->pw_name) >= sizeof(luser))
+ fatal(0, "Your name is too long");
+ strcpy(luser, p->pw_name);
+ person = luser;
+ }
while (--argc) {
if ((arg = *++argv)[0] == '-')
switch (arg[1]) {
@@ -128,11 +140,11 @@ main(argc, argv)
usage();
if (isdigit(arg[0])) {
if (requests >= MAXREQUESTS)
- fatal("Too many requests");
+ fatal(0, "Too many requests");
requ[requests++] = atoi(arg);
} else {
if (users >= MAXUSERS)
- fatal("Too many users");
+ fatal(0, "Too many users");
user[users++] = arg;
}
}
@@ -140,7 +152,7 @@ main(argc, argv)
if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
printer = DEFLP;
- rmjob();
+ rmjob(printer);
exit(0);
}
OpenPOWER on IntegriCloud