summaryrefslogtreecommitdiff
path: root/Build/source/texk
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk')
-rw-r--r--Build/source/texk/web2c/mplibdir/mpost.w24
-rw-r--r--Build/source/texk/web2c/pmpostdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/pmpostdir/pmpost.ch19
3 files changed, 38 insertions, 9 deletions
diff --git a/Build/source/texk/web2c/mplibdir/mpost.w b/Build/source/texk/web2c/mplibdir/mpost.w
index c419cdc25a2..4c4d671df21 100644
--- a/Build/source/texk/web2c/mplibdir/mpost.w
+++ b/Build/source/texk/web2c/mplibdir/mpost.w
@@ -48,6 +48,7 @@ static char *job_area = NULL;
static int dvitomp_only = 0;
static int ini_version_test = false;
string output_directory; /* Defaults to NULL. */
+static boolean restricted_mode = false;
@<getopt structures@>;
@<Declarations@>;
@@ -111,6 +112,9 @@ static void mpost_run_editor (MP mp, char *fname, int fline) {
int dontchange = 0;
#endif
+ if (restricted_mode)
+ return;
+
sdone = ddone = false;
edit_value = kpse_var_value ("MPEDIT");
if (edit_value == NULL)
@@ -332,6 +336,10 @@ void recorder_start(char *jobname) {
static int mpost_run_make_mpx (MP mp, char *mpname, char *mpxname) {
int ret;
char *cnf_cmd = kpse_var_value ("MPXCOMMAND");
+ if (restricted_mode) {
+ /* In the restricted mode, just return success */
+ return 0;
+ }
if (cnf_cmd != NULL && (strcmp (cnf_cmd, "0")==0)) {
/* If they turned off this feature, just return success. */
ret = 0;
@@ -813,6 +821,7 @@ static struct option mpost_options[]
{ "progname", 1, 0, 0 },
{ "version", 0, 0, 0 },
{ "recorder", 0, &recorder_enabled, 1 },
+ { "restricted", 0, 0, 0 },
{ "file-line-error-style", 0, 0, 0 },
{ "no-file-line-error-style", 0, 0, 0 },
{ "file-line-error", 0, 0, 0 },
@@ -894,11 +903,15 @@ static struct option mpost_options[]
} else {
fprintf(stdout,"Ignoring unknown argument `%s' to --numbersystem\n", optarg);
}
+ } else if (ARGUMENT_IS ("restricted")) {
+ restricted_mode = true;
+ mpost_tex_program = NULL;
} else if (ARGUMENT_IS("troff") ||
ARGUMENT_IS("T")) {
options->troff_mode = (int)true;
} else if (ARGUMENT_IS ("tex")) {
- mpost_tex_program = optarg;
+ if (!restricted_mode)
+ mpost_tex_program = optarg;
} else if (ARGUMENT_IS("file-line-error") ||
ARGUMENT_IS("file-line-error-style")) {
options->file_line_error_style=true;
@@ -1014,6 +1027,7 @@ fprintf(stdout,
" the bits of NUMBER\n"
" -mem=MEMNAME or &MEMNAME use MEMNAME instead of program name or a %%& line\n"
" -recorder enable filename recorder\n"
+" -restricted be secure: disable tex, makempx and editor commands\n"
" -troff set prologues:=1 and assume TEXPROGRAM is really troff\n"
" -s INTERNAL=\"STRING\" set internal INTERNAL to the string value STRING\n"
" -s INTERNAL=NUMBER set internal INTERNAL to the integer value NUMBER\n"
@@ -1368,6 +1382,10 @@ main (int argc, char **argv)
options->print_found_names = (int)true;
{
const char *base = cleaned_invocation_name(argv[0]);
+ if (FILESTRCASEEQ(base, "rmpost")){
+ base++;
+ restricted_mode = true;
+ }
if (FILESTRCASEEQ(base, "dvitomp"))
dvitomp_only=1;
}
@@ -1400,7 +1418,9 @@ main (int argc, char **argv)
if (!nokpse) {
kpse_set_program_enabled (kpse_mem_format, MAKE_TEX_FMT_BY_DEFAULT,
kpse_src_compile);
- kpse_set_program_name(argv[0], user_progname);
+ kpse_set_program_name(argv[0], user_progname);
+ if (FILESTRCASEEQ(kpse_program_name, "rmpost"))
+ kpse_program_name++;
}
@= /*@@=nullpass@@*/ @>
if(putenv(xstrdup("engine=metapost")))
diff --git a/Build/source/texk/web2c/pmpostdir/ChangeLog b/Build/source/texk/web2c/pmpostdir/ChangeLog
index d666e5734c5..37f3c87234c 100644
--- a/Build/source/texk/web2c/pmpostdir/ChangeLog
+++ b/Build/source/texk/web2c/pmpostdir/ChangeLog
@@ -1,3 +1,7 @@
+2016-12-02 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pmpost.ch: Adapt to the restricted mode in the latest mpost.w.
+
2016-03-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* pmp.ch: Adapt to MetaPost 1.9991.
diff --git a/Build/source/texk/web2c/pmpostdir/pmpost.ch b/Build/source/texk/web2c/pmpostdir/pmpost.ch
index 9e1bb4d43a4..a7add6f26fe 100644
--- a/Build/source/texk/web2c/pmpostdir/pmpost.ch
+++ b/Build/source/texk/web2c/pmpostdir/pmpost.ch
@@ -244,6 +244,12 @@ else
@z
@x
+ if (FILESTRCASEEQ(base, "rmpost")){
+@y
+ if (FILESTRCASEEQ(base, "r" P_UP "mpost")){
+@z
+
+@x
if (FILESTRCASEEQ(base, "dvitomp"))
@y
if (FILESTRCASEEQ(base, P_UP "dvitomp"))
@@ -270,13 +276,12 @@ else
if (dvitomp_only) {
@<Read and set dvitomp command line options@>;
} else {
-#ifdef WIN32
- options->mem_name =
- strlwr(kpse_program_basename(argv[0]));
-#else
- options->mem_name =
- kpse_program_basename(argv[0]);
-#endif
+@z
+
+@x
+ if (FILESTRCASEEQ(kpse_program_name, "rmpost"))
+@y
+ if (FILESTRCASEEQ(kpse_program_name, "r" P_UP "mpost"))
@z
@x