lprm.c (29780) | lprm.c (31492) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 29 unchanged lines hidden (view full) --- 38 The Regents of the University of California. All rights reserved.\n"; 39#endif /* not lint */ 40 41#ifndef lint 42#if 0 43static char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93"; 44#endif 45static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 29 unchanged lines hidden (view full) --- 38 The Regents of the University of California. All rights reserved.\n"; 39#endif /* not lint */ 40 41#ifndef lint 42#if 0 43static char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93"; 44#endif 45static const char rcsid[] = |
46 "$Id$"; | 46 "$Id: lprm.c,v 1.3 1997/09/24 06:48:17 charnier Exp $"; |
47#endif /* not lint */ 48 49/* 50 * lprm - remove the current user's spool entry 51 * 52 * lprm [-] [[job #] [user] ...] 53 * 54 * Using information in the lock file, lprm will kill the --- 29 unchanged lines hidden (view full) --- 84 85static void usage __P((void)); 86 87int 88main(argc, argv) 89 int argc; 90 char *argv[]; 91{ | 47#endif /* not lint */ 48 49/* 50 * lprm - remove the current user's spool entry 51 * 52 * lprm [-] [[job #] [user] ...] 53 * 54 * Using information in the lock file, lprm will kill the --- 29 unchanged lines hidden (view full) --- 84 85static void usage __P((void)); 86 87int 88main(argc, argv) 89 int argc; 90 char *argv[]; 91{ |
92 register char *arg; | 92 char *arg, *printer; |
93 struct passwd *p; | 93 struct passwd *p; |
94 static char root[] = "root"; |
|
94 | 95 |
96 printer = NULL; |
|
95 uid = getuid(); 96 euid = geteuid(); 97 seteuid(uid); /* be safe */ 98 name = argv[0]; 99 gethostname(host, sizeof(host)); 100 openlog("lpd", 0, LOG_LPR); | 97 uid = getuid(); 98 euid = geteuid(); 99 seteuid(uid); /* be safe */ 100 name = argv[0]; 101 gethostname(host, sizeof(host)); 102 openlog("lpd", 0, LOG_LPR); |
101 if ((p = getpwuid(getuid())) == NULL) 102 fatal("Who are you?"); 103 if (strlen(p->pw_name) >= sizeof(luser)) 104 fatal("Your name is too long"); 105 strcpy(luser, p->pw_name); 106 person = luser; | 103 104 /* 105 * Bogus code later checks for string equality between 106 * `person' and "root", so if we are root, better make sure 107 * that code will succeed. 108 */ 109 if (getuid() == 0) { 110 person = root; 111 } else if ((person = getlogin()) == NULL) { 112 if ((p = getpwuid(getuid())) == NULL) 113 fatal(0, "Who are you?"); 114 if (strlen(p->pw_name) >= sizeof(luser)) 115 fatal(0, "Your name is too long"); 116 strcpy(luser, p->pw_name); 117 person = luser; 118 } |
107 while (--argc) { 108 if ((arg = *++argv)[0] == '-') 109 switch (arg[1]) { 110 case 'P': 111 if (arg[2]) 112 printer = &arg[2]; 113 else if (argc > 1) { 114 argc--; --- 8 unchanged lines hidden (view full) --- 123 default: 124 usage(); 125 } 126 else { 127 if (users < 0) 128 usage(); 129 if (isdigit(arg[0])) { 130 if (requests >= MAXREQUESTS) | 119 while (--argc) { 120 if ((arg = *++argv)[0] == '-') 121 switch (arg[1]) { 122 case 'P': 123 if (arg[2]) 124 printer = &arg[2]; 125 else if (argc > 1) { 126 argc--; --- 8 unchanged lines hidden (view full) --- 135 default: 136 usage(); 137 } 138 else { 139 if (users < 0) 140 usage(); 141 if (isdigit(arg[0])) { 142 if (requests >= MAXREQUESTS) |
131 fatal("Too many requests"); | 143 fatal(0, "Too many requests"); |
132 requ[requests++] = atoi(arg); 133 } else { 134 if (users >= MAXUSERS) | 144 requ[requests++] = atoi(arg); 145 } else { 146 if (users >= MAXUSERS) |
135 fatal("Too many users"); | 147 fatal(0, "Too many users"); |
136 user[users++] = arg; 137 } 138 } 139 } 140 if (printer == NULL && (printer = getenv("PRINTER")) == NULL) 141 printer = DEFLP; 142 | 148 user[users++] = arg; 149 } 150 } 151 } 152 if (printer == NULL && (printer = getenv("PRINTER")) == NULL) 153 printer = DEFLP; 154 |
143 rmjob(); | 155 rmjob(printer); |
144 exit(0); 145} 146 147static void 148usage() 149{ 150 fprintf(stderr, "usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n"); 151 exit(2); 152} | 156 exit(0); 157} 158 159static void 160usage() 161{ 162 fprintf(stderr, "usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n"); 163 exit(2); 164} |