From: msweet Date: Mon, 25 Jan 2016 14:43:52 +0000 (+0000) Subject: Add (undocumented) -T option to print the current sandbox profile to stdout. X-Git-Tag: v2.2b1~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dd940185b68583cc33c5a91b7ee21dec3c448e7;p=thirdparty%2Fcups.git Add (undocumented) -T option to print the current sandbox profile to stdout. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@13055 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/scheduler/main.c b/scheduler/main.c index 0b171b5044..225892e621 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -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. diff --git a/scheduler/process.c b/scheduler/process.c index 1f45368abc..2587bde187 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -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");