rmjob.c (29780) | rmjob.c (30407) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)rmjob.c 8.2 (Berkeley) 4/28/95"; 37#endif 38static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)rmjob.c 8.2 (Berkeley) 4/28/95"; 37#endif 38static const char rcsid[] = |
39 "$Id$"; | 39 "$Id: rmjob.c,v 1.9 1997/09/24 06:47:31 charnier Exp $"; |
40#endif /* not lint */ 41 42#include <sys/param.h> 43 44#include <signal.h> 45#include <errno.h> 46#include <dirent.h> 47#include <unistd.h> --- 14 unchanged lines hidden (view full) --- 62 */ 63static char root[] = "root"; 64static int all = 0; /* eliminate all files (root only) */ 65static int cur_daemon; /* daemon's pid */ 66static char current[40]; /* active control file name */ 67 68extern uid_t uid, euid; /* real and effective user id's */ 69 | 40#endif /* not lint */ 41 42#include <sys/param.h> 43 44#include <signal.h> 45#include <errno.h> 46#include <dirent.h> 47#include <unistd.h> --- 14 unchanged lines hidden (view full) --- 62 */ 63static char root[] = "root"; 64static int all = 0; /* eliminate all files (root only) */ 65static int cur_daemon; /* daemon's pid */ 66static char current[40]; /* active control file name */ 67 68extern uid_t uid, euid; /* real and effective user id's */ 69 |
70static void alarmhandler __P((int)); |
|
70static void do_unlink __P((char *)); 71 72void 73rmjob() 74{ 75 register int i, nitems; 76 int assasinated = 0; 77 struct dirent **files; --- 8 unchanged lines hidden (view full) --- 86 if (cgetstr(bp, "lp", &LP) < 0) 87 LP = _PATH_DEFDEVLP; 88 if (cgetstr(bp, "rp", &RP) < 0) 89 RP = DEFLP; 90 if (cgetstr(bp, "sd", &SD) < 0) 91 SD = _PATH_DEFSPOOL; 92 if (cgetstr(bp,"lo", &LO) < 0) 93 LO = DEFLOCK; | 71static void do_unlink __P((char *)); 72 73void 74rmjob() 75{ 76 register int i, nitems; 77 int assasinated = 0; 78 struct dirent **files; --- 8 unchanged lines hidden (view full) --- 87 if (cgetstr(bp, "lp", &LP) < 0) 88 LP = _PATH_DEFDEVLP; 89 if (cgetstr(bp, "rp", &RP) < 0) 90 RP = DEFLP; 91 if (cgetstr(bp, "sd", &SD) < 0) 92 SD = _PATH_DEFSPOOL; 93 if (cgetstr(bp,"lo", &LO) < 0) 94 LO = DEFLOCK; |
95 if (cgetnum(bp, "ct", &CT) < 0) 96 CT = DEFTIMEOUT; |
|
94 cgetstr(bp, "rm", &RM); 95 if ((cp = checkremote())) 96 printf("Warning: %s\n", cp); 97 98 /* 99 * If the format was `lprm -' and the user isn't the super-user, 100 * then fake things to look like he said `lprm user'. 101 */ --- 210 unchanged lines hidden (view full) --- 312 * then try removing files on the remote machine. 313 */ 314void 315rmremote() 316{ 317 register char *cp; 318 register int i, rem; 319 char buf[BUFSIZ]; | 97 cgetstr(bp, "rm", &RM); 98 if ((cp = checkremote())) 99 printf("Warning: %s\n", cp); 100 101 /* 102 * If the format was `lprm -' and the user isn't the super-user, 103 * then fake things to look like he said `lprm user'. 104 */ --- 210 unchanged lines hidden (view full) --- 315 * then try removing files on the remote machine. 316 */ 317void 318rmremote() 319{ 320 register char *cp; 321 register int i, rem; 322 char buf[BUFSIZ]; |
323 void (*savealrm)(int); |
|
320 321 if (!remote) 322 return; /* not sending to a remote machine */ 323 324 /* 325 * Flush stdout so the user can see what has been deleted 326 * while we wait (possibly) for the connection. 327 */ --- 6 unchanged lines hidden (view full) --- 334 *cp++ = ' '; 335 strcpy(cp, user[i]); 336 } 337 for (i = 0; i < requests && cp-buf+10 < sizeof(buf) - 1; i++) { 338 cp += strlen(cp); 339 (void) sprintf(cp, " %d", requ[i]); 340 } 341 strcat(cp, "\n"); | 324 325 if (!remote) 326 return; /* not sending to a remote machine */ 327 328 /* 329 * Flush stdout so the user can see what has been deleted 330 * while we wait (possibly) for the connection. 331 */ --- 6 unchanged lines hidden (view full) --- 338 *cp++ = ' '; 339 strcpy(cp, user[i]); 340 } 341 for (i = 0; i < requests && cp-buf+10 < sizeof(buf) - 1; i++) { 342 cp += strlen(cp); 343 (void) sprintf(cp, " %d", requ[i]); 344 } 345 strcat(cp, "\n"); |
346 savealrm = signal(SIGALRM, alarmhandler); 347 alarm(CT); |
|
342 rem = getport(RM, 0); | 348 rem = getport(RM, 0); |
349 (void)signal(SIGALRM, savealrm); |
|
343 if (rem < 0) { 344 if (from != host) 345 printf("%s: ", host); 346 printf("connection to %s is down\n", RM); 347 } else { 348 i = strlen(buf); 349 if (write(rem, buf, i) != i) 350 fatal("Lost connection"); --- 7 unchanged lines hidden (view full) --- 358 * Return 1 if the filename begins with 'cf' 359 */ 360int 361iscf(d) 362 struct dirent *d; 363{ 364 return(d->d_name[0] == 'c' && d->d_name[1] == 'f'); 365} | 350 if (rem < 0) { 351 if (from != host) 352 printf("%s: ", host); 353 printf("connection to %s is down\n", RM); 354 } else { 355 i = strlen(buf); 356 if (write(rem, buf, i) != i) 357 fatal("Lost connection"); --- 7 unchanged lines hidden (view full) --- 365 * Return 1 if the filename begins with 'cf' 366 */ 367int 368iscf(d) 369 struct dirent *d; 370{ 371 return(d->d_name[0] == 'c' && d->d_name[1] == 'f'); 372} |
373 374void 375alarmhandler(signo) 376{ 377 /* ignored */ 378} |
|