|
|
1.1 root 1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted provided
6: * that: (1) source distributions retain this entire copyright notice and
7: * comment, and (2) distributions including binaries display the following
8: * acknowledgement: ``This product includes software developed by the
9: * University of California, Berkeley and its contributors'' in the
10: * documentation or other materials provided with the distribution and in
11: * all advertising materials mentioning features or use of this software.
12: * Neither the name of the University nor the names of its contributors may
13: * be used to endorse or promote products derived from this software without
14: * specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: char copyright[] =
22: "@(#) Copyright (c) 1983 Regents of the University of California.\n\
23: All rights reserved.\n";
24: #endif /* not lint */
25:
26: #ifndef lint
27: static char sccsid[] = "@(#)lprm.c 5.5 (Berkeley) 6/1/90";
28: #endif /* not lint */
29:
30: /*
31: * lprm - remove the current user's spool entry
32: *
33: * lprm [-] [[job #] [user] ...]
34: *
35: * Using information in the lock file, lprm will kill the
36: * currently active daemon (if necessary), remove the associated files,
37: * and startup a new daemon. Priviledged users may remove anyone's spool
38: * entries, otherwise one can only remove their own.
39: */
40:
41: #include "lp.h"
42:
43: /*
44: * Stuff for handling job specifications
45: */
46: char *user[MAXUSERS]; /* users to process */
47: int users; /* # of users in user array */
48: int requ[MAXREQUESTS]; /* job number of spool entries */
49: int requests; /* # of spool requests */
50: char *person; /* name of person doing lprm */
51:
52: static char luser[16]; /* buffer for person */
53:
54: struct passwd *getpwuid();
55:
56: main(argc, argv)
57: char *argv[];
58: {
59: register char *arg;
60: struct passwd *p;
61: struct direct **files;
62: int nitems, assasinated = 0;
63:
64: name = argv[0];
65: gethostname(host, sizeof(host));
66: openlog("lpd", 0, LOG_LPR);
67: if ((p = getpwuid(getuid())) == NULL)
68: fatal("Who are you?");
69: if (strlen(p->pw_name) >= sizeof(luser))
70: fatal("Your name is too long");
71: strcpy(luser, p->pw_name);
72: person = luser;
73: while (--argc) {
74: if ((arg = *++argv)[0] == '-')
75: switch (arg[1]) {
76: case 'P':
77: if (arg[2])
78: printer = &arg[2];
79: else if (argc > 1) {
80: argc--;
81: printer = *++argv;
82: }
83: break;
84: case '\0':
85: if (!users) {
86: users = -1;
87: break;
88: }
89: default:
90: usage();
91: }
92: else {
93: if (users < 0)
94: usage();
95: if (isdigit(arg[0])) {
96: if (requests >= MAXREQUESTS)
97: fatal("Too many requests");
98: requ[requests++] = atoi(arg);
99: } else {
100: if (users >= MAXUSERS)
101: fatal("Too many users");
102: user[users++] = arg;
103: }
104: }
105: }
106: if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
107: printer = DEFLP;
108:
109: rmjob();
110: }
111:
112: static
113: usage()
114: {
115: printf("usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n");
116: exit(2);
117: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.