diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-12-02 23:00:22 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-12-02 23:00:22 +0000 |
commit | 8e96ca083471a730df14fb680fb72ce9302dd84a (patch) | |
tree | 2ff222275f7c9381a06d8164deb91fbababbc4f1 /Build/source/texk/web2c/mplibdir | |
parent | 457a8e33ef7c5bb33b3d68f9aec793f92916ca69 (diff) |
mplibdir: sync with the upstream: introduce restricted mode
git-svn-id: svn://tug.org/texlive/trunk@42625 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mplibdir')
-rw-r--r-- | Build/source/texk/web2c/mplibdir/mpost.w | 24 |
1 files changed, 22 insertions, 2 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"))) |