texlive[51875] Build/source/texk/kpathsea: warn about unusual

commits+karl at tug.org commits+karl at tug.org
Wed Aug 14 00:43:09 CEST 2019


Revision: 51875
          http://tug.org/svn/texlive?view=revision&revision=51875
Author:   karl
Date:     2019-08-14 00:43:09 +0200 (Wed, 14 Aug 2019)
Log Message:
-----------
warn about unusual characters in program name qualifiers

Modified Paths:
--------------
    trunk/Build/source/texk/kpathsea/ChangeLog
    trunk/Build/source/texk/kpathsea/Makefile.am
    trunk/Build/source/texk/kpathsea/Makefile.in
    trunk/Build/source/texk/kpathsea/cnf.c
    trunk/Build/source/texk/kpathsea/doc/kpathsea.info
    trunk/Build/source/texk/kpathsea/doc/kpathsea.texi

Added Paths:
-----------
    trunk/Build/source/texk/kpathsea/tests/cnfprog/
    trunk/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf
    trunk/Build/source/texk/kpathsea/tests/cnfprog.test

Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog	2019-08-13 20:54:58 UTC (rev 51874)
+++ trunk/Build/source/texk/kpathsea/ChangeLog	2019-08-13 22:43:09 UTC (rev 51875)
@@ -1,3 +1,14 @@
+2019-08-13  Karl Berry  <karl at 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 at freefriends.org>
 
 	* texmf.cnf (log_openout): new configuration variable, true

Modified: trunk/Build/source/texk/kpathsea/Makefile.am
===================================================================
--- trunk/Build/source/texk/kpathsea/Makefile.am	2019-08-13 20:54:58 UTC (rev 51874)
+++ trunk/Build/source/texk/kpathsea/Makefile.am	2019-08-13 22:43:09 UTC (rev 51875)
@@ -307,17 +307,20 @@
 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/cnfline/texmf.cnf
 EXTRA_DIST += tests/cnfnewline/texmf.cnf
-EXTRA_DIST += tests/cnfline/texmf.cnf
+EXTRA_DIST += tests/cnfprog/texmf.cnf
 
 # Rebuild
 rebuild_prereq =

Modified: trunk/Build/source/texk/kpathsea/Makefile.in
===================================================================
--- trunk/Build/source/texk/kpathsea/Makefile.in	2019-08-13 20:54:58 UTC (rev 51874)
+++ trunk/Build/source/texk/kpathsea/Makefile.in	2019-08-13 22:43:09 UTC (rev 51875)
@@ -759,7 +759,8 @@
 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 @@
 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 @@
 
 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)

Modified: trunk/Build/source/texk/kpathsea/cnf.c
===================================================================
--- trunk/Build/source/texk/kpathsea/cnf.c	2019-08-13 20:54:58 UTC (rev 51874)
+++ trunk/Build/source/texk/kpathsea/cnf.c	2019-08-13 22:43:09 UTC (rev 51875)
@@ -103,7 +103,7 @@
   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 @@
     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.  */

Modified: trunk/Build/source/texk/kpathsea/doc/kpathsea.info
===================================================================
--- trunk/Build/source/texk/kpathsea/doc/kpathsea.info	2019-08-13 20:54:58 UTC (rev 51874)
+++ trunk/Build/source/texk/kpathsea/doc/kpathsea.info	2019-08-13 22:43:09 UTC (rev 51875)
@@ -522,8 +522,8 @@
 
    * 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 @@
    * 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 @@
 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 @@
                                                               (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 @@
 * 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 @@
                                                               (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 @@
 * 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: 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

Modified: trunk/Build/source/texk/kpathsea/doc/kpathsea.texi
===================================================================
--- trunk/Build/source/texk/kpathsea/doc/kpathsea.texi	2019-08-13 20:54:58 UTC (rev 51874)
+++ trunk/Build/source/texk/kpathsea/doc/kpathsea.texi	2019-08-13 22:43:09 UTC (rev 51875)
@@ -647,7 +647,7 @@
 @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 @@
 The @var{variable} name may contain any character other than whitespace,
 @samp{=}, or @samp{.}, but sticking to @samp{A-Za-z_} is safest.
 
- at item If @samp{. at 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
- at file{@var{progname}.@{exe,bat,cmd,...@}}.  Most notably, this allows
-different flavors of @TeX{} to have different search paths.
+ at item If @samp{. at 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)
+ at 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 @@
 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
+ at 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}.
 

Added: trunk/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf
===================================================================
--- trunk/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf	                        (rev 0)
+++ trunk/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf	2019-08-13 22:43:09 UTC (rev 51875)
@@ -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


Property changes on: trunk/Build/source/texk/kpathsea/tests/cnfprog/texmf.cnf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision
\ No newline at end of property
Added: trunk/Build/source/texk/kpathsea/tests/cnfprog.test
===================================================================
--- trunk/Build/source/texk/kpathsea/tests/cnfprog.test	                        (rev 0)
+++ trunk/Build/source/texk/kpathsea/tests/cnfprog.test	2019-08-13 22:43:09 UTC (rev 51875)
@@ -0,0 +1,23 @@
+#!/bin/sh -vx
+# $Id$
+# Copyright 2019 Karl Berry <tex-live at 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


Property changes on: trunk/Build/source/texk/kpathsea/tests/cnfprog.test
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision
\ No newline at end of property


More information about the tex-live-commits mailing list