summaryrefslogtreecommitdiff
path: root/scheduler
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2016-01-25 14:43:52 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2016-01-25 14:43:52 +0000
commit2dd940185b68583cc33c5a91b7ee21dec3c448e7 (patch)
treed2b22a99e1e8d6874ce9da74962b44d688a3d191 /scheduler
parent3517cb23485f25c4425129bc3b24c64a4a46b7c1 (diff)
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
Diffstat (limited to 'scheduler')
-rw-r--r--scheduler/main.c32
-rw-r--r--scheduler/process.c2
2 files changed, 32 insertions, 2 deletions
diff --git a/scheduler/main.c b/scheduler/main.c
index 0b171b504..225892e62 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 1f45368ab..2587bde18 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");