SCCS-vsn: usr.sbin/lpr/lpr/lpr.c 4.4
SCCS-vsn: usr.sbin/lpr/Makefile 1.4
SCCS-vsn: usr.sbin/lpr/common_source/lp.local.h 1.3
-lpd: lpd.o lpdchar.o printcap.o
- ${CC} -o lpd ${LDFLAGS} lpd.o lpdchar.o printcap.o
+lpd: lpd.o lpdchar.o printcap.o getqueue.o
+ ${CC} -o lpd ${LDFLAGS} lpd.o lpdchar.o printcap.o getqueue.o
lpr: lpr.o printcap.o
${CC} -o lpr ${LDFLAGS} lpr.o printcap.o
lpr: lpr.o printcap.o
${CC} -o lpr ${LDFLAGS} lpr.o printcap.o
-sq: sq.o printcap.o
- ${CC} -o sq ${LDFLAGS} sq.o -ltermcap printcap.o
+sq: sq.o printcap.o getqueue.o
+ ${CC} -o sq ${LDFLAGS} sq.o -ltermcap printcap.o getqueue.o
-dq: dq.o printcap.o
- ${CC} -o dq ${LDFLAGS} dq.o printcap.o
+dq: dq.o printcap.o scandir.o
+ ${CC} -o dq ${LDFLAGS} dq.o printcap.o scandir.o
lpdrestart: lpdrestart.o
${CC} -o lpdrestart ${LDFLAGS} lpdrestart.o
lpdrestart: lpdrestart.o
${CC} -o lpdrestart ${LDFLAGS} lpdrestart.o
${CC} -o necf ${CFLAGS} ${LDFLAGS} necf.c
lpr.o lpd.o sq.o dq.o lpdrestart.o: lp.local.h
${CC} -o necf ${CFLAGS} ${LDFLAGS} necf.c
lpr.o lpd.o sq.o dq.o lpdrestart.o: lp.local.h
+lpd.o sq.o getqueue.o: getqueue.h
install: all
cp lpd ${LIBDIR}/lpd
install: all
cp lpd ${LIBDIR}/lpd
- cp sq ${BINDIR}/sq
- cp dq ${BINDIR}/dq
+ cp sq ${BINDIR}/lpq
+ cp dq ${BINDIR}/lprm
cp lpr ${BINDIR}/lpr
# rm -f ${BINDIR}/opr ${BINDIR}/print
# ln ${BINDIR}/lpr ${BINDIR}/print
# ln ${BINDIR}/lpr ${BINDIR}/opr
cp lpr ${BINDIR}/lpr
# rm -f ${BINDIR}/opr ${BINDIR}/print
# ln ${BINDIR}/lpr ${BINDIR}/print
# ln ${BINDIR}/lpr ${BINDIR}/opr
- chown ${ROOT} ${BINDIR}/lpr ${BINDIR}/sq
- chown ${DAEMON} ${BINDIR}/dq ${LIBDIR}/lpd
- chgrp ${SPGRP} ${LIBDIR}/lpd ${BINDIR}/lpr ${BINDIR}/dq ${BINDIR}/sq
- chmod 6711 ${LIBDIR}/lpd ${BINDIR}/lpr ${BINDIR}/dq
- chmod 2711 ${BINDIR}/sq
- chmod 775 ${SPOOLDIR}
- chgrp ${SPGRP} ${SPOOLDIR}
+ chown ${ROOT} ${BINDIR}/lpr
+ chown ${DAEMON} $(BINDIR)/lpq ${BINDIR}/lprm ${LIBDIR}/lpd
+ chgrp ${SPGRP} ${LIBDIR}/lpd ${BINDIR}/lpr ${BINDIR}/lpq ${BINDIR}/lprm
+ chmod 6711 ${LIBDIR}/lpd ${BINDIR}/lpr ${BINDIR}/lprm
+ chmod 2711 ${BINDIR}/lpq
chown ${DAEMON} ${SPOOLDIR}
chown ${DAEMON} ${SPOOLDIR}
+ chgrp ${SPGRP} ${SPOOLDIR}
+ chmod 775 ${SPOOLDIR}
clean:
rm -f laf dq sq lpd lpr necf lpf *.o
clean:
rm -f laf dq sq lpd lpr necf lpf *.o
-/* lp.local.h 1.2 81/09/04 */
+/* lp.local.h 1.3 82/12/02 */
/*
* Possibly, local parameters to the spooling system
*/
/*
* Possibly, local parameters to the spooling system
*/
#define DEFFF "\f"
#define DEFDAEMON "/usr/lib/lpd"
#define DEFDEVLP "/dev/lp"
#define DEFFF "\f"
#define DEFDAEMON "/usr/lib/lpd"
#define DEFDEVLP "/dev/lp"
-#define DEFUID 1
-
-/*
- * The system name is normally imported from <whoami.h>,
- * change it here if you want someting special on the JOB line
- * of the burst page.
- */
-
-#ifdef SYTEK
-# define SYSTEM_NAME "Sytek VAX/UNIX"
-#else
-#include <whoami.h>
-
-# define SYSTEM_NAME sysname
-#endif
/*
* Some utilities used by lpd
/*
* Some utilities used by lpd
char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
-/* lpr.c 4.3 81/05/19 */
+/* lpr.c 4.4 82/12/02 */
/*
* lpr -- off line print
* also known as print
/*
* lpr -- off line print
* also known as print
* Multiple printer scheme using info from printer data base:
*
* DN who to invoke to print stuff
* Multiple printer scheme using info from printer data base:
*
* DN who to invoke to print stuff
- * SA rectory used as spool queue
+ * SA directory used as spool queue
*
* daemon identifies what printer it should use (in the case of the
* same code being shared) by inspecting its argv[1].
*
* daemon identifies what printer it should use (in the case of the
* same code being shared) by inspecting its argv[1].
int user; /* user id */
int spgroup; /* daemon's group for creating spool files */
char *title; /* pr'ing title */
int user; /* user id */
int spgroup; /* daemon's group for creating spool files */
char *title; /* pr'ing title */
-char *class = SYSTEM_NAME; /* class title on header page */
+char classbuf[32]; /* class title on header page */
+char *class = classbuf;
char *jobname; /* job name on header page */
char *name; /* program name */
char *printer; /* printer name */
char *jobname; /* job name on header page */
char *name; /* program name */
char *printer; /* printer name */
char *getenv();
char *rindex();
char *getenv();
char *rindex();
-int argc;
-char *argv[];
+ int argc;
+ char *argv[];
{
register char *arg;
int i, c, f, flag, out();
{
register char *arg;
int i, c, f, flag, out();
* access files and printer. Users can't get to anything
* w/o help of sq and dq programs.
*/
* access files and printer. Users can't get to anything
* w/o help of sq and dq programs.
*/
+ gethostname(classbuf, sizeof (classbuf));
user = getuid();
spgroup = getegid();
user = getuid();
spgroup = getegid();
- if(signal(SIGHUP, SIG_IGN) != SIG_IGN)
+ if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
- if(signal(SIGINT, SIG_IGN) != SIG_IGN)
+ if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- if(signal(SIGQUIT, SIG_IGN) != SIG_IGN)
+ if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
- if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
+ if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
signal(SIGTERM, out);
flag = 0;
if ((printer = getenv("PRINTER")) == NULL)
signal(SIGTERM, out);
flag = 0;
if ((printer = getenv("PRINTER")) == NULL)
inchar = f-7;
tff = nfile(tfname);
if (jflag == 0) {
inchar = f-7;
tff = nfile(tfname);
if (jflag == 0) {
jobname = &dfname[f-10];
else
jobname = argv[1];
}
ident();
jobname = &dfname[f-10];
else
jobname = argv[1];
}
ident();
- else while(--argc) {
- if(test(arg = *++argv) == -1) /* file reasonable */
+ else while (--argc) {
+ if (test(arg = *++argv) == -1) /* file reasonable */
continue;
if (flag == '+') /* force copy flag */
goto cf;
if (stat(arg, &sbuf) < 0) {
continue;
if (flag == '+') /* force copy flag */
goto cf;
if (stat(arg, &sbuf) < 0) {
- if((sbuf.st_mode&04) == 0)
+ if ((sbuf.st_mode&04) == 0)
- if(*arg == '/' && flag != '-') {
- for(i=0;i<ncopies;i++) {
+ if (*arg == '/' && flag != '-') {
+ for (i=0;i<ncopies;i++) {
if (prflag) {
if (title)
card('H', title);
if (prflag) {
if (title)
card('H', title);
- if(link(arg, lfname) < 0)
+ if (link(arg, lfname) < 0)
- for(i=0;i<ncopies;i++) {
+ for (i=0;i<ncopies;i++) {
if (prflag) {
card('H', title ? title : arg);
card('R', lfname);
if (prflag) {
card('H', title ? title : arg);
card('R', lfname);
- if((f = open(arg, 0)) < 0) {
+ if ((f = open(arg, 0)) < 0) {
printf("%s: cannot open %s\n", name, arg);
continue;
}
printf("%s: cannot open %s\n", name, arg);
continue;
}
- if(flag == '-' && unlink(arg))
+ if (flag == '-' && unlink(arg))
printf("%s: cannot remove %s\n", name, arg);
}
printf("%s: cannot remove %s\n", name, arg);
}
- if(link(tfname, dfname) < 0) {
+ if (link(tfname, dfname) < 0) {
printf("%s: cannot rename %s\n", name, dfname);
tfname[inchar]++;
out();
printf("%s: cannot rename %s\n", name, dfname);
tfname[inchar]++;
out();
printf("job queued, but printer down\n");
exit(0);
}
printf("job queued, but printer down\n");
exit(0);
}
- for(f = 0; f < NOFILE; close(f++))
+ for (f = 0; f < NOFILE; close(f++))
;
open("/dev/tty", 0);
open("/dev/tty", 1);
;
open("/dev/tty", 0);
open("/dev/tty", 1);
{
int ff, i, nr, nc;
char buf[BUFSIZ];
{
int ff, i, nr, nc;
char buf[BUFSIZ];
- for(i=0;i<ncopies;i++) {
+ for (i=0;i<ncopies;i++) {
if (prflag) {
card('H', title ? title : n);
card('R', cfname);
if (prflag) {
card('H', title ? title : n);
card('R', cfname);
card('U', cfname);
ff = nfile(cfname);
nr = nc = 0;
card('U', cfname);
ff = nfile(cfname);
nr = nc = 0;
- while((i = read(f, buf, BUFSIZ)) > 0) {
+ while ((i = read(f, buf, BUFSIZ)) > 0) {
if (write(ff, buf, i) != i) {
printf("%s: %s: temp file write error\n", name, n);
break;
}
nc += i;
if (write(ff, buf, i) != i) {
printf("%s: %s: temp file write error\n", name, n);
break;
}
nc += i;
printf("%s: %s: copy file is too large\n", name, n);
break;
}
printf("%s: %s: copy file is too large\n", name, n);
break;
}
{
char buf[BUFSIZ];
register char *p1 = buf;
int col = 0;
*p1++ = c;
{
char buf[BUFSIZ];
register char *p1 = buf;
int col = 0;
*p1++ = c;
- while((c = *p2++) != '\0') {
+ while ((c = *p2++) != '\0') {
+ int oldumask = umask(022); /* should block signals */
- if((f = creat(n, FILMOD)) < 0) {
+ f = creat(n, FILMOD);
+ (void) umask(oldumask);
+ if (f < 0) {
printf("%s: cannot create %s\n", name, n);
out();
}
printf("%s: cannot create %s\n", name, n);
out();
}
signal(SIGTERM, SIG_IGN);
i = inchar;
if (tfname)
signal(SIGTERM, SIG_IGN);
i = inchar;
if (tfname)
- while(tfname[i] != 'A') {
+ while (tfname[i] != 'A') {
tfname[i]--;
unlink(tfname);
}
if (cfname)
tfname[i]--;
unlink(tfname);
}
if (cfname)
- while(cfname[i] != 'A') {
+ while (cfname[i] != 'A') {
cfname[i]--;
unlink(cfname);
}
if (lfname)
cfname[i]--;
unlink(cfname);
}
if (lfname)
- while(lfname[i] != 'A') {
+ while (lfname[i] != 'A') {
lfname[i]--;
unlink(lfname);
}
if (dfname)
lfname[i]--;
unlink(lfname);
}
if (dfname)
- while(dfname[i] != 'A') {
+ while (dfname[i] != 'A') {
dfname[i]--;
unlink(dfname);
}
dfname[i]--;
unlink(dfname);
}
{
struct exec buf;
struct stat mbuf;
{
struct exec buf;
struct stat mbuf;
if (access(file, 4) < 0) {
printf("%s: cannot access %s\n", name, file);
if (access(file, 4) < 0) {
printf("%s: cannot access %s\n", name, file);
- if(stat(file, &mbuf) < 0) {
+ if (stat(file, &mbuf) < 0) {
printf("%s: cannot stat %s\n", name, file);
return (-1);
}
if ((mbuf.st_mode&S_IFMT) == S_IFDIR) {
printf("%s: %s is a directory\n", name, file);
printf("%s: cannot stat %s\n", name, file);
return (-1);
}
if ((mbuf.st_mode&S_IFMT) == S_IFDIR) {
printf("%s: %s is a directory\n", name, file);
- if((fd = open(file, 0)) < 0) {
+ if ((fd = open(file, 0)) < 0) {
printf("%s: cannot open %s\n", name, file);
printf("%s: cannot open %s\n", name, file);
}
if (read(fd, &buf, sizeof(buf)) == sizeof(buf))
switch(buf.a_magic) {
}
if (read(fd, &buf, sizeof(buf)) == sizeof(buf))
switch(buf.a_magic) {
error1:
printf(" and is unprintable\n");
close(fd);
error1:
printf(" and is unprintable\n");
close(fd);
{
static char b[10] = "########";
register char *p;
{
static char b[10] = "########";
register char *p;
do
*p-- = i%10 + '0';
while (i /= 10);
do
*p-- = i%10 + '0';
while (i /= 10);
* return pointer to daemon structure
*/
chkprinter(s)
* return pointer to daemon structure
*/
chkprinter(s)
{
static char buf[BUFSIZ/2];
char b[BUFSIZ];
{
static char buf[BUFSIZ/2];
char b[BUFSIZ];
fprintf(stderr, "%s: can't open printer description file\n", name);
exit(3);
} else if (stat == 0)
fprintf(stderr, "%s: can't open printer description file\n", name);
exit(3);
} else if (stat == 0)
if ((DN = pgetstr("dn", &bp)) == NULL)
DN = DEFDAEMON;
if ((LP = pgetstr("lp", &bp)) == NULL)
if ((DN = pgetstr("dn", &bp)) == NULL)
DN = DEFDAEMON;
if ((LP = pgetstr("lp", &bp)) == NULL)
SA = DEFSPOOL;
if ((MX = pgetnum("mx")) < 0)
MX = DEFMX;
SA = DEFSPOOL;
if ((MX = pgetnum("mx")) < 0)
MX = DEFMX;
*/
char *
mktmp(id, pid, n)
*/
char *
mktmp(id, pid, n)
exit(1);
}
sprintf(s, "%s/%sA%05d", SA, id, pid);
exit(1);
}
sprintf(s, "%s/%sA%05d", SA, id, pid);