]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/cups-driverd.cxx
Fix test suite failure caused by log rotation due to sandboxing warning message.
[thirdparty/cups.git] / scheduler / cups-driverd.cxx
index 1c5b26533068680c0beaae9e5727bd431daa978c..b518a93258178774b839d557560eba3ceabc79c6 100644 (file)
@@ -5,7 +5,7 @@
  * created from driver information files, and dynamically generated PPD files
  * using driver helper programs.
  *
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2018 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products.
  *
  * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
@@ -153,7 +153,7 @@ static ppd_info_t   *add_ppd(const char *filename, const char *name,
                                 size_t size, int model_number, int type,
                                 const char *scheme);
 static int             cat_drv(const char *name, int request_id);
-static int             cat_ppd(const char *name, int request_id);
+static void            cat_ppd(const char *name, int request_id);
 static int             cat_static(const char *name, int request_id);
 static int             cat_tar(const char *name, int request_id);
 static int             compare_inodes(struct stat *a, struct stat *b);
@@ -163,12 +163,12 @@ static int                compare_names(const ppd_info_t *p0,
                                      const ppd_info_t *p1);
 static int             compare_ppds(const ppd_info_t *p0,
                                     const ppd_info_t *p1);
-static int             dump_ppds_dat(const char *filename);
+static void            dump_ppds_dat(const char *filename);
 static void            free_array(cups_array_t *a);
 static cups_file_t     *get_file(const char *name, int request_id,
                                  const char *subdir, char *buffer,
                                  size_t bufsize, char **subfile);
-static int             list_ppds(int request_id, int limit, const char *opt);
+static void            list_ppds(int request_id, int limit, const char *opt);
 static int             load_drivers(cups_array_t *include,
                                     cups_array_t *exclude);
 static int             load_drv(const char *filename, const char *name,
@@ -204,13 +204,13 @@ main(int  argc,                           /* I - Number of command-line args */
   */
 
   if (argc == 3 && !strcmp(argv[1], "cat"))
-    return (cat_ppd(argv[2], 0));
+    cat_ppd(argv[2], 0);
   else if ((argc == 2 || argc == 3) && !strcmp(argv[1], "dump"))
-    return (dump_ppds_dat(argv[2]));
+    dump_ppds_dat(argv[2]);
   else if (argc == 4 && !strcmp(argv[1], "get"))
-    return (cat_ppd(argv[3], atoi(argv[2])));
+    cat_ppd(argv[3], atoi(argv[2]));
   else if (argc == 5 && !strcmp(argv[1], "list"))
-    return (list_ppds(atoi(argv[2]), atoi(argv[3]), argv[4]));
+    list_ppds(atoi(argv[2]), atoi(argv[3]), argv[4]);
   else
   {
     fputs("Usage: cups-driverd cat ppd-name\n", stderr);
@@ -428,7 +428,7 @@ cat_drv(const char *name,           /* I - PPD name */
  * 'cat_ppd()' - Copy a PPD file to stdout.
  */
 
-static int                             /* O - Exit code */
+static void
 cat_ppd(const char *name,              /* I - PPD name */
         int        request_id)         /* I - Request ID for response? */
 {
@@ -445,7 +445,7 @@ cat_ppd(const char *name,           /* I - PPD name */
   if (strstr(name, "../"))
   {
     fputs("ERROR: Invalid PPD name.\n", stderr);
-    return (1);
+    exit(1);
   }
 
   strlcpy(scheme, name, sizeof(scheme));
@@ -475,11 +475,11 @@ cat_ppd(const char *name,         /* I - PPD name */
     puts("Content-Type: application/ipp\n");
 
   if (!scheme[0])
-    return (cat_static(name, request_id));
+    exit(cat_static(name, request_id));
   else if (!strcmp(scheme, "drv"))
-    return (cat_drv(name, request_id));
+    exit(cat_drv(name, request_id));
   else if (!strcmp(scheme, "file"))
-    return (cat_tar(name, request_id));
+    exit(cat_tar(name, request_id));
   else
   {
    /*
@@ -517,7 +517,7 @@ cat_ppd(const char *name,           /* I - PPD name */
         cupsdSendIPPTrailer();
       }
 
-      return (1);
+      exit(1);
     }
 
    /*
@@ -547,15 +547,15 @@ cat_ppd(const char *name,         /* I - PPD name */
 
       fprintf(stderr, "ERROR: [cups-driverd] Unable to execute \"%s\" - %s\n",
               line, strerror(errno));
-      return (1);
+      exit(1);
     }
   }
 
  /*
-  * Return with no errors...
+  * Exit with no errors...
   */
 
-  return (0);
+  exit(0);
 }
 
 
@@ -778,7 +778,7 @@ compare_ppds(const ppd_info_t *p0,  /* I - First PPD file */
  * 'dump_ppds_dat()' - Dump the contents of the ppds.dat file.
  */
 
-static int                             /* O - Exit status */
+static void
 dump_ppds_dat(const char *filename)    /* I - Filename */
 {
   char         temp[1024];             /* ppds.dat filename */
@@ -810,7 +810,7 @@ dump_ppds_dat(const char *filename) /* I - Filename */
           ppd->record.make_and_model, ppd->record.device_id,
           ppd->record.scheme);
 
-  return (0);
+  exit(0);
 }
 
 
@@ -1004,7 +1004,7 @@ get_file(const char *name,                /* I - Name */
  * 'list_ppds()' - List PPD files.
  */
 
-static int                             /* O - Exit code */
+static void
 list_ppds(int        request_id,       /* I - Request ID */
           int        limit,            /* I - Limit */
          const char *opt)              /* I - Option argument */
@@ -1566,7 +1566,7 @@ list_ppds(int        request_id,  /* I - Request ID */
   if (request_id)
     cupsdSendIPPTrailer();
 
-  return (0);
+  exit(0);
 }
 
 
@@ -2615,7 +2615,7 @@ load_ppds_dat(char   *filename,           /* I - Filename buffer */
     unsigned ppdsync;                  /* Sync word */
     int      num_ppds;                 /* Number of PPDs */
 
-    if (cupsFileRead(fp, (char *)&ppdsync, sizeof(ppdsync)) == sizeof(ppdsync) &&
+    if ((size_t)cupsFileRead(fp, (char *)&ppdsync, sizeof(ppdsync)) == sizeof(ppdsync) &&
         ppdsync == PPD_SYNC &&
         !stat(filename, &fileinfo) &&
        (((size_t)fileinfo.st_size - sizeof(ppdsync)) % sizeof(ppd_rec_t)) == 0 &&
@@ -2724,7 +2724,7 @@ read_tar(cups_file_t *fp,         /* I - Archive to read */
   tar_rec_t    record;                 /* Record from file */
 
 
-  while (cupsFileRead(fp, (char *)&record, sizeof(record)) == sizeof(record))
+  while ((size_t)cupsFileRead(fp, (char *)&record, sizeof(record)) == sizeof(record))
   {
    /*
     * Check for a valid tar header...