diff options
Diffstat (limited to 'Build/source/texk/kpathsea')
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 11 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/Makefile.am | 9 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/Makefile.in | 12 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/cnf.c | 24 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/doc/kpathsea.info | 127 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/doc/kpathsea.texi | 24 | ||||
-rwxr-xr-x | Build/source/texk/kpathsea/tests/cnfprog.test | 23 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf | 13 |
8 files changed, 168 insertions, 75 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index 62726b7aff0..91c0d93e2b7 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,14 @@ +2019-08-13 Karl Berry <karl@freefriends.org> + + * cnf.c (do_line): warn about a program name qualifier which is + empty or contains one of our usual special characters: .{}$;: + since it is probably a misparsing, especially if the = is omitted. + Report from Johannes Kunde, 1 Aug 2019 20:57:14. + * Makefile.am (TESTS): new tests/cnfprog.test + (cnfprog.log): another target for kpsewhich. + (EXTRA_DIST): add tests/cnfprog/texmf.cnf. + * doc/kpathsea.texi (Config files): mention example of above. + 2019-08-09 Karl Berry <karl@freefriends.org> * texmf.cnf (log_openout): new configuration variable, true diff --git a/Build/source/texk/kpathsea/Makefile.am b/Build/source/texk/kpathsea/Makefile.am index 08ccf7460bc..56cec6af422 100644 --- a/Build/source/texk/kpathsea/Makefile.am +++ b/Build/source/texk/kpathsea/Makefile.am @@ -307,17 +307,20 @@ uninstall-hook: uninstall-bin-links AM_TESTS_ENVIRONMENT = LN_S='$(LN_S)'; export LN_S; AM_TESTS_ENVIRONMENT += LT_OBJDIR='$(LT_OBJDIR)'; export LT_OBJDIR; # -TESTS = tests/cnfline.test tests/cnfnewline.test tests/kpseaccess.test +TESTS = tests/cnfline.test tests/cnfnewline.test tests/cnfprog.test +TESTS += tests/kpseaccess.test TESTS += tests/kpsereadlink.test tests/kpsestat.test tests/kpsewhich.test # -tests/cnfline.log tests/cnfnewline.log tests/kpsewhich.log: kpsewhich$(EXEEXT) +tests/cnfline.log tests/cnfnewline.log tests/cnfprog.log \ + tests/kpsewhich.log: kpsewhich$(EXEEXT) tests/kpseaccess.log: kpseaccess$(EXEEXT) tests/kpsereadlink.log: kpsereadlink$(EXEEXT) tests/kpsestat.log: kpsestat$(EXEEXT) # EXTRA_DIST += $(TESTS) -EXTRA_DIST += tests/cnfnewline/texmf.cnf EXTRA_DIST += tests/cnfline/texmf.cnf +EXTRA_DIST += tests/cnfnewline/texmf.cnf +EXTRA_DIST += tests/cnfprog/texmf.cnf # Rebuild rebuild_prereq = diff --git a/Build/source/texk/kpathsea/Makefile.in b/Build/source/texk/kpathsea/Makefile.in index 3a721c4013c..6f62d6f9acf 100644 --- a/Build/source/texk/kpathsea/Makefile.in +++ b/Build/source/texk/kpathsea/Makefile.in @@ -759,7 +759,8 @@ top_srcdir = @top_srcdir@ SUBDIRS = . doc man $(am__append_6) # EXTRA_DIST = PROJECTS putenv.c bsnl.awk cnf-to-paths.awk $(TESTS) \ - tests/cnfnewline/texmf.cnf tests/cnfline/texmf.cnf mktex.cnf + tests/cnfline/texmf.cnf tests/cnfnewline/texmf.cnf \ + tests/cnfprog/texmf.cnf mktex.cnf AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/.. AM_CFLAGS = $(WARNING_CFLAGS) lib_LTLIBRARIES = libkpathsea.la @@ -866,9 +867,9 @@ bin_links = mktexlsr:texhash AM_TESTS_ENVIRONMENT = LN_S='$(LN_S)'; export LN_S; \ LT_OBJDIR='$(LT_OBJDIR)'; export LT_OBJDIR; # -TESTS = tests/cnfline.test tests/cnfnewline.test tests/kpseaccess.test \ - tests/kpsereadlink.test tests/kpsestat.test \ - tests/kpsewhich.test +TESTS = tests/cnfline.test tests/cnfnewline.test tests/cnfprog.test \ + tests/kpseaccess.test tests/kpsereadlink.test \ + tests/kpsestat.test tests/kpsewhich.test # Rebuild rebuild_prereq = @@ -2533,7 +2534,8 @@ install-exec-hook: install-bin-links uninstall-hook: uninstall-bin-links # -tests/cnfline.log tests/cnfnewline.log tests/kpsewhich.log: kpsewhich$(EXEEXT) +tests/cnfline.log tests/cnfnewline.log tests/cnfprog.log \ + tests/kpsewhich.log: kpsewhich$(EXEEXT) tests/kpseaccess.log: kpseaccess$(EXEEXT) tests/kpsereadlink.log: kpsereadlink$(EXEEXT) tests/kpsestat.log: kpsestat$(EXEEXT) diff --git a/Build/source/texk/kpathsea/cnf.c b/Build/source/texk/kpathsea/cnf.c index def8f97c77e..14f7e04e706 100644 --- a/Build/source/texk/kpathsea/cnf.c +++ b/Build/source/texk/kpathsea/cnf.c @@ -103,7 +103,7 @@ do_line (kpathsea kpse, string line, boolean env_progname) strncpy (var, start, len); var[len] = 0; - /* If the variable is qualified with a program name, find out which. */ + /* If the variable is qualified with a program name, extract it. */ while (*line && ISSPACE (*line)) line++; if (*line == '.') { @@ -115,12 +115,30 @@ do_line (kpathsea kpse, string line, boolean env_progname) while (*line && !ISSPACE (*line) && *line != '=') line++; - /* It's annoying to repeat all this, but making a tokenizing - subroutine would be just as long and annoying. */ + /* The program name is what's in between. */ len = line - start; prog = (string) xmalloc (len + 1); strncpy (prog, start, len); prog[len] = 0; + /* If the name is empty, or contains one of our usual special + characters, it's probably a mistake. For instance, a cnf line + foo .;bar + is interpreted as a program name ";bar", because the = between + the variable name and value is optional. We don't try to guess + the user's intentions, but just give a warning. */ + if (len == 0) { + return ("Empty program name qualifier"); + } else { + unsigned i; + for (i = 0; i < len; i++) { + if (prog[i] == '$' || prog[i] == '{' || prog[i] == '}' + || IS_KPSE_SEP (prog[i])) { + string msg = xmalloc (50); + sprintf (msg, "Unlikely character %c in program name", prog[i]); + return msg; + } + } + } } /* Skip whitespace, an optional =, more whitespace. */ diff --git a/Build/source/texk/kpathsea/doc/kpathsea.info b/Build/source/texk/kpathsea/doc/kpathsea.info index 19aca80756b..959873b6e8c 100644 --- a/Build/source/texk/kpathsea/doc/kpathsea.info +++ b/Build/source/texk/kpathsea/doc/kpathsea.info @@ -522,8 +522,8 @@ mentions most features. The format of 'texmf.cnf' files follows: * Comments start with '%', either at the beginning of a line or preceded by whitespace, and continue to the end of the line. That - is, as with most shells, a '%' in the "middle" of a value does not - start a comment. Examples: + is, similar to most shells, a '%' in the "middle" of a value does + not start a comment. Examples: % this is a comment var = a%b % but the value of var will be "a%b". @@ -543,11 +543,12 @@ mentions most features. The format of 'texmf.cnf' files follows: * The VARIABLE name may contain any character other than whitespace, '=', or '.', but sticking to 'A-Za-z_' is safest. - * If '.PROGNAME' is present, the definition only applies if the - program that is running is named (i.e., the last component of - 'argv[0]' is) PROGNAME or 'PROGNAME.{exe,bat,cmd,...}'. Most - notably, this allows different flavors of TeX to have different - search paths. + * If '.PROGNAME' is present (preceding spaces are ignored), the + definition only applies if the program that is running is named + (i.e., the last component of 'argv[0]' is) PROGNAME or + 'PROGNAME.{exe,bat,cmd,...}'. Most notably, this allows different + flavors of TeX to have different search paths. The PROGNAME value + is used literally, without variable or other expansions. * VALUE may contain any characters except '%' and '@'. (These restrictions are only necessary because of the processing done on @@ -579,6 +580,16 @@ However, there seemed little advantage in this, since all the information would have to passed back to Kpathsea and parsed there anyway, since the 'sh' process couldn't affect its parent's environment. + The combination of spaces being ignored before the '.' of a program +name qualifer and the optional '=' for the assignment has an unexpected +consequence: if the value begins with a literal '.' and the '=' is +omitted, the intended value is interpreted as a program name. For +example, a line 'var .;/some/path' is taken as an empty value for 'var' +running under the program named ';/some/path'. To diagnose this, +Kpathsea warns if the program name contains a path separator or other +special character. The simplest way to avoid the problem is to use the +'='. + The implementation of all this is in 'kpathsea/cnf.c'. @@ -3256,7 +3267,7 @@ Index (line 46) * cmr10, as fallback font: Fallback font. (line 15) * cmr10.vf: Searching overview. (line 31) -* cnf.c: Config files. (line 86) +* cnf.c: Config files. (line 97) * cnf.h: Programming with config files. (line 27) * comments, in fontmap files: Fontmap. (line 27) @@ -3285,7 +3296,7 @@ Index * config.status: Bug checklist. (line 27) * configuration bugs: Bug checklist. (line 27) * configuration file, source for path: Path sources. (line 20) -* configuration files as shell scripts.: Config files. (line 79) +* configuration files as shell scripts.: Config files. (line 80) * configuration of mktex scripts: mktex configuration. (line 6) * configure options for mktex scripts: mktex configuration. (line 12) * context diff: Bug checklist. (line 52) @@ -3676,7 +3687,7 @@ Index (line 49) * resolutions, last-resort: Fallback font. (line 6) * retrieving TeX: unixtex.ftp. (line 6) -* right-hand side of variable assignments: Config files. (line 56) +* right-hand side of variable assignments: Config files. (line 57) * RISINPUTS: Supported file formats. (line 173) * Rokicki, Tom: History. (line 12) @@ -3700,7 +3711,7 @@ Index * setgid scripts: Security. (line 40) * SFDFONTS: Supported file formats. (line 177) -* shell scripts as configuration files: Config files. (line 79) +* shell scripts as configuration files: Config files. (line 80) * shell variables: Variable expansion. (line 17) * shell_escape, example for code: Programming with config files. (line 10) @@ -3929,52 +3940,52 @@ Node: Path searching16905 Node: Searching overview17632 Node: Path sources21451 Node: Config files22677 -Node: Path expansion26604 -Node: Default expansion27557 -Node: Variable expansion29627 -Node: Tilde expansion31028 -Node: Brace expansion32008 -Node: KPSE_DOT expansion32947 -Node: Subdirectory expansion33460 -Node: Casefolding search35814 -Node: Casefolding rationale36583 -Node: Casefolding examples37922 -Node: Filename database42972 -Node: ls-R44030 -Node: Filename aliases47706 -Node: Database format48884 -Node: Invoking kpsewhich49897 -Node: Path searching options50852 -Node: Specially-recognized files60450 -Node: Auxiliary tasks61805 -Node: Standard options65530 -Node: TeX support65886 -Node: Supported file formats67240 -Node: File lookup74905 -Node: Glyph lookup76654 -Node: Basic glyph lookup77778 -Node: Fontmap78658 -Node: Fallback font81187 -Node: Suppressing warnings82099 -Node: mktex scripts83226 -Node: mktex configuration84441 -Node: mktex script names90244 -Node: mktex script arguments91630 -Node: Programming92509 -Node: Programming overview93082 -Node: Calling sequence95943 -Node: Program-specific files102475 -Node: Programming with config files103498 -Node: Reporting bugs105085 -Node: Bug checklist105763 -Node: Mailing lists109235 -Node: Debugging109910 -Node: Logging114987 -Node: Common problems116854 -Node: Unable to find files117331 -Node: Slow path searching119741 -Node: Unable to generate fonts121116 -Node: TeX or Metafont failing123587 -Node: Index124789 +Node: Path expansion27283 +Node: Default expansion28236 +Node: Variable expansion30306 +Node: Tilde expansion31707 +Node: Brace expansion32687 +Node: KPSE_DOT expansion33626 +Node: Subdirectory expansion34139 +Node: Casefolding search36493 +Node: Casefolding rationale37262 +Node: Casefolding examples38601 +Node: Filename database43651 +Node: ls-R44709 +Node: Filename aliases48385 +Node: Database format49563 +Node: Invoking kpsewhich50576 +Node: Path searching options51531 +Node: Specially-recognized files61129 +Node: Auxiliary tasks62484 +Node: Standard options66209 +Node: TeX support66565 +Node: Supported file formats67919 +Node: File lookup75584 +Node: Glyph lookup77333 +Node: Basic glyph lookup78457 +Node: Fontmap79337 +Node: Fallback font81866 +Node: Suppressing warnings82778 +Node: mktex scripts83905 +Node: mktex configuration85120 +Node: mktex script names90923 +Node: mktex script arguments92309 +Node: Programming93188 +Node: Programming overview93761 +Node: Calling sequence96622 +Node: Program-specific files103154 +Node: Programming with config files104177 +Node: Reporting bugs105764 +Node: Bug checklist106442 +Node: Mailing lists109914 +Node: Debugging110589 +Node: Logging115666 +Node: Common problems117533 +Node: Unable to find files118010 +Node: Slow path searching120420 +Node: Unable to generate fonts121795 +Node: TeX or Metafont failing124266 +Node: Index125468 End Tag Table diff --git a/Build/source/texk/kpathsea/doc/kpathsea.texi b/Build/source/texk/kpathsea/doc/kpathsea.texi index ff8fdbe8725..db619f50129 100644 --- a/Build/source/texk/kpathsea/doc/kpathsea.texi +++ b/Build/source/texk/kpathsea/doc/kpathsea.texi @@ -647,7 +647,7 @@ mentions most features. The format of @file{texmf.cnf} files follows: @cindex comments, in @file{texmf.cnf} Comments start with @samp{%}, either at the beginning of a line or preceded by whitespace, and continue to the end of the line. That is, -as with most shells, a @samp{%} in the ``middle'' of a value does not +similar to most shells, a @samp{%} in the ``middle'' of a value does not start a comment. Examples: @example @@ -681,11 +681,13 @@ lines is not ignored. The @var{variable} name may contain any character other than whitespace, @samp{=}, or @samp{.}, but sticking to @samp{A-Za-z_} is safest. -@item If @samp{.@var{progname}} is present, the definition only -applies if the program that is running is named (i.e., the last -component of @code{argv[0]} is) @var{progname} or -@file{@var{progname}.@{exe,bat,cmd,...@}}. Most notably, this allows -different flavors of @TeX{} to have different search paths. +@item If @samp{.@var{progname}} is present (preceding spaces are +ignored), the definition only applies if the program that is running +is named (i.e., the last component of @code{argv[0]} is) +@var{progname} or @file{@var{progname}.@{exe,bat,cmd,...@}}. Most +notably, this allows different flavors of @TeX{} to have different +search paths. The @var{progname} value is used literally, without +variable or other expansions. @item @cindex right-hand side of variable assignments @@ -727,6 +729,16 @@ advantage in this, since all the information would have to passed back to Kpathsea and parsed there anyway, since the @code{sh} process couldn't affect its parent's environment. +The combination of spaces being ignored before the @code{.} of a +program name qualifer and the optional @samp{=} for the assignment has +an unexpected consequence: if the value begins with a literal @samp{.} +and the @samp{=} is omitted, the intended value is interpreted as a +program name. For example, a line @code{var .;/some/path} is taken as +an empty value for @code{var} running under the program named +@samp{;/some/path}. To diagnose this, Kpathsea warns if the program +name contains a path separator or other special character. The +simplest way to avoid the problem is to use the @code{=}. + @flindex cnf.c The implementation of all this is in @file{kpathsea/cnf.c}. diff --git a/Build/source/texk/kpathsea/tests/cnfprog.test b/Build/source/texk/kpathsea/tests/cnfprog.test new file mode 100755 index 00000000000..08f472e2b34 --- /dev/null +++ b/Build/source/texk/kpathsea/tests/cnfprog.test @@ -0,0 +1,23 @@ +#!/bin/sh -vx +# $Id$ +# Copyright 2019 Karl Berry <tex-live@tug.org> +# You may freely use, modify and/or distribute this file. +# Test strange program name qualifiers which should give warnings. + +cnf_dir=$srcdir/tests/cnfprog + +# But for the rest, just use the environment, to keep things simpler. +TEXMFCNF=$cnf_dir; export TEXMFCNF + +# Make sure we get expected values from the test texmf.cnf. +errfile=cnfprog.err +val=`./kpsewhich --var-value=noequals 2>$errfile` + +# the vaiable should not have any value. +test -z "$val" || exit 1 + +grep 'Empty program name qualifier' $errfile || exit 1 +grep 'Unlikely character ;' $errfile || exit 1 +grep 'Unlikely character \$' $errfile || exit 1 + +exit 0 diff --git a/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf b/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf new file mode 100644 index 00000000000..9b7bd3c6219 --- /dev/null +++ b/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf @@ -0,0 +1,13 @@ +# $Id$ +# Public domain. This tiny texmf.cnf is for kpathsea/tests/cnfprog.test. + +# An empty program name is warned about (as of August 2019). +justdot. = dval + +# Contrary to appearances, this is interpreted as a program name ";val", +# with no value. A warning is issued. +noequals .;qval + +# Similarly, the "${var}" is a literal string here, not expanded. +# Again, a warning is issued. +braceprog.${var} = bval |