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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 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-12-02 20:46:22 +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 */
|
|
|
|
|
|
|
|
#ifndef lint
|
1997-12-02 20:46:22 +00:00
|
|
|
/*
|
1996-05-05 22:40:51 +00:00
|
|
|
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/28/95";
|
1997-12-02 20:46:22 +00:00
|
|
|
*/
|
|
|
|
static const char rcsid[] =
|
1999-08-28 01:35:59 +00:00
|
|
|
"$FreeBSD$";
|
1994-05-26 05:23:31 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* lpc -- line printer control program -- commands:
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/stat.h>
|
1996-05-05 22:40:51 +00:00
|
|
|
#include <sys/file.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "lp.h"
|
|
|
|
#include "lp.local.h"
|
|
|
|
#include "lpc.h"
|
|
|
|
#include "extern.h"
|
|
|
|
#include "pathnames.h"
|
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
static void abortpr __P((struct printer *, int));
|
1994-05-26 05:23:31 +00:00
|
|
|
static int doarg __P((char *));
|
|
|
|
static int doselect __P((struct dirent *));
|
1997-12-02 20:46:22 +00:00
|
|
|
static void putmsg __P((struct printer *, int, char **));
|
1994-05-26 05:23:31 +00:00
|
|
|
static int sortq __P((const void *, const void *));
|
1997-12-02 20:46:22 +00:00
|
|
|
static void startpr __P((struct printer *, int));
|
1994-05-26 05:23:31 +00:00
|
|
|
static int touch __P((struct queue *));
|
|
|
|
static void unlinkf __P((char *));
|
1997-12-02 20:46:22 +00:00
|
|
|
static void upstat __P((struct printer *, char *));
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
1997-12-02 20:46:22 +00:00
|
|
|
* generic framework for commands which operate on all or a specified
|
|
|
|
* set of printers
|
1994-05-26 05:23:31 +00:00
|
|
|
*/
|
|
|
|
void
|
1997-12-02 20:46:22 +00:00
|
|
|
generic(doit, argc, argv)
|
|
|
|
void (*doit) __P((struct printer *));
|
1994-05-26 05:23:31 +00:00
|
|
|
int argc;
|
|
|
|
char *argv[];
|
|
|
|
{
|
1997-12-02 20:46:22 +00:00
|
|
|
int status, more;
|
|
|
|
struct printer myprinter, *pp = &myprinter;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
if (argc == 1) {
|
1997-12-02 20:46:22 +00:00
|
|
|
printf("Usage: %s {all | printer ...}\n", argv[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (argc == 2 && strcmp(argv[1], "all") == 0) {
|
|
|
|
more = firstprinter(pp, &status);
|
|
|
|
if (status)
|
|
|
|
goto looperr;
|
|
|
|
while (more) {
|
|
|
|
(*doit)(pp);
|
|
|
|
do {
|
|
|
|
more = nextprinter(pp, &status);
|
|
|
|
looperr:
|
|
|
|
switch (status) {
|
|
|
|
case PCAPERR_TCOPEN:
|
|
|
|
printf("warning: %s: unresolved "
|
|
|
|
"tc= reference(s) ",
|
|
|
|
pp->printer);
|
|
|
|
case PCAPERR_SUCCESS:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fatal(pp, pcaperr(status));
|
|
|
|
}
|
|
|
|
} while (more && status);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (--argc) {
|
1997-12-02 20:46:22 +00:00
|
|
|
++argv;
|
|
|
|
init_printer(pp);
|
|
|
|
status = getprintcap(*argv, pp);
|
|
|
|
switch(status) {
|
|
|
|
default:
|
|
|
|
fatal(pp, pcaperr(status));
|
|
|
|
case PCAPERR_NOTFOUND:
|
|
|
|
printf("unknown printer %s\n", *argv);
|
1994-05-26 05:23:31 +00:00
|
|
|
continue;
|
1997-12-02 20:46:22 +00:00
|
|
|
case PCAPERR_TCOPEN:
|
|
|
|
printf("warning: %s: unresolved tc= reference(s)\n",
|
|
|
|
*argv);
|
|
|
|
break;
|
|
|
|
case PCAPERR_SUCCESS:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
(*doit)(pp);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
/*
|
|
|
|
* kill an existing daemon and disable printing.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
doabort(pp)
|
|
|
|
struct printer *pp;
|
|
|
|
{
|
|
|
|
abortpr(pp, 1);
|
|
|
|
}
|
|
|
|
|
1994-05-26 05:23:31 +00:00
|
|
|
static void
|
1997-12-02 20:46:22 +00:00
|
|
|
abortpr(pp, dis)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
int dis;
|
|
|
|
{
|
|
|
|
register FILE *fp;
|
|
|
|
struct stat stbuf;
|
|
|
|
int pid, fd;
|
1997-12-02 20:46:22 +00:00
|
|
|
char lf[MAXPATHLEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
lock_file_name(pp, lf, sizeof lf);
|
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn on the owner execute bit of the lock file to disable printing.
|
|
|
|
*/
|
|
|
|
if (dis) {
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (stat(lf, &stbuf) >= 0) {
|
|
|
|
if (chmod(lf, stbuf.st_mode | LFM_PRINT_DIS) < 0)
|
|
|
|
printf("\tcannot disable printing: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else {
|
1997-12-02 20:46:22 +00:00
|
|
|
upstat(pp, "printing disabled\n");
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tprinting disabled\n");
|
|
|
|
}
|
|
|
|
} else if (errno == ENOENT) {
|
1997-12-02 20:46:22 +00:00
|
|
|
if ((fd = open(lf, O_WRONLY|O_CREAT,
|
|
|
|
LOCK_FILE_MODE | LFM_PRINT_DIS)) < 0)
|
|
|
|
printf("\tcannot create lock file: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else {
|
|
|
|
(void) close(fd);
|
1997-12-02 20:46:22 +00:00
|
|
|
upstat(pp, "printing disabled\n");
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tprinting disabled\n");
|
|
|
|
printf("\tno daemon to abort\n");
|
|
|
|
}
|
1997-07-23 00:49:46 +00:00
|
|
|
goto out;
|
1994-05-26 05:23:31 +00:00
|
|
|
} else {
|
|
|
|
printf("\tcannot stat lock file\n");
|
1997-07-23 00:49:46 +00:00
|
|
|
goto out;
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Kill the current daemon to stop printing now.
|
|
|
|
*/
|
1997-12-02 20:46:22 +00:00
|
|
|
if ((fp = fopen(lf, "r")) == NULL) {
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tcannot open lock file\n");
|
1997-07-23 00:49:46 +00:00
|
|
|
goto out;
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
if (!getline(fp) || flock(fileno(fp), LOCK_SH|LOCK_NB) == 0) {
|
|
|
|
(void) fclose(fp); /* unlocks as well */
|
|
|
|
printf("\tno daemon to abort\n");
|
1997-07-23 00:49:46 +00:00
|
|
|
goto out;
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
(void) fclose(fp);
|
1997-07-23 00:49:46 +00:00
|
|
|
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
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tdaemon (pid %d) killed\n", pid);
|
1997-07-23 00:49:46 +00:00
|
|
|
out:
|
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write a message into the status file.
|
|
|
|
*/
|
|
|
|
static void
|
1997-12-02 20:46:22 +00:00
|
|
|
upstat(pp, msg)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
char *msg;
|
|
|
|
{
|
|
|
|
register int fd;
|
1997-07-29 04:17:19 +00:00
|
|
|
char statfile[MAXPATHLEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
status_file_name(pp, statfile, sizeof statfile);
|
1994-05-26 05:23:31 +00:00
|
|
|
umask(0);
|
1997-12-02 20:46:22 +00:00
|
|
|
fd = open(statfile, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE);
|
|
|
|
if (fd < 0) {
|
|
|
|
printf("\tcannot create status file: %s\n", strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
(void) ftruncate(fd, 0);
|
|
|
|
if (msg == (char *)NULL)
|
|
|
|
(void) write(fd, "\n", 1);
|
|
|
|
else
|
|
|
|
(void) write(fd, msg, strlen(msg));
|
|
|
|
(void) close(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
doselect(d)
|
|
|
|
struct dirent *d;
|
|
|
|
{
|
|
|
|
int c = d->d_name[0];
|
|
|
|
|
|
|
|
if ((c == 't' || c == 'c' || c == 'd') && d->d_name[1] == 'f')
|
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Comparison routine for scandir. Sort by job number and machine, then
|
|
|
|
* by `cf', `tf', or `df', then by the sequence letter A-Z, a-z.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sortq(a, b)
|
|
|
|
const void *a, *b;
|
|
|
|
{
|
|
|
|
struct dirent **d1, **d2;
|
|
|
|
int c1, c2;
|
|
|
|
|
|
|
|
d1 = (struct dirent **)a;
|
|
|
|
d2 = (struct dirent **)b;
|
1996-10-27 03:06:52 +00:00
|
|
|
if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3)))
|
1994-05-26 05:23:31 +00:00
|
|
|
return(c1);
|
|
|
|
c1 = (*d1)->d_name[0];
|
|
|
|
c2 = (*d2)->d_name[0];
|
|
|
|
if (c1 == c2)
|
|
|
|
return((*d1)->d_name[2] - (*d2)->d_name[2]);
|
|
|
|
if (c1 == 'c')
|
|
|
|
return(-1);
|
|
|
|
if (c1 == 'd' || c2 == 'c')
|
|
|
|
return(1);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-12-02 20:46:22 +00:00
|
|
|
* Remove all spool files and temporaries from the spooling area.
|
|
|
|
* Or, perhaps:
|
1994-05-26 05:23:31 +00:00
|
|
|
* Remove incomplete jobs from spooling area.
|
|
|
|
*/
|
1997-12-02 20:46:22 +00:00
|
|
|
void
|
|
|
|
clean(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
register int i, n;
|
|
|
|
register char *cp, *cp1, *lp;
|
|
|
|
struct dirent **queue;
|
|
|
|
int nitems;
|
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
lp = line;
|
|
|
|
cp = pp->spool_dir;
|
|
|
|
while (lp < &line[sizeof(line) - 1]) {
|
|
|
|
if ((*lp++ = *cp++) == 0)
|
|
|
|
break;
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
lp[-1] = '/';
|
|
|
|
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
nitems = scandir(pp->spool_dir, &queue, doselect, sortq);
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
if (nitems < 0) {
|
|
|
|
printf("\tcannot examine spool directory\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (nitems == 0)
|
|
|
|
return;
|
|
|
|
i = 0;
|
|
|
|
do {
|
|
|
|
cp = queue[i]->d_name;
|
|
|
|
if (*cp == 'c') {
|
|
|
|
n = 0;
|
|
|
|
while (i + 1 < nitems) {
|
|
|
|
cp1 = queue[i + 1]->d_name;
|
|
|
|
if (*cp1 != 'd' || strcmp(cp + 3, cp1 + 3))
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
if (n == 0) {
|
1997-02-09 05:04:17 +00:00
|
|
|
strncpy(lp, cp, sizeof(line) - strlen(line) - 1);
|
|
|
|
line[sizeof(line) - 1] = '\0';
|
1994-05-26 05:23:31 +00:00
|
|
|
unlinkf(line);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Must be a df with no cf (otherwise, it would have
|
|
|
|
* been skipped above) or a tf file (which can always
|
|
|
|
* be removed).
|
|
|
|
*/
|
1997-02-09 05:04:17 +00:00
|
|
|
strncpy(lp, cp, sizeof(line) - strlen(line) - 1);
|
|
|
|
line[sizeof(line) - 1] = '\0';
|
1994-05-26 05:23:31 +00:00
|
|
|
unlinkf(line);
|
|
|
|
}
|
|
|
|
} while (++i < nitems);
|
|
|
|
}
|
1997-07-23 00:49:46 +00:00
|
|
|
|
1994-05-26 05:23:31 +00:00
|
|
|
static void
|
|
|
|
unlinkf(name)
|
|
|
|
char *name;
|
|
|
|
{
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1994-05-26 05:23:31 +00:00
|
|
|
if (unlink(name) < 0)
|
|
|
|
printf("\tcannot remove %s\n", name);
|
|
|
|
else
|
|
|
|
printf("\tremoved %s\n", name);
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable queuing to the printer (allow lpr's).
|
|
|
|
*/
|
|
|
|
void
|
1997-12-02 20:46:22 +00:00
|
|
|
enable(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
struct stat stbuf;
|
1997-12-02 20:46:22 +00:00
|
|
|
char lf[MAXPATHLEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
lock_file_name(pp, lf, sizeof lf);
|
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn off the group execute bit of the lock file to enable queuing.
|
|
|
|
*/
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (stat(lf, &stbuf) >= 0) {
|
|
|
|
if (chmod(lf, stbuf.st_mode & ~LFM_QUEUE_DIS) < 0)
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tcannot enable queuing\n");
|
|
|
|
else
|
|
|
|
printf("\tqueuing enabled\n");
|
|
|
|
}
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable queuing.
|
|
|
|
*/
|
|
|
|
void
|
1997-12-02 20:46:22 +00:00
|
|
|
disable(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
register int fd;
|
|
|
|
struct stat stbuf;
|
1997-12-02 20:46:22 +00:00
|
|
|
char lf[MAXPATHLEN];
|
|
|
|
|
|
|
|
lock_file_name(pp, lf, sizeof lf);
|
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* Turn on the group execute bit of the lock file to disable queuing.
|
|
|
|
*/
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (stat(lf, &stbuf) >= 0) {
|
|
|
|
if (chmod(lf, stbuf.st_mode | LFM_QUEUE_DIS) < 0)
|
|
|
|
printf("\tcannot disable queuing: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else
|
|
|
|
printf("\tqueuing disabled\n");
|
|
|
|
} else if (errno == ENOENT) {
|
1997-12-02 20:46:22 +00:00
|
|
|
if ((fd = open(lf, O_WRONLY|O_CREAT,
|
|
|
|
LOCK_FILE_MODE | LFM_QUEUE_DIS)) < 0)
|
|
|
|
printf("\tcannot create lock file: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else {
|
|
|
|
(void) close(fd);
|
|
|
|
printf("\tqueuing disabled\n");
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
printf("\tcannot stat lock file\n");
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable queuing and printing and put a message into the status file
|
|
|
|
* (reason for being down).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
down(argc, argv)
|
|
|
|
int argc;
|
|
|
|
char *argv[];
|
|
|
|
{
|
1997-12-02 20:46:22 +00:00
|
|
|
int status, more;
|
|
|
|
struct printer myprinter, *pp = &myprinter;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
if (argc == 1) {
|
|
|
|
printf("Usage: down {all | printer} [message ...]\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[1], "all")) {
|
1997-12-02 20:46:22 +00:00
|
|
|
more = firstprinter(pp, &status);
|
|
|
|
if (status)
|
|
|
|
goto looperr;
|
|
|
|
while (more) {
|
|
|
|
putmsg(pp, argc - 2, argv + 2);
|
|
|
|
do {
|
|
|
|
more = nextprinter(pp, &status);
|
|
|
|
looperr:
|
|
|
|
switch (status) {
|
|
|
|
case PCAPERR_TCOPEN:
|
|
|
|
printf("warning: %s: unresolved "
|
|
|
|
"tc= reference(s) ",
|
|
|
|
pp->printer);
|
|
|
|
case PCAPERR_SUCCESS:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fatal(pp, pcaperr(status));
|
|
|
|
}
|
|
|
|
} while (more && status);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
1997-12-02 20:46:22 +00:00
|
|
|
init_printer(pp);
|
|
|
|
status = getprintcap(argv[1], pp);
|
|
|
|
switch(status) {
|
|
|
|
default:
|
|
|
|
fatal(pp, pcaperr(status));
|
|
|
|
case PCAPERR_NOTFOUND:
|
|
|
|
printf("unknown printer %s\n", argv[1]);
|
1994-05-26 05:23:31 +00:00
|
|
|
return;
|
1997-12-02 20:46:22 +00:00
|
|
|
case PCAPERR_TCOPEN:
|
|
|
|
printf("warning: %s: unresolved tc= reference(s)", argv[1]);
|
|
|
|
break;
|
|
|
|
case PCAPERR_SUCCESS:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
putmsg(pp, argc - 2, argv + 2);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-12-02 20:46:22 +00:00
|
|
|
putmsg(pp, argc, argv)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
{
|
|
|
|
register int fd;
|
|
|
|
register char *cp1, *cp2;
|
|
|
|
char buf[1024];
|
1997-12-02 20:46:22 +00:00
|
|
|
char file[MAXPATHLEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
struct stat stbuf;
|
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
/*
|
1997-12-02 20:46:22 +00:00
|
|
|
* Turn on the group execute bit of the lock file to disable queuing;
|
1994-05-26 05:23:31 +00:00
|
|
|
* turn on the owner execute bit of the lock file to disable printing.
|
|
|
|
*/
|
1997-12-02 20:46:22 +00:00
|
|
|
lock_file_name(pp, file, sizeof file);
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (stat(file, &stbuf) >= 0) {
|
|
|
|
if (chmod(file, stbuf.st_mode|LFM_PRINT_DIS|LFM_QUEUE_DIS) < 0)
|
|
|
|
printf("\tcannot disable queuing: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else
|
|
|
|
printf("\tprinter and queuing disabled\n");
|
|
|
|
} else if (errno == ENOENT) {
|
1997-12-02 20:46:22 +00:00
|
|
|
if ((fd = open(file, O_WRONLY|O_CREAT,
|
|
|
|
LOCK_FILE_MODE|LFM_PRINT_DIS|LFM_QUEUE_DIS)) < 0)
|
|
|
|
printf("\tcannot create lock file: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else {
|
|
|
|
(void) close(fd);
|
|
|
|
printf("\tprinter and queuing disabled\n");
|
|
|
|
}
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
return;
|
|
|
|
} else
|
|
|
|
printf("\tcannot stat lock file\n");
|
|
|
|
/*
|
|
|
|
* Write the message into the status file.
|
|
|
|
*/
|
1997-12-02 20:46:22 +00:00
|
|
|
status_file_name(pp, file, sizeof file);
|
|
|
|
fd = open(file, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE);
|
|
|
|
if (fd < 0) {
|
|
|
|
printf("\tcannot create status file: %s\n", strerror(errno));
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
return;
|
|
|
|
}
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
(void) ftruncate(fd, 0);
|
|
|
|
if (argc <= 0) {
|
|
|
|
(void) write(fd, "\n", 1);
|
|
|
|
(void) close(fd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cp1 = buf;
|
|
|
|
while (--argc >= 0) {
|
|
|
|
cp2 = *argv++;
|
1997-07-29 04:17:19 +00:00
|
|
|
while ((cp1 - buf) < sizeof(buf) && (*cp1++ = *cp2++))
|
1994-05-26 05:23:31 +00:00
|
|
|
;
|
|
|
|
cp1[-1] = ' ';
|
|
|
|
}
|
|
|
|
cp1[-1] = '\n';
|
|
|
|
*cp1 = '\0';
|
|
|
|
(void) write(fd, buf, strlen(buf));
|
|
|
|
(void) close(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exit lpc
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
quit(argc, argv)
|
|
|
|
int argc;
|
|
|
|
char *argv[];
|
|
|
|
{
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kill and restart the daemon.
|
|
|
|
*/
|
|
|
|
void
|
1997-12-02 20:46:22 +00:00
|
|
|
restart(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
1997-12-02 20:46:22 +00:00
|
|
|
abortpr(pp, 0);
|
|
|
|
startpr(pp, 0);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable printing on the specified printer and startup the daemon.
|
|
|
|
*/
|
|
|
|
void
|
1997-12-02 20:46:22 +00:00
|
|
|
startcmd(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
1997-12-02 20:46:22 +00:00
|
|
|
startpr(pp, 1);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-12-02 20:46:22 +00:00
|
|
|
startpr(pp, enable)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
int enable;
|
|
|
|
{
|
|
|
|
struct stat stbuf;
|
1997-12-02 20:46:22 +00:00
|
|
|
char lf[MAXPATHLEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
lock_file_name(pp, lf, sizeof lf);
|
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
2000-01-24 23:30:38 +00:00
|
|
|
* For enable==1 ('start'), turn off the LFM_PRINT_DIS bit of the
|
|
|
|
* lock file to re-enable printing. For enable==2 ('up'), also
|
|
|
|
* turn off the LFM_QUEUE_DIS bit to re-enable queueing.
|
1994-05-26 05:23:31 +00:00
|
|
|
*/
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (enable && stat(lf, &stbuf) >= 0) {
|
2000-01-24 23:30:38 +00:00
|
|
|
mode_t bits = (enable == 2 ? 0 : LFM_QUEUE_DIS);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (chmod(lf, stbuf.st_mode & (LOCK_FILE_MODE | bits)) < 0)
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tcannot enable printing\n");
|
|
|
|
else
|
|
|
|
printf("\tprinting enabled\n");
|
|
|
|
}
|
1997-12-02 20:46:22 +00:00
|
|
|
if (!startdaemon(pp))
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tcouldn't start daemon\n");
|
|
|
|
else
|
|
|
|
printf("\tdaemon started\n");
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print the status of the printer queue.
|
|
|
|
*/
|
1997-12-02 20:46:22 +00:00
|
|
|
void
|
|
|
|
status(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
struct stat stbuf;
|
|
|
|
register int fd, i;
|
|
|
|
register struct dirent *dp;
|
|
|
|
DIR *dirp;
|
1997-12-02 20:46:22 +00:00
|
|
|
char file[MAXPATHLEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
printf("%s:\n", pp->printer);
|
|
|
|
lock_file_name(pp, file, sizeof file);
|
|
|
|
if (stat(file, &stbuf) >= 0) {
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tqueuing is %s\n",
|
1997-12-02 20:46:22 +00:00
|
|
|
((stbuf.st_mode & LFM_QUEUE_DIS) ? "disabled"
|
|
|
|
: "enabled"));
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tprinting is %s\n",
|
1997-12-02 20:46:22 +00:00
|
|
|
((stbuf.st_mode & LFM_PRINT_DIS) ? "disabled"
|
|
|
|
: "enabled"));
|
1994-05-26 05:23:31 +00:00
|
|
|
} else {
|
|
|
|
printf("\tqueuing is enabled\n");
|
|
|
|
printf("\tprinting is enabled\n");
|
|
|
|
}
|
1997-12-02 20:46:22 +00:00
|
|
|
if ((dirp = opendir(pp->spool_dir)) == NULL) {
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tcannot examine spool directory\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
i = 0;
|
|
|
|
while ((dp = readdir(dirp)) != NULL) {
|
|
|
|
if (*dp->d_name == 'c' && dp->d_name[1] == 'f')
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
closedir(dirp);
|
|
|
|
if (i == 0)
|
1997-12-02 20:46:22 +00:00
|
|
|
printf("\tno entries in spool area\n");
|
1994-05-26 05:23:31 +00:00
|
|
|
else if (i == 1)
|
|
|
|
printf("\t1 entry in spool area\n");
|
|
|
|
else
|
|
|
|
printf("\t%d entries in spool area\n", i);
|
1997-12-02 20:46:22 +00:00
|
|
|
fd = open(file, O_RDONLY);
|
1994-05-26 05:23:31 +00:00
|
|
|
if (fd < 0 || flock(fd, LOCK_SH|LOCK_NB) == 0) {
|
|
|
|
(void) close(fd); /* unlocks as well */
|
1996-10-27 03:06:52 +00:00
|
|
|
printf("\tprinter idle\n");
|
1994-05-26 05:23:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
(void) close(fd);
|
1997-05-13 20:52:31 +00:00
|
|
|
/* print out the contents of the status file, if it exists */
|
1997-12-02 20:46:22 +00:00
|
|
|
status_file_name(pp, file, sizeof file);
|
|
|
|
fd = open(file, O_RDONLY|O_SHLOCK);
|
1994-05-26 05:23:31 +00:00
|
|
|
if (fd >= 0) {
|
1997-05-13 20:52:31 +00:00
|
|
|
(void) fstat(fd, &stbuf);
|
|
|
|
if (stbuf.st_size > 0) {
|
|
|
|
putchar('\t');
|
|
|
|
while ((i = read(fd, line, sizeof(line))) > 0)
|
|
|
|
(void) fwrite(line, 1, i, stdout);
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
(void) close(fd); /* unlocks as well */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop the specified daemon after completing the current job and disable
|
|
|
|
* printing.
|
|
|
|
*/
|
|
|
|
void
|
1997-12-02 20:46:22 +00:00
|
|
|
stop(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
register int fd;
|
|
|
|
struct stat stbuf;
|
1997-12-02 20:46:22 +00:00
|
|
|
char lf[MAXPATHLEN];
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-12-02 20:46:22 +00:00
|
|
|
lock_file_name(pp, lf, sizeof lf);
|
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn on the owner execute bit of the lock file to disable printing.
|
|
|
|
*/
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (stat(lf, &stbuf) >= 0) {
|
|
|
|
if (chmod(lf, stbuf.st_mode | LFM_PRINT_DIS) < 0)
|
|
|
|
printf("\tcannot disable printing: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else {
|
1997-12-02 20:46:22 +00:00
|
|
|
upstat(pp, "printing disabled\n");
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tprinting disabled\n");
|
|
|
|
}
|
|
|
|
} else if (errno == ENOENT) {
|
1997-12-02 20:46:22 +00:00
|
|
|
if ((fd = open(lf, O_WRONLY|O_CREAT,
|
|
|
|
LOCK_FILE_MODE | LFM_PRINT_DIS)) < 0)
|
|
|
|
printf("\tcannot create lock file: %s\n",
|
|
|
|
strerror(errno));
|
1994-05-26 05:23:31 +00:00
|
|
|
else {
|
|
|
|
(void) close(fd);
|
1997-12-02 20:46:22 +00:00
|
|
|
upstat(pp, "printing disabled\n");
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("\tprinting disabled\n");
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
printf("\tcannot stat lock file\n");
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct queue **queue;
|
|
|
|
int nitems;
|
|
|
|
time_t mtime;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put the specified jobs at the top of printer queue.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
topq(argc, argv)
|
|
|
|
int argc;
|
|
|
|
char *argv[];
|
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
struct stat stbuf;
|
|
|
|
int status, changed;
|
1997-12-02 20:46:22 +00:00
|
|
|
struct printer myprinter, *pp = &myprinter;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
if (argc < 3) {
|
|
|
|
printf("Usage: topq printer [jobnum ...] [user ...]\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
--argc;
|
1997-12-02 20:46:22 +00:00
|
|
|
++argv;
|
|
|
|
init_printer(pp);
|
|
|
|
status = getprintcap(*argv, pp);
|
|
|
|
switch(status) {
|
|
|
|
default:
|
|
|
|
fatal(pp, pcaperr(status));
|
|
|
|
case PCAPERR_NOTFOUND:
|
|
|
|
printf("unknown printer %s\n", *argv);
|
|
|
|
return;
|
|
|
|
case PCAPERR_TCOPEN:
|
|
|
|
printf("warning: %s: unresolved tc= reference(s)", *argv);
|
|
|
|
break;
|
|
|
|
case PCAPERR_SUCCESS:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf("%s:\n", pp->printer);
|
1994-05-26 05:23:31 +00:00
|
|
|
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (chdir(pp->spool_dir) < 0) {
|
|
|
|
printf("\tcannot chdir to %s\n", pp->spool_dir);
|
1997-07-23 00:49:46 +00:00
|
|
|
goto out;
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(uid);
|
1997-12-02 20:46:22 +00:00
|
|
|
nitems = getq(pp, &queue);
|
1994-05-26 05:23:31 +00:00
|
|
|
if (nitems == 0)
|
|
|
|
return;
|
|
|
|
changed = 0;
|
|
|
|
mtime = queue[0]->q_time;
|
|
|
|
for (i = argc; --i; ) {
|
|
|
|
if (doarg(argv[i]) == 0) {
|
|
|
|
printf("\tjob %s is not in the queue\n", argv[i]);
|
|
|
|
continue;
|
|
|
|
} else
|
|
|
|
changed++;
|
|
|
|
}
|
|
|
|
for (i = 0; i < nitems; i++)
|
|
|
|
free(queue[i]);
|
|
|
|
free(queue);
|
|
|
|
if (!changed) {
|
|
|
|
printf("\tqueue order unchanged\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Turn on the public execute bit of the lock file to
|
|
|
|
* get lpd to rebuild the queue after the current job.
|
|
|
|
*/
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
1997-12-02 20:46:22 +00:00
|
|
|
if (changed && stat(pp->lock_file, &stbuf) >= 0)
|
|
|
|
(void) chmod(pp->lock_file, stbuf.st_mode | LFM_RESET_QUE);
|
1997-07-23 00:49:46 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
seteuid(uid);
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reposition the job by changing the modification time of
|
|
|
|
* the control file.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
touch(q)
|
|
|
|
struct queue *q;
|
|
|
|
{
|
|
|
|
struct timeval tvp[2];
|
1997-07-23 00:49:46 +00:00
|
|
|
int ret;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
tvp[0].tv_sec = tvp[1].tv_sec = --mtime;
|
|
|
|
tvp[0].tv_usec = tvp[1].tv_usec = 0;
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
|
|
|
ret = utimes(q->q_name, tvp);
|
|
|
|
seteuid(uid);
|
|
|
|
return (ret);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Checks if specified job name is in the printer's queue.
|
|
|
|
* Returns: negative (-1) if argument name is not in the queue.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
doarg(job)
|
|
|
|
char *job;
|
|
|
|
{
|
|
|
|
register struct queue **qq;
|
|
|
|
register int jobnum, n;
|
|
|
|
register char *cp, *machine;
|
|
|
|
int cnt = 0;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
/*
|
1997-07-29 04:17:19 +00:00
|
|
|
* Look for a job item consisting of system name, colon, number
|
|
|
|
* (example: ucbarpa:114)
|
1994-05-26 05:23:31 +00:00
|
|
|
*/
|
1997-07-23 20:53:41 +00:00
|
|
|
if ((cp = strchr(job, ':')) != NULL) {
|
1994-05-26 05:23:31 +00:00
|
|
|
machine = job;
|
|
|
|
*cp++ = '\0';
|
|
|
|
job = cp;
|
|
|
|
} else
|
|
|
|
machine = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for job specified by number (example: 112 or 235ucbarpa).
|
|
|
|
*/
|
|
|
|
if (isdigit(*job)) {
|
|
|
|
jobnum = 0;
|
|
|
|
do
|
|
|
|
jobnum = jobnum * 10 + (*job++ - '0');
|
|
|
|
while (isdigit(*job));
|
|
|
|
for (qq = queue + nitems; --qq >= queue; ) {
|
|
|
|
n = 0;
|
|
|
|
for (cp = (*qq)->q_name+3; isdigit(*cp); )
|
|
|
|
n = n * 10 + (*cp++ - '0');
|
|
|
|
if (jobnum != n)
|
|
|
|
continue;
|
|
|
|
if (*job && strcmp(job, cp) != 0)
|
|
|
|
continue;
|
|
|
|
if (machine != NULL && strcmp(machine, cp) != 0)
|
|
|
|
continue;
|
|
|
|
if (touch(*qq) == 0) {
|
|
|
|
printf("\tmoved %s\n", (*qq)->q_name);
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(cnt);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Process item consisting of owner's name (example: henry).
|
|
|
|
*/
|
|
|
|
for (qq = queue + nitems; --qq >= queue; ) {
|
1997-07-23 00:49:46 +00:00
|
|
|
seteuid(euid);
|
|
|
|
fp = fopen((*qq)->q_name, "r");
|
|
|
|
seteuid(uid);
|
|
|
|
if (fp == NULL)
|
1994-05-26 05:23:31 +00:00
|
|
|
continue;
|
|
|
|
while (getline(fp) > 0)
|
|
|
|
if (line[0] == 'P')
|
|
|
|
break;
|
|
|
|
(void) fclose(fp);
|
|
|
|
if (line[0] != 'P' || strcmp(job, line+1) != 0)
|
|
|
|
continue;
|
|
|
|
if (touch(*qq) == 0) {
|
|
|
|
printf("\tmoved %s\n", (*qq)->q_name);
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable everything and start printer (undo `down').
|
|
|
|
*/
|
|
|
|
void
|
1997-12-02 20:46:22 +00:00
|
|
|
up(pp)
|
|
|
|
struct printer *pp;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
1997-12-02 20:46:22 +00:00
|
|
|
startpr(pp, 2);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|