122433Sdist /* 222433Sdist * Copyright (c) 1983 Regents of the University of California. 334203Sbostic * All rights reserved. 434203Sbostic * 542802Sbostic * %sccs.include.redist.c% 622433Sdist */ 722433Sdist 813954Ssam #ifndef lint 922433Sdist char copyright[] = 1022433Sdist "@(#) Copyright (c) 1983 Regents of the University of California.\n\ 1122433Sdist All rights reserved.\n"; 1234203Sbostic #endif /* not lint */ 1313954Ssam 1422433Sdist #ifndef lint 15*46916Sbostic static char sccsid[] = "@(#)lprm.c 5.6 (Berkeley) 03/02/91"; 1634203Sbostic #endif /* not lint */ 1722433Sdist 1812110Sralph /* 1912110Sralph * lprm - remove the current user's spool entry 2012110Sralph * 2112110Sralph * lprm [-] [[job #] [user] ...] 2212110Sralph * 2312110Sralph * Using information in the lock file, lprm will kill the 2412110Sralph * currently active daemon (if necessary), remove the associated files, 2512110Sralph * and startup a new daemon. Priviledged users may remove anyone's spool 2612110Sralph * entries, otherwise one can only remove their own. 2712110Sralph */ 2812110Sralph 2912110Sralph #include "lp.h" 3012110Sralph 3112110Sralph /* 3212110Sralph * Stuff for handling job specifications 3312110Sralph */ 3412877Sralph char *user[MAXUSERS]; /* users to process */ 3512877Sralph int users; /* # of users in user array */ 3612877Sralph int requ[MAXREQUESTS]; /* job number of spool entries */ 3712877Sralph int requests; /* # of spool requests */ 3812877Sralph char *person; /* name of person doing lprm */ 3912110Sralph 4012877Sralph static char luser[16]; /* buffer for person */ 4112110Sralph 4212110Sralph main(argc, argv) 43*46916Sbostic int argc; 4412110Sralph char *argv[]; 4512110Sralph { 4612110Sralph register char *arg; 4712110Sralph struct passwd *p; 4812110Sralph struct direct **files; 4912110Sralph int nitems, assasinated = 0; 5012110Sralph 5112110Sralph name = argv[0]; 5212110Sralph gethostname(host, sizeof(host)); 5325496Seric openlog("lpd", 0, LOG_LPR); 5412110Sralph if ((p = getpwuid(getuid())) == NULL) 5512110Sralph fatal("Who are you?"); 5612110Sralph if (strlen(p->pw_name) >= sizeof(luser)) 5712110Sralph fatal("Your name is too long"); 5812110Sralph strcpy(luser, p->pw_name); 5912110Sralph person = luser; 6012110Sralph while (--argc) { 6112110Sralph if ((arg = *++argv)[0] == '-') 6212110Sralph switch (arg[1]) { 6312110Sralph case 'P': 6412730Sralph if (arg[2]) 6512730Sralph printer = &arg[2]; 6612730Sralph else if (argc > 1) { 6712730Sralph argc--; 6812730Sralph printer = *++argv; 6912730Sralph } 7012110Sralph break; 7112110Sralph case '\0': 7212110Sralph if (!users) { 7312110Sralph users = -1; 7412110Sralph break; 7512110Sralph } 7612110Sralph default: 7712110Sralph usage(); 7812110Sralph } 7912110Sralph else { 8012110Sralph if (users < 0) 8112110Sralph usage(); 8212110Sralph if (isdigit(arg[0])) { 8312110Sralph if (requests >= MAXREQUESTS) 8412110Sralph fatal("Too many requests"); 8512110Sralph requ[requests++] = atoi(arg); 8612110Sralph } else { 8712110Sralph if (users >= MAXUSERS) 8812110Sralph fatal("Too many users"); 8912110Sralph user[users++] = arg; 9012110Sralph } 9112110Sralph } 9212110Sralph } 9312110Sralph if (printer == NULL && (printer = getenv("PRINTER")) == NULL) 9412110Sralph printer = DEFLP; 9512110Sralph 9612110Sralph rmjob(); 9712110Sralph } 9812110Sralph 9912110Sralph usage() 10012110Sralph { 101*46916Sbostic fprintf(stderr, "usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n"); 10212110Sralph exit(2); 10312110Sralph } 104