add copyright notice
[unix-history] / usr / src / usr.sbin / lpr / common_source / rmjob.c
index 05bdb05..f0dcf2f 100644 (file)
@@ -1,4 +1,7 @@
-/*     rmjob.c 4.6     83/06/29        */
+#ifndef lint
+static char sccsid[] = "@(#)rmjob.c    4.10 (Berkeley) %G%";
+#endif
+
 /*
  * rmjob - remove the specified jobs from the queue.
  */
 /*
  * rmjob - remove the specified jobs from the queue.
  */
@@ -14,10 +17,10 @@ extern int  requ[];                 /* job number of spool entries */
 extern int     requests;               /* # of spool requests */
 extern char    *person;                /* name of person doing lprm */
 
 extern int     requests;               /* # of spool requests */
 extern char    *person;                /* name of person doing lprm */
 
-static char    root[] = "root";
-static int     all = 0;                /* eliminate all files (root only) */
-static int     cur_daemon;             /* daemon's pid */
-static char    current[40];            /* active control file name */
+char   root[] = "root";
+int    all = 0;                /* eliminate all files (root only) */
+int    cur_daemon;             /* daemon's pid */
+char   current[40];            /* active control file name */
 
 int    iscf();
 
 
 int    iscf();
 
@@ -86,7 +89,7 @@ rmjob()
        /*
         * Restart the printer daemon if it was killed
         */
        /*
         * Restart the printer daemon if it was killed
         */
-       if (assasinated && !startdaemon(host))
+       if (assasinated && !startdaemon(printer))
                fatal("cannot restart printer daemon\n");
        exit(0);
 }
                fatal("cannot restart printer daemon\n");
        exit(0);
 }
@@ -96,7 +99,6 @@ rmjob()
  *  daemon and the file name of the active spool entry.
  * Return boolean indicating existence of a lock file.
  */
  *  daemon and the file name of the active spool entry.
  * Return boolean indicating existence of a lock file.
  */
-static
 lockchk(s)
        char *s;
 {
 lockchk(s)
        char *s;
 {
@@ -132,7 +134,6 @@ lockchk(s)
 /*
  * Process a control file.
  */
 /*
  * Process a control file.
  */
-static
 process(file)
        char *file;
 {
 process(file)
        char *file;
 {
@@ -142,7 +143,7 @@ process(file)
                return;
        if ((cfp = fopen(file, "r")) == NULL)
                fatal("cannot open %s", file);
                return;
        if ((cfp = fopen(file, "r")) == NULL)
                fatal("cannot open %s", file);
-       while (getline()) {
+       while (getline(cfp)) {
                switch (line[0]) {
                case 'U':  /* unlink associated files */
                        if (from != host)
                switch (line[0]) {
                case 'U':  /* unlink associated files */
                        if (from != host)
@@ -160,7 +161,6 @@ process(file)
 /*
  * Do the dirty work in checking
  */
 /*
  * Do the dirty work in checking
  */
-static
 chk(file)
        char *file;
 {
 chk(file)
        char *file;
 {
@@ -168,6 +168,12 @@ chk(file)
        register char **u, *cp;
        FILE *cfp;
 
        register char **u, *cp;
        FILE *cfp;
 
+       /*
+        * Check for valid cf file name (mostly checking current).
+        */
+       if (strlen(file) < 7 || file[0] != 'c' || file[1] != 'f')
+               return(0);
+
        if (all && (from == host || !strcmp(from, file+6)))
                return(1);
 
        if (all && (from == host || !strcmp(from, file+6)))
                return(1);
 
@@ -209,7 +215,6 @@ chk(file)
  * files sent from the remote machine to be removed.
  * Normal users can only remove the file from where it was sent.
  */
  * files sent from the remote machine to be removed.
  * Normal users can only remove the file from where it was sent.
  */
-static
 isowner(owner, file)
        char *owner, *file;
 {
 isowner(owner, file)
        char *owner, *file;
 {
@@ -227,7 +232,6 @@ isowner(owner, file)
  * Check to see if we are sending files to a remote machine. If we are,
  * then try removing files on the remote machine.
  */
  * Check to see if we are sending files to a remote machine. If we are,
  * then try removing files on the remote machine.
  */
-static
 chkremote()
 {
        register char *cp;
 chkremote()
 {
        register char *cp;
@@ -273,7 +277,6 @@ chkremote()
 /*
  * Return 1 if the filename begins with 'cf'
  */
 /*
  * Return 1 if the filename begins with 'cf'
  */
-static
 iscf(d)
        struct direct *d;
 {
 iscf(d)
        struct direct *d;
 {