diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /obsolete/fonts/utilities |
Initial commit
Diffstat (limited to 'obsolete/fonts/utilities')
-rw-r--r-- | obsolete/fonts/utilities/mtype13/README | 20 | ||||
-rw-r--r-- | obsolete/fonts/utilities/safemtpk/00-README | 20 | ||||
-rw-r--r-- | obsolete/fonts/utilities/safemtpk/MakeTeXMF | 68 | ||||
-rw-r--r-- | obsolete/fonts/utilities/safemtpk/MakeTeXPK | 281 | ||||
-rw-r--r-- | obsolete/fonts/utilities/safemtpk/MakeTeXTFM | 246 | ||||
-rw-r--r-- | obsolete/fonts/utilities/safemtpk/append_db | 44 | ||||
-rw-r--r-- | obsolete/fonts/utilities/safemtpk/maketex.c | 89 | ||||
-rw-r--r-- | obsolete/fonts/utilities/safemtpk/safeMakeTeXPK.tex | 319 |
8 files changed, 1087 insertions, 0 deletions
diff --git a/obsolete/fonts/utilities/mtype13/README b/obsolete/fonts/utilities/mtype13/README new file mode 100644 index 0000000000..a4156e763c --- /dev/null +++ b/obsolete/fonts/utilities/mtype13/README @@ -0,0 +1,20 @@ + +``MTYPE13'' package by Wlodek Bzyl <matwb@univ.gda.pl> + +November 2002 + +The package contains MetaPost libraries, bash and +Perl scripts which help in programming and +creation of Type 1 and Type 3 fonts under Linux. + +The Type 1 part was written for DOS by JNS team +(B. Jackowski, J. M. Nowacki, and P. Strzelczyk). +and is available from + + ftp://bop.eps.gda.pl/pub/metatype1 + + +February 2004 + +Updated to METATYPE1 ver044. + diff --git a/obsolete/fonts/utilities/safemtpk/00-README b/obsolete/fonts/utilities/safemtpk/00-README new file mode 100644 index 0000000000..0fa02c8150 --- /dev/null +++ b/obsolete/fonts/utilities/safemtpk/00-README @@ -0,0 +1,20 @@ + +This directory contains a note, safeMakeTeXPK.tex, which describes how +to resolve Unix security concerns arising when using an automatic +bitmap generation in TeX systems which rely on MakeTeXPK and similar +scripts. + +File maketex.c is a C source of a small program you need to compile +in order to use a described approach. + +MakeTeXMF, MakeTeXPK, MakeTeXTFM and append_db are modification of +scripts from /usr/local/tex/scripts-0.2/bin/ directory in +teTeX distribution (version 0.2) for Linux prepared by +Thomas Esser <te@informatik.uni-hannover.de>. If you happen to run +somewhat different variants use them as an example of changes +you need to perform. + + Enjoy safe computing, :-) + Michal Jaegermann + michal@ellpspace.math.ualberta.ca + michal@gortel.phys.ualberta.ca diff --git a/obsolete/fonts/utilities/safemtpk/MakeTeXMF b/obsolete/fonts/utilities/safemtpk/MakeTeXMF new file mode 100644 index 0000000000..e9df862605 --- /dev/null +++ b/obsolete/fonts/utilities/safemtpk/MakeTeXMF @@ -0,0 +1,68 @@ +#!/bin/sh + +TOOLS="/usr/local/tex/kpsetools-0.2/bin" +SCRIPTS="/usr/local/tex/scripts-0.2/bin" + +KPSEXPAND="$TOOLS/kpsexpand" +APPENDDB="$SCRIPTS/append_db" + +MD="/bin/mkdir" +CHM="/bin/chmod" +MV="/bin/mv -f" + +progname=`basename $0` + +#DIR_PERMS=1777 +DIR_PERMS=755 +FILE_PERMS=444 + +if test $# -lt 1 ; then + echo "Usage: $progname name." >&2 + exit 1 +fi + +TEXMF=`$KPSEXPAND '$TEXMF'` +dcfontdir="$TEXMF/fonts/public/dc/src" +ls_R="$TEXMF/ls-R" + +test -d "$dcfontdir" || ($MD "$dcfontdir" ; $CHM "$DIR_PERMS" "$dcfontdir") +cd "$dcfontdir" || exit 1 + +NAME="`basename $1 .mf`" +rootname=`echo "$NAME" | sed 's/[0-9]*$//'` +pointsize=`echo "$NAME" | sed "s/^$rootname//"` + +case "$NAME" in +dc*) ;; +*) exit +esac + +case "$pointsize" in +"") ;; +11) realsize=10.95444 ;; # \magstephalf +14) realsize=14.4 ;; # \magstep2 +17) realsize=17.28 ;; # \magstep3 +20) realsize=20.74 ;; # \magstep4 +25) realsize=24.88 ;; # \magstep5 +*) realsize="$pointsize" ;; +esac + +mfname="$NAME.mf" +if [ -f "$mfname" ] ; then + echo "$dcfontdir/$mfname already exists!" >&2 + echo $dcfontdir/$mfname + $APPENDDB "$dcfontdir" "$mfname" + exit +fi + +cat > "$mfname.tmp$$" <<EOF +if unknown dxbase: input dxbase fi; +gensize:=$realsize; +generate $rootname; +EOF + +$CHM "$FILE_PERMS" "$mfname.tmp$$" +$MV "$mfname.tmp$$" "$mfname" + +echo "$dcfontdir/$mfname" +$APPENDDB "$dcfontdir" "$mfname" diff --git a/obsolete/fonts/utilities/safemtpk/MakeTeXPK b/obsolete/fonts/utilities/safemtpk/MakeTeXPK new file mode 100644 index 0000000000..8f080ca96f --- /dev/null +++ b/obsolete/fonts/utilities/safemtpk/MakeTeXPK @@ -0,0 +1,281 @@ +#!/bin/sh +# This script must echo the name of the generated PK file (and nothing +# else) to standard output. Yes, this is different from the original dvips. +# +# Parameters: +# name dpi bdpi magnification [mode [destdir]] +# +# `name' is the base name of the font, such as `cmr10'. +# `dpi' is the resolution the font is needed at. +# `bdpi' is the base resolution, used to intuit the mode to use. +# `magnification' is a string to pass to MF as the value of `mag'. +# `mode', if supplied, is the mode to use. Unless it's `default', in +# which case we guess. (This is so people can specify a destdir +# without a mode.) +# `destdir', if supplied, is either the absolute directory name to use +# (if it starts with a /) or relative to the default DESTDIR (if not). + +TOOLS="/usr/local/tex/kpsetools-0.2/bin" +SCRIPTS="/usr/local/tex/scripts-0.2/bin" + +KPSEXPAND="$TOOLS/kpsexpand" +KPSEWHICH="$KPSEXPAND -w" +APPENDDB="$SCRIPTS/append_db" + +MF="/usr/local/bin/mf" +GSFTOPK="/usr/local/bin/gsftopk" +GFK="/usr/local/bin/gftopk" + +AWK="/usr/bin/awk" +EGREP="/usr/bin/egrep" +GREP="/usr/bin/grep" +RM="/bin/rm -f" +MV="/bin/mv -f" +MD="/bin/mkdir" +CHM="/bin/chmod" + +# The root of where to put the new file. (Using the sh construct +# ${var=value} is the tersest construct that lets an environment +# variable `var' override the value given here.) + +progname="`basename $0`" +TEXMF=`$KPSEXPAND '$TEXMF'` +DESTROOT=${MTPK_DESTROOT-"$TEXMF/fonts"} + +# Define to `gsftopk' or `ps2pk' or whatever to make PK files for +# PostScript fonts. If this is defined, PSMAPFILE must also be defined to +# be your psfonts.map file or some equivalent. +ps_to_pk=$GSFTOPK +PSMAPFILE=`$KPSEWHICH dvips_config psfonts.map 2>&-` + +# Location of the files that map font name parts to directory names. +NAMEMAPDIR="$TEXMF/fontmaps" + +# If this directory doesn't exist, the DC fonts won't be attempted. +dcfontdir="$TEXMF/fonts/public/dc" + +# If this directory doesn't exist, the Sauter stuff won't be attempted. +sauterdir="$TEXMF/fonts/public/sauter" + +# If the true typeface directory cannot be determined from the fontname, +# the files are installed here, relative to $DESTROOT. +# TE: change: pk will be appended later +default_namepart=tmp + +# TEMPDIR needs to be unique for each process because of the possibility +# of simultaneous processes running this script. +TEMPDIR="${TMPDIR-/tmp}/mtpk.$$" +ls_R="$TEXMF/ls-R" + + +DIR_PERMS=755 +#DIR_PERMS=1777 +FILE_PERMS=444 + + +if test $# -lt 4 ; then + echo "Usage: $progname name dpi bdpi mag [mode [destdir]]." >&2 + exit 1 +fi + +NAME=$1 +DPI=$2 +BDPI=$3 +MAG=$4 +MODE=$5 + +# DESTDIR is harder. +case "$6" in + "") + # Nothing specified, so try to intuit the directory from the + # fontname. First the special cases: either $NAME matches an entire + # name in special.map, or it matches the abbreviation in + # special.map and ends with a numeral (for the pointsize). + # We (painfully) use only the minimal features in original awk. + if test -r $NAMEMAPDIR/special.map ; then + namepart=`$AWK \ +'{if ($1 == NAME || (substr (NAME, 1, length ($1)) == $1 \ + && substr (NAME, length (NAME), 1) ~ /[0-9]/)) \ + { print $2 "/" $3; exit; }}' NAME="$NAME" "$NAMEMAPDIR/special.map"` + + if test -z "$namepart" ; then + # Try the normal case. Source first. + s_abbrev=`echo $NAME | cut -c 1-1` + sourcedir=`$AWK '{ if ($1 == s_abbrev) { print $2; exit; }}' \ + s_abbrev="$s_abbrev" "$NAMEMAPDIR/source.map"` + + if test -n "$sourcedir" ; then + # We found the source. Try for the typeface. + t_abbrev=`echo $NAME | cut -c 2-3` + typefacedir=`$AWK '{ if ($1 == t_abbrev) { print $2; exit; }}' \ + t_abbrev="$t_abbrev" "$NAMEMAPDIR/typeface.map"` + + if test -n "$typefacedir" ; then + # Found everything. + namepart="$sourcedir/$typefacedir" + + else + echo "$progname: Could not map typeface abbreviation $t_abbrev." >&2 + fi + else + echo "$progname: Could not map source abbreviation $s_abbrev." >&2 + fi + fi + else + # No map files. + : + fi + # If we failed for whatever reason, default to a generic subdir. + test -z "$namepart" && namepart="$default_namepart" + namepart="$namepart/pk" + + # Finally, update the parent of the installation directory. + DESTROOT="$DESTROOT/$namepart" + ;; + /*) DESTDIR="$6" ;; # Absolute, explicit destdir => use it. + *) DESTDIR="$DESTROOT/$6" ;; # Relative destdir => append to the default. +esac + +GFNAME="$NAME.${DPI}gf" +PKNAME="$NAME.${DPI}pk" + +# Clean up on normal or abnormal exit. DESTDIR changes, hence the eval. +trap "cd / ; eval $RM -r $TEMPDIR \$DESTDIR/pktmp.$$" 0 1 2 15 + +MFINPUTS="$MFINPUTS:$PWD" +DVIPSHEADERS="$DVIPSHEADERS:$PWD" +export MFINPUTS DVIPSHEADERS + +# Go to the unique working directory. +test -d "$TEMPDIR" || $MD "$TEMPDIR" +cd "$TEMPDIR" || exit 1 + +# grep for the font in $PSMAPFILE, if some ps-to-pk is claimed to be supported. +test -n "$ps_to_pk" && $EGREP \^"$NAME"'([ ]|$)' "$PSMAPFILE" >psline +if test -s psline ; then + # This is a PostScript font. + MODE=`basename $ps_to_pk` + case "$ps_to_pk" in + ps2pk*) special_part=`cat psline | sed -e 's/^.*"//' -e 's/".*$//'` + # .167 SlantFont + slant=`echo $special_part \ + | $AWK '{ if ($2 == SlantFont) print "-S" $1 }'` + extend=`echo $special_part \ + | $AWK '{ if ($2 == ExtendFont) print "-E" $1 }'` + cmd="$ps_to_pk -v -X$DPI $slant $extend $NAME" ;; + *) cmd="$ps_to_pk $NAME $DPI" ;; + esac + + # Update DESTDIR for new mode, and check if we were spuriously called. + test -z "$6" && DESTDIR="$DESTROOT/$MODE" + if test -r "$DESTDIR/$PKNAME" ; then # sigh, this is repeated below + echo "$progname: $DESTDIR/$PKNAME already exists." >&2 + append_db "$DESTDIR $PKNAME" + echo "$DESTDIR/$PKNAME" + exit 0 + fi + + echo "$progname: Running $cmd" >&2 + $cmd >&2 || { echo "$progname: $gsftopk failed." >&2 ; exit 1 ; } + +else + # If an explicit mode is not supplied, try to guess. You can get a + # list of extant modes from ftp.cs.umb.edu:pub/tex/modes.mf. + if test -z "$MODE" || test "$MODE" = default ; then + case "$BDPI" in + 85) MODE=sun ;; + 300) MODE=cx ;; + 400) MODE=nexthi ;; + 600) MODE=ljfour ;; + 1270) MODE=linolo ;; + *) echo "$progname: Can't guess mode for $BDPI dpi devices." >&2 + echo "$progname: Use a config file, or update me." >&2 + exit 1 + esac + fi + + # If no destination directory specified, install font in directory + # named for the mode. + test -z "$6" && DESTDIR="$DESTROOT/$MODE" + + if test -r $DESTDIR/$PKNAME ; then # sigh, this is repeated above + echo "$progname: $DESTDIR/$PKNAME already exists." >&2 + echo "$DESTDIR/$PKNAME" + $APPENDDB "$DESTDIR" "$PKNAME" + exit 0 + fi + + # Run Metafont. Always use plain Metafont, since reading cmbase.mf + # does not noticeably slow things down. Separate the filename from the + # rest, since we have to use ./$NAME if we generate something. + cmd="$MF \mode:=$MODE; mag:=$MAG; scrollmode; input" + echo "$progname: Running $cmd $NAME" >&2 + if $cmd "$NAME" </dev/null >&2 ; then + : # Success already. + + else + # These other cases should really be part of MakeTeXMF. + # First have to figure out the real magnification, which means + # extracting the point size from the name -- a trailing number. + rootname=`echo "$NAME" | sed 's/[0-9]*$//'` + pointsize=`echo "$NAME" | sed "s/^$rootname//"` + case "$pointsize" in + 11) realsize=10.95444 ;; # \magstephalf + 14) realsize=14.4 ;; # \magstep2 + 17) realsize=17.28 ;; # \magstep3 + 20) realsize=20.74 ;; # \magstep4 + 25) realsize=24.88 ;; # \magstep5 + *) realsize=$pointsize ;; + esac + mfname="$NAME.mf" + $RM $mfname # We are in $TEMPDIR, so this is safe. + + if test -z "$pointsize" ; then + # No point size, so it can't be a DC or Sauter font. Give up. + : + + elif echo "$NAME" | $GREP '^dc' >/dev/null ; then + echo "$progname: Trying DC font." >&2 + echo "if unknown dxbase: input dxbase fi;" >$mfname + echo "gensize:=$realsize;" >>$mfname + echo "generate $rootname;" >>$mfname + echo "$progname: Running $cmd ./$NAME" >&2 + $cmd ./$mfname </dev/null >&2 + + elif test -d $sauterdir ; then + echo "$progname: Trying interpolated/extrapolated (Sauter) font." >&2 + echo "design_size:=$realsize;" >>$mfname + echo "input b-$rootname;" >>$mfname + echo "$progname: Running $cmd ./$NAME" >&2 + $cmd "./$mfname" </dev/null >&2 + # Result should go in the sauterdir, not the cm dir. + test -z "$6" && $DESTDIR="$sauterdir/pk/$MODE" + fi # alternative mf sources + fi # first mf failed + + # If we couldn't make the font, quit. + test -r "$GFNAME" || \ + { echo "$progname: Metafont failed to make $GFNAME." >&2 ; exit 1 ; } + + # Success. Make the PK file. + $GFK "./$GFNAME" "$PKNAME" || exit 1 +fi + +# If we get here, we've succeeded; move the final font to $DESTDIR. +test -d "$DESTDIR" \ + || ($MD "$DESTDIR" ; $CHM "$DIR_PERMS" "$DESTDIR") \ + || { echo "$progname: Could not mkdir $DESTDIR." >&2 ; exit 1 ; } + +# Install the PK file carefully, since others may be working simultaneously. +$MV "$PKNAME" "$DESTDIR/pktmp.$$" \ + || { echo "$progname: Could not mv $PKNAME $DESTDIR/pktmp.$$." >&2 ; exit 1 ; } + +cd "$DESTDIR" || exit 1 +$MV "pktmp.$$" "$PKNAME" +$CHM "$FILE_PERMS" "$PKNAME" + +# If this line (or an equivalent) is not present, dvipsk/xdvik/dviljk +# will think MakeTeXPK failed. Any other output to stdout will also lose. +echo $DESTDIR/$PKNAME +$APPENDDB "$DESTDIR" "$PKNAME" +exit 0 diff --git a/obsolete/fonts/utilities/safemtpk/MakeTeXTFM b/obsolete/fonts/utilities/safemtpk/MakeTeXTFM new file mode 100644 index 0000000000..78b53fbd5f --- /dev/null +++ b/obsolete/fonts/utilities/safemtpk/MakeTeXTFM @@ -0,0 +1,246 @@ +#!/bin/sh +# This script must echo the name of the generated PK file (and nothing +# else) to standard output. Yes, this is different from the original MakeTeXPK +# +# Parameters: +# name [destdir] +# +# `name' is the base name of the font, such as `cmr10'. +# `destdir' is the name of the destination directory. + +# setup section + +TOOLS="/usr/local/tex/kpsetools-0.2/bin" +SCRIPTS="/usr/local/tex/scripts-0.2/bin" + +KPSEXPAND="$TOOLS/kpsexpand" +APPENDDB="$SCRIPTS/append_db" + +MF="/usr/local/bin/mf" +GSFTOPK="/usr/local/bin/gsftopk" +GFK="/usr/local/bin/gftopk" + +AWK="/usr/bin/awk" +EGREP="/usr/bin/egrep" +RM="/bin/rm -f" +MV="/bin/mv -f" +MD="/bin/mkdir" +CHM="/bin/chmod" + +# if we are going to install resulting pk, then let us use +# a reasonable mode on this installation + +DPI=400 +MAG=1 +MODE=nexthi + + +# The root of where to put the new file. (Using the sh construct +# ${var=value} is the tersest construct that lets an environment +# variable `var' override the value given here.) +progname=`basename $0` +TEXMF=`$KPSEXPAND '$TEXMF'` +DESTROOT=${MTPK_DESTROOT-"$TEXMF/fonts"} + +# Location of the files that map font name parts to directory names. +NAMEMAPDIR="$TEXMF/fontmaps" + +# If this directory doesn't exist, the DC fonts won't be attempted. +dcfontdir="$TEXMF/fonts/public/dc" + +# If this directory doesn't exist, the Sauter stuff won't be attempted. +sauterdir="$TEXMF/fonts/public/sauter" + +# If the true typeface directory cannot be determined from the fontname, +# the files are installed here, relative to $DESTROOT. +# TE: change: tfm will be appended later +default_namepart=tmp + +# TEMPDIR needs to be unique for each process because of the possibility +# of simultaneous processes running this script. +TEMPDIR=${TMPDIR-/tmp}/mttfm.$$ + +NAME=`basename $1 .tfm` + +DIR_PERMS=755 +FILE_PERMS=444 + +if test $# -lt 1 ; then + echo "Usage: $progname name [destdir]." >&2 + exit 1 +fi + +# DESTDIR is harder. +case "$2" in + "") + # Nothing specified, so try to intuit the directory from the + # fontname. First the special cases: either $NAME matches an entire + # name in special.map, or it matches the abbreviation in + # special.map and ends with a numeral (for the pointsize). + # We (painfully) use only the minimal features in original awk. + if test -r $NAMEMAPDIR/special.map ; then + namepart=`$AWK \ +'{if ($1 == NAME || (substr (NAME, 1, length ($1)) == $1 \ + && substr (NAME, length (NAME), 1) ~ /[0-9]/)) \ + { print $2 "/" $3; exit; }}' NAME=$NAME $NAMEMAPDIR/special.map` + + if test -z "$namepart" ; then + # Try the normal case. Source first. + s_abbrev=`echo $NAME | cut -c 1-1` + sourcedir=`$AWK '{ if ($1 == s_abbrev) { print $2 ; exit ; }}' \ + s_abbrev=$s_abbrev $NAMEMAPDIR/source.map` + + if test -n "$sourcedir" ; then + # We found the source. Try for the typeface. + t_abbrev=`echo $NAME | cut -c 2-3` + typefacedir=`$AWK '{ if ($1 == t_abbrev) { print $2; exit; }}' \ + t_abbrev=$t_abbrev $NAMEMAPDIR/typeface.map` + + if test -n "$typefacedir" ; then + # Found everything. + namepart=$sourcedir/$typefacedir + + else + echo "$progname: Could not map typeface abbreviation $t_abbrev." >&2 + fi + else + echo "$progname: Could not map source abbreviation $s_abbrev." >&2 + fi + fi + else + # No map files. + : + fi + # If we failed for whatever reason, default to a generic subdir. + test -z "$namepart" && namepart=$default_namepart + namepart=$namepart/tfm + + # Finally, update the parent of the installation directory. + DESTDIR="$DESTROOT/$namepart" + ;; + /*) DESTDIR=$2 ;; # Absolute, explicit destdir => use it. + *) DESTDIR=$DESTROOT/$2 ;; # Relative destdir => append to the default. +esac + +PK_DESTDIR=`echo $DESTDIR | sed s@/tfm\$\@/pk/${MODE}@` + +GFNAME=$NAME.$DPI'gf' +PKNAME=$NAME.$DPI'pk' +TFMNAME=$NAME.tfm + +# Clean up on normal or abnormal exit. DESTDIR changes, hence the eval. +trap "cd / ; eval $RM -r $TEMPDIR $DESTDIR/pktmp.$$" 0 1 2 15 + +# Remember where we were for the paths. We'd most like to replace `.', +# wherever it is in the path, with $PWD, but we don't have access to the +# compile-time path. So we are conservative, and put this at the end. +MFINPUTS="$MFINPUTS:$PWD" +export MFINPUTS + +# Go to the unique working directory. +test -d $TEMPDIR || $MD $TEMPDIR +cd $TEMPDIR || exit 1 + +# grep for the font in $PSMAPFILE, if some ps-to-pk is claimed to be supported. +test -n "$ps_to_pk" && $EGREP \^$NAME'([ ]|$)' $PSMAPFILE >psline +if test -s psline ; then + # This is a PostScript font. + echo "$progname: Sorry. No support for PostScript fonts here." >&2 + exit + +else + if test -r $DESTDIR/$TFMNAME ; then # sigh, this is repeated above + echo "$progname: $DESTDIR/$TFMNAME already exists." >&2 + echo $DESTDIR/$TFMNAME + $APPENDDB $DESTDIR $TFMNAME + exit 0 + fi + + # Run Metafont. Always use plain Metafont, since reading cmbase.mf + # does not noticeably slow things down. Separate the filename from the + # rest, since we have to use ./$NAME if we generate something. + cmd="$MF \mode:=$MODE; mag:=$MAG; scrollmode; input" + echo "$progname: Running $cmd $NAME" >&2 + if $cmd $NAME </dev/null >&2 ; then + : # Success already. + + else + # These other cases should really be part of MakeTeXMF. + # First have to figure out the real magnification, which means + # extracting the point size from the name -- a trailing number. + rootname=`echo $NAME | sed 's/[0-9]*$//'` + pointsize=`echo $NAME | sed "s/^$rootname//"` + case "$pointsize" in + 11) realsize=10.95444 ;; # \magstephalf + 14) realsize=14.4 ;; # \magstep2 + 17) realsize=17.28 ;; # \magstep3 + 20) realsize=20.74 ;; # \magstep4 + 25) realsize=24.88 ;; # \magstep5 + *) realsize=$pointsize ;; + esac + mfname=$NAME.mf + $RM $mfname # We are in $TEMPDIR, so this is safe. + + if test -z "$pointsize" ; then + # No point size, so it can't be a DC or Sauter font. Give up. + : + + elif echo $NAME | $GREP '^dc' >/dev/null ; then + echo "$progname: Trying DC font." >&2 + echo "if unknown dxbase: input dxbase fi;" >$mfname + echo "gensize:=$realsize;" >>$mfname + echo "generate $rootname;" >>$mfname + echo "$progname: Running $cmd ./$NAME" >&2 + $cmd ./$mfname </dev/null >&2 + + elif test -d $sauterdir ; then + echo "$progname: Trying interpolated/extrapolated (Sauter) font." >&2 + echo "design_size:=$realsize;" >>$mfname + echo "input b-$rootname;" >>$mfname + echo "$progname: Running $cmd ./$NAME" >&2 + $cmd ./$mfname </dev/null >&2 + # Result should go in the sauterdir, not the cm dir. + test -z "$6" && $DESTDIR=$sauterdir/pk/$MODE + fi # alternative mf sources + fi # first mf failed + + # If we couldn't make the font, quit. + test -r $GFNAME || \ + { echo "$progname: Metafont failed to make $GFNAME." >&2 ; exit 1 ; } + + # Success. Make the PK file. + $GFK ./$GFNAME $PKNAME || exit 1 +fi + +# If we get here, we've succeeded; move the final font to $DESTDIR. +test -d $DESTDIR \ + || ($MD $DESTDIR && $CHM $DIR_PERMS $DESTDIR) \ + || { echo "$progname: Could not mkdir $DESTDIR." >&2 ; exit 1 ; } + +test -d $PK_DESTDIR \ + || ($MD $PK_DESTDIR && $CHM $DIR_PERMS $PK_DESTDIR) \ + || { echo "$progname: Could not mkdir $PK_DESTDIR." >&2 ; exit 1 ; } + +# Install the PK file carefully, since others may be working simultaneously. +$MV $TFMNAME $DESTDIR/tfmtmp.$$ \ + || { echo "$progname: Could not mv $TFMNAME $DESTDIR/tfmtmp.$$." >&2 ; exit 1 ; } + +# Install the PK file carefully, since others may be working simultaneously. +if [ ! -f $PK_DESTDIR/$PKNAME ] ; then + $MV $PKNAME $PK_DESTDIR/pktmp.$$ \ + || { echo "$progname: Could not mv $PKNAME $PK_DESTDIR/pktmp.$$." >&2 ; exit 1 ; } + cd $PK_DESTDIR || exit 1 + $MV pktmp.$$ $PKNAME + $CHM $FILE_PERMS $PKNAME + $APPENDDB $DESTDIR $PKNAME +fi + +cd $DESTDIR || exit 1 +$MV tfmtmp.$$ $TFMNAME +$CHM $FILE_PERMS $TFMNAME + +# If this line (or an equivalent) is not present, dvipsk/xdvik/dviljk +# will think MakeTeXPK failed. Any other output to stdout will also lose. +echo $DESTDIR/$TFMNAME +$APPENDDB $DESTDIR $TFMNAME +exit 0 diff --git a/obsolete/fonts/utilities/safemtpk/append_db b/obsolete/fonts/utilities/safemtpk/append_db new file mode 100644 index 0000000000..3d54351b7c --- /dev/null +++ b/obsolete/fonts/utilities/safemtpk/append_db @@ -0,0 +1,44 @@ +#!/bin/sh + +# append_db +# Written by Thomas Esser <te@informatik.uni-hannover.de>, Nov., 1994 + +TOOLS="/usr/local/tex/kpsetools-0.2/bin" +KPSEXPAND="$TOOLS/kpsexpand" +SED="/usr/bin/sed" +CAT="/bin/cat" +EDT="/bin/ed" +CHM="/bin/chmod 666" + + +progname=`basename $0` +db_file=`$KPSEXPAND '$TEXMF'`/ls-R +control_string='% This is file ls-R. Maintained by texhash and append_db.' + +case $# in +2) ;; +*) echo "Usage: append_db dir file" + exit + ;; +esac + +test -f $db_file || (echo "$control_string" > $db_file; $CHM $db_file) + +if [ ! -w "$db_file" ] ; then + echo "$progname: error: cannot write to file $db_file." + exit +fi >&2 + +$EDT -s $db_file >& /dev/null <<-eof + /`echo $1 | $SED 's@/@\\\\/@g'`/a + $2 + . + wq +eof + +if [ $? != 0 ]; then + $CAT >> $db_file <<-eof + $1: + $2 + eof +fi diff --git a/obsolete/fonts/utilities/safemtpk/maketex.c b/obsolete/fonts/utilities/safemtpk/maketex.c new file mode 100644 index 0000000000..0461afd3dc --- /dev/null +++ b/obsolete/fonts/utilities/safemtpk/maketex.c @@ -0,0 +1,89 @@ +/****************************************************/ +/* */ +/* Executable wrapper for MakeTeX... programs. */ +/* Calls its namesake from TOOLS directory. */ +/* Provide links with different names to make it */ +/* multipurpose. */ +/* */ +/* Michal Jaegermann, Feb 11 1995 */ +/* */ +/****************************************************/ + +#include <unistd.h> +#include <string.h> +#include <stdlib.h> + +#define VERSION_S "0.2" +/* + * If you do not have ANSI compiler you may use + * an "explicit"single string in TOOLS define; this + * is just a way to make future modifications easier. + */ +#define TOOLS "/usr/local/tex/scripts-" VERSION_S "/bin/" +#define ASIZE 120 + +/* + * This is a list of names under which we are willing + * to execute. It has be NULL terminated. + */ +const char *accepted[] = { + "MakeTeXPK", + "MakeTeXTFM", + "MakeTeXMF", + NULL +}; + +int +main(int argc, char **argv) +{ + char doer[ASIZE] = TOOLS; + int idx = 0; + /* + * If your compiler is broken and the construction below + * does not work then "tail = strchr(doer, '\0');", or + * equivalent, will serve as well. + */ + char *tail = doer + (sizeof(TOOLS) - 1); + char *start; + + /* find our base name */ + start = (start = strrchr(argv[0], '/')) ? + (start + 1) : argv[0]; + /* check if we are on the list */ + while (1) { + if (NULL == accepted[idx]) + exit(1); /* not on the list - bye-bye */ + if (0 == strcmp(accepted[idx], start)) + break; /* this is ours */ + idx += 1; + } + /* + * Set pretty bland, but hopefuly secure environment; + * we intend to run this program 'suid'. + */ + setenv("PATH", "/bin:/usr/bin", 1); + setenv("IFS", " ", 1); + /* + * You may want/need some other calls to setenv(). + * For example, if your system has an environment + * variable pointing to shared libraries it should + * be set here. + */ + + /* + * Attach our name at the end of a directory string. + * This assumes that real scripts in TOOLS directory + * will be called by their own names (but indirectly) + */ + strcpy(tail, start); + setuid(geteuid()); /* we want priviledges of + an owner of this program */ + return execv(doer, argv); /* do it and tell results */ +} + +/* + * Local variables: + * compile-command: "gcc -s -O6 -fomit-frame-pointer -Wall -pipe -m486 -Xlinker -N -o ../MakeTeXPK maketex.c" + * End: + */ + diff --git a/obsolete/fonts/utilities/safemtpk/safeMakeTeXPK.tex b/obsolete/fonts/utilities/safemtpk/safeMakeTeXPK.tex new file mode 100644 index 0000000000..8ff1607c8c --- /dev/null +++ b/obsolete/fonts/utilities/safemtpk/safeMakeTeXPK.tex @@ -0,0 +1,319 @@ +% +% Copyright 1995, Michal Jaegermann +% +% You may print and reprint this article, as long as the author +% will be acknowledged. +% +\ifx\documentclass\undefined +\documentstyle[11pt]{article} +\else +\documentclass[11pt]{article} +\fi + +\newcommand{\command}[1]{\mbox{\tt #1}} +\newcommand{\path}[1]{{\tt #1}} + +\begin{document} +\title{Making MakeTeXPK safer for Unix installations} +\author{Micha{\l} Jaegermann\\ +{\small\tt michal\char`\@ellpspace.math.ualberta.ca,}\\ +{\small\tt michal\char`\@gortel.phys.ualberta.ca}} +\date{14 February 1995} +\maketitle + +\begin{abstract} + Leaving directories open for writing by anybody in the world + in order to ensure that \command{MakeTeXPK} will work is often a + security concern. This note describes how to avoid that on Unix + systems without loosing functionality. +\end{abstract} +\renewcommand{\thefootnote}{} +\footnote{Unix is a registered trademark of AT\&T} +\footnote{\TeX{} is a trademark of the American Mathematical Society} +\footnote{Metafont is a trademark of the Addison--Wesley Publishing Company} + +If you run \TeX{} on Unix, or any other Unix-like, system and you are +using very convenient and popular setup with an automatic bitmap +generation then you undoubtedly noticed that this requires directories +with \command{'write'} permissions to everybody. In theory this is +not much different than having your \path{/tmp} directory opened that +way. In practice, though, especially when your programs were compiled +with \command{kpathsea} library with ensuing multiple font +directories, this may be some security and administrative headache. + +For the first and rather feeble line of defense, if your variant of +Unix supports that, you should set 'sticky' bit on directories in +question like this: \command{chmod a+t pk}. That way files can be +removed or overwritten only by their owner(s). Unfortunately this +does not prevent a ``denial of service'' attack when a perpetrator +may fill out directories with a garbage (like empty) files with +proper names. No big harm is done on a long run, but repeated pranks +like that may turn into a major nuisance. + +If you were thinking about running \command{MakeTeXPK} ``suid'' +(that means --- in a mode which gives a program all privileges of +its {\em owner\/}) then you should drop the idea immediately; +especially if \command{MakeTeXPK} is owned by \command{root}. +This is a {\em shell script} and for many reasons running shell +scripts in suid mode is one of the biggest security holes you may +think of. Because of that many Unix variants simply disable such +scripts, thus saving you from yourself; but even if this is not the +case on some particular system do {\bf not} do that. Problems with +``world writable'' directories pale in a comparison. + +Fortunately not everything is lost as long as you have a compiler and +an editor. \command{MakeTeXPK} and relatives (\command{MakeTeXTFM}, +\command{MakeTEXMF}, \ldots) may be executed indirectly, by a small +compiled ``wrapper'' program and the last one can be safely made +``suid''. + +This note describes below steps needed to perform such modification. +Details and accompanying sample files are for one particular +distribution (some version of \command{teTeX} for Linux) but +modifications for other installations should be rather straightforward. +It goes without saying that you need a \command{root} access for all +(ok, most of) these steps. + +\begin{itemize} +\item Create new user account, say \command{tex}, on your system + and include it some innocuous group, e.g.~\command{tex}. +\end{itemize} +The only purpose of of this ``user'' will be to own common \TeX{} +files. You may have already some suitable group, like +\command{nogroup} or \command{nobody}, so instead you may include your +new user there. +\begin{itemize} +\item Give \command{tex} account \path{/bin/false} for a login shell + and disable password by putting \command{*} in the corresponding + field. Home directory is not terribly important. Nobody will be + ever logging into this account. +\end{itemize} +An entry in your password file will look after this somewhat like +that: +\begin{verbatim} +tex:*:117:65535:Owner of TeX files:/usr/local/tex:/bin/false +\end{verbatim} +\begin{itemize} +\item Close a loophole in some mail delivery programs by creating + an empty file \path{/usr/spool/mail/tex} executing + \command{touch /usr/spool/mail/tex}. + You may find the file already + in place made by some yours system administration utility. + Change owner and a group of this file to those of root + (\command{chown root:root /usr/spool/mail/tex}) + and remove all read and write permissions on it + (\command{chmod 000 /usr/spool/mail/tex}). +\item Make sure that \command{MakeTeXPK}, and similar scripts you want + to execute the same way, are {\bf not} in your \$PATH, or at least not + earlier then an intended location of your ``wrapper'' program(s). +\end{itemize} +For \command{teTeX} distribution, version 0.2, it is enough to delete +links in a directory \path{/usr/local/bin}. Real scripts +\command{MakeTeXPK}, \command{MakeTeXMF} and \command{MakeTeXTFM} +reside in \path{/usr/local/tex/scripts-0.2/bin/} and we may leave them +there. +\begin{itemize} +\item Edit all scripts in question to replace in invocations programs + by their absolute locations. Do not forget to perform this task + in other scripts which may be called by our \command{MakeTEX...} + scripts (this is \command{append\_db} in \command{teTeX} + distribution). Change mode used when creating new files to 444 + and to 755 for directories. +\end{itemize} +A proper way to do that is start a script with a series of shell +variable definitions similar to \command{MF="/usr/local/bin/mf"} and +replace all later occurences of \command{mf} in the script by +\command{\$MF}. That way, if you later move your {\sc Metafont} +executables to some other place, script editing will be limited to one +place. Similar for other programs. Absolute locations are required +since, for security reason, we will limit \command{\$PATH} only to +\path{"/bin:/usr/bin"}. This means that in theory you may leave things +like \command{test}, \command{echo} or \command{rm} alone. In the +later case, for ``dangerous'' commands like \command{rm -f} is still a +good idea to replace them with definitions similar to +\command{RM="/bin/rm -f"} to get a better control on what you are +really executing. As a side effect you will ensure that this is a +``real'' system \command{rm} and not some funky user redefinition +which asks a lot of questions before doing anything and confuses +\command{MakeTeXPK} in the process. + +Depending on a level of your mistrust you may use a similar approach +to \command{echo} and \command{test} as well, but in bundled sample +files I have chosen to be more relaxed. Besides they may anyway be +``built-ins'' for some shells. +\begin{itemize} +\item Edit, to adjust to your system, and compile a program like this + one below. +\end{itemize} +% +\begin{verbatim} +/****************************************************/ +/* */ +/* Executable wrapper for MakeTeX... programs. */ +/* Calls its namesake from TOOLS directory. */ +/* Provide links with different names to make it */ +/* multipurpose. */ +/* */ +/* Michal Jaegermann, Feb 11 1995 */ +/* */ +/****************************************************/ + +#include <unistd.h> +#include <string.h> +#include <stdlib.h> + +#define VERSION_S "0.2" +/* + * If you do not have ANSI compiler you may use + * an "explicit"single string in TOOLS define; this + * is just a way to make future modifications easier. + */ +#define TOOLS "/usr/local/tex/scripts-" VERSION_S "/bin/" +#define ASIZE 120 + +/* + * This is a list of names under which we are willing + * to execute. It has be NULL terminated. + */ +const char *accepted[] = { + "MakeTeXPK", + "MakeTeXTFM", + "MakeTeXMF", + NULL +}; + +int +main(int argc, char **argv) +{ + char doer[ASIZE] = TOOLS; + int idx = 0; + /* + * If your compiler is broken and the construction below + * does not work then "tail = strchr(doer, '\0');", or + * equivalent, will serve as well. + */ + char *tail = doer + (sizeof(TOOLS) - 1); + char *start; + + /* find our base name */ + start = (start = strrchr(argv[0], '/')) ? + (start + 1) : argv[0]; + /* check if we are on the list */ + while (1) { + if (NULL == accepted[idx]) + exit(1); /* not on the list - bye-bye */ + if (0 == strcmp(accepted[idx], start)) + break; /* this is ours */ + idx += 1; + } + /* + * Set pretty bland, but hopefuly secure environment; + * we intend to run this program 'suid'. + */ + setenv("PATH", "/bin:/usr/bin", 1); + setenv("IFS", " ", 1); + /* + * You may want/need some other calls to setenv(). + * For example, if your system has an environment + * variable pointing to shared libraries it should + * be set here. + */ + + /* + * Attach our name at the end of a directory string. + * This assumes that real scripts in TOOLS directory + * will be called by their own names (but indirectly) + */ + strcpy(tail, start); + setuid(geteuid()); /* we want priviledges of + an owner of this program */ + return execv(doer, argv); /* do it and tell results */ +} +\end{verbatim} +\begin{itemize} +\item Install results of the compilation somewhere in your + \command{\$PATH}. A directory \path{/usr/local/bin} is + usually a good place. Go there and name your program + \command{MakeTeXPK}. + Change its ownership and group to that of user \command{tex} by + typing \command{chmod tex:tex MakeTeXPK}. (Depending on your + variant of Unix you may have to use dot instead of colon to separate + user and its group name, or you may have to do that in two steps, + using also another command, \command{chgrp}, to acomplish the above. + Use a group to which you assigned your \command{tex} user. This is + only an example). The program needs ``execute'' and ``set uid'' + priviledges (\command{chmod 4755 MakeTeXPK}). Also for your other + \command{MakeTeX...} scripts provide corresponding ``call points'' + with their names via file links (\command{ln MakeTeXPK MakeTeXTFM}; + \command{ln MakeTeXPK MakeTeXMF}). +\item Change ownership of all your font files to \command{tex}. + Actually you may make \command{tex} an owner of whole directory + trees in \TeX{} system files. Assuming that all you want to asign + that way is in a tree rooted in \path{texmf} you may accomplish that + by doing \command{chown -R tex:tex texmf}. If your \command{chown} + does not understand \command{-R} (recursive) flag, then something + similar to the following should do: +\begin{verbatim} + find texmf -print | xargs -n1 chown tex:tex +\end{verbatim} + See also \command{chown} caveats in the previous item. +\end{itemize} +\begin{itemize} +\item Remove ``write'' permissions for anybody but owner on all + directories in question. A command like this should + accomplish that task (careful, you do not want to change + non-directories): +\begin{verbatim} + find texmf -type d -print | xargs -n1 chmod 755 +\end{verbatim} +\end{itemize} +You are done. Now, when \command{MakeTeXPK} will be called, directly +from a command line, or by some other program like \command{dvips}, +your ``wrapper'' program will be executed instead. It will call in +turn a ``real'' script but already with an id of an owner of your font +directories. + + +\subsubsection*{Concluding remarks} + +The presented solution is not entirely without problems. Due to ``out +of sync'' ownership and permissions \command{kpathsea} library +functions may fail, depending on a moment this happened, when trying +to write \path{missfont.log} file in cases when font making was not +successful. +This can likely be hard to resolve without modifying the library +itself. If you will really encounter this, then a simple workaround +would be to create an empty \path{missfont.log}, owned by you, and to +give on it write permissions for everybody \\(\command{touch missfont.log;} +\command{chmod a+w missfont.log}). When you are done simply change +permissions back to an original state. + +Another possible trouble spot will occur when you have your +``private'' fonts, because you are conducting some font making +experiments, for example, and you would like to have bitmaps created +in places owned by you and not by \command{tex}. Otherwise you will +not be able to remove results of failed tests. In that case make +yourself a private, executable, copy of \command{MakeTeXPK} script, +edit it accordingly and make sure that it can be found {\em earlier} +in your \command{\$PATH} than a system program with the same name. +You will not able to deposit anything in system directories, but this +is likely what you want anyway. Your script does not have to run +``suid'', so repeating all of the above is not necessary. + +Last, but not least, there is possible somewhat another approach to +the whole problem. There are only a few commands (\command{mv}, +\command{mkdir}, \command{chmod}) which have to modify \TeX{} +``system'' directories. Instead of running the whole +\command{MakeTeX} in ``suid'' mode you may write special versions +(\command{texmv}, \command{texmkdir}, \command{texchmod}) of these, +which would operate ``suid'' \command{tex}, and use them as +replacements in \command{MakeTeXPK} script whenever needed. If this +is a better idea depends entirely on your situation and +security requirements. + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: |