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