]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add (undocumented) -T option to print the current sandbox profile to stdout.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 25 Jan 2016 14:43:52 +0000 (14:43 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 25 Jan 2016 14:43:52 +0000 (14:43 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@13055 a1ca3aef-8c08-0410-bb20-df032aa958be

scheduler/main.c
scheduler/process.c

index 0b171b5044d2dbe71208a46604c02c6cb39671e6..225892e6215c3901f6df6922d5e9538d8b94a714 100644 (file)
@@ -109,8 +109,10 @@ main(int  argc,                            /* I - Number of command-line args */
   int                  close_all = 1,  /* Close all file descriptors? */
                        disconnect = 1, /* Disconnect from controlling terminal? */
                        fg = 0,         /* Run in foreground? */
-                       run_as_child = 0;
+                       run_as_child = 0,
                                        /* Running as child process? */
+                       print_profile = 0;
+                                       /* Print the sandbox profile to stdout? */
   int                  fds;            /* Number of ready descriptors */
   cupsd_client_t       *con;           /* Current client */
   cupsd_job_t          *job;           /* Current job */
@@ -309,6 +311,13 @@ main(int  argc,                            /* I - Number of command-line args */
              close_all      = 0;
              break;
 
+          case 'T' : /* Print security profile */
+              print_profile = 1;
+              fg            = 1;
+              disconnect    = 0;
+              close_all     = 0;
+              break;
+
          default : /* Unknown option */
               _cupsLangPrintf(stderr, _("cupsd: Unknown option \"%c\" - "
                                        "aborting."), *opt);
@@ -546,6 +555,27 @@ main(int  argc,                            /* I - Number of command-line args */
     printf("\"%s\" is OK.\n", ConfigurationFile);
     return (0);
   }
+  else if (print_profile)
+  {
+    cups_file_t        *fp;                    /* File pointer */
+    const char *profile = cupsdCreateProfile(42, 0);
+                                       /* Profile */
+    char       line[1024];             /* Line from file */
+
+
+    if ((fp = cupsFileOpen(profile, "r")) == NULL)
+    {
+      printf("Unable to open profile file \"%s\": %s\n", profile ? profile : "(null)", strerror(errno));
+      return (1);
+    }
+
+    while (cupsFileGets(fp, line, sizeof(line)))
+      puts(line);
+
+    cupsFileClose(fp);
+
+    return (0);
+  }
 
  /*
   * Clean out old temp files and printer cache data.
index 1f45368abc3d8eecbebf71e19c1bac776c7cff13..2587bde187f9355043bf3d8594dd3b6ba01a477e 100644 (file)
@@ -341,7 +341,7 @@ cupsdCreateProfile(int job_id,              /* I - Job ID or 0 for none */
     /* Only allow SNMP (UDP) and LPD (TCP) off the machine... */
     cupsFilePuts(fp, ")\n");
     cupsFilePuts(fp, "(allow network-outbound\n"
-                    "       (remote udp \"*:161\")"
+                    "       (remote udp \"*:161\")\n"
                     "       (remote tcp \"*:515\"))\n");
     cupsFilePuts(fp, "(allow network-inbound\n"
                     "       (local udp \"localhost:*\"))\n");