diff options
author | wlemb <wlemb> | 2003-10-28 07:46:21 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2003-10-28 07:46:21 +0000 |
commit | 6f5e764aa363f94048dadabcde94956e507edd87 (patch) | |
tree | 8a7e544e9a46558caeb33484cf61ea12fac7c675 /contrib/eqn2graph | |
parent | 1b6b1ae675b4df397807631699464f3fa77a9727 (diff) | |
download | groff-6f5e764aa363f94048dadabcde94956e507edd87.tar.gz |
* contrib/eqn2graph/eqn2graph.sh, contrib/grap2graph/grap2graph.sh,
contrib/pic2graph/pic2graph.sh: Implement secure management of
temporary files.
Pass `-P-pletter' to groff to avoid data outside of the converted
area -- some versions of `convert' (for example 5.3.8) don't check
the bounding box of the image but always use a fixed image size
(letter paper format).
* contrib/eqn2graph/eqn2graph.man, contrib/grap2graph/grap2graph.man,
contrib/pic2graph/pic2graph.man: Updated.
* src/roff/groff/groff.man: Document $TMP and $TEMP.
Diffstat (limited to 'contrib/eqn2graph')
-rw-r--r-- | contrib/eqn2graph/eqn2graph.man | 18 | ||||
-rw-r--r-- | contrib/eqn2graph/eqn2graph.sh | 31 |
2 files changed, 41 insertions, 8 deletions
diff --git a/contrib/eqn2graph/eqn2graph.man b/contrib/eqn2graph/eqn2graph.man index e7896fcc..3f34cc5e 100644 --- a/contrib/eqn2graph/eqn2graph.man +++ b/contrib/eqn2graph/eqn2graph.man @@ -1,4 +1,4 @@ -.\" $Id: eqn2graph.man,v 1.3 2003/07/02 15:37:30 wlemb Exp $ +.\" $Id: eqn2graph.man,v 1.4 2003/10/28 07:46:23 wlemb Exp $ .\" This documentation is released to the public domain. . . @@ -82,6 +82,22 @@ The initialization file. . . +.SH ENVIRONMENT +.TP +.B GROFF_TMPDIR +The directory in which temporary files will be created. +If this is not set +.B eqn2graph +searches the environment variables +.BR \%TMPDIR , +.BR TMP , +and +.B TEMP +(in that order). +Otherwise, temporary files will be created in +.BR /tmp . +. +. .SH "SEE ALSO" .BR pic2graph (@MAN1EXT@), .BR grap2graph (@MAN1EXT@), diff --git a/contrib/eqn2graph/eqn2graph.sh b/contrib/eqn2graph/eqn2graph.sh index e314dc91..efcd0187 100644 --- a/contrib/eqn2graph/eqn2graph.sh +++ b/contrib/eqn2graph/eqn2graph.sh @@ -32,7 +32,7 @@ # # Thus, we pass -U to groff(1), and everything else to convert(1). # -# $Id: eqn2graph.sh,v 1.2 2002/07/17 04:55:46 wlemb Exp $ +# $Id: eqn2graph.sh,v 1.3 2003/10/28 07:46:23 wlemb Exp $ # groff_opts="" convert_opts="" @@ -58,17 +58,34 @@ do shift done +# create temporary directory +tmp= +for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do + test -z "$d" && continue + + tmp=`(umask 077 && mktemp -d -q "$d/eqn2graph-XXXXXX") 2> /dev/null` \ + && test -n "$tmp" && test -d "$tmp" \ + && break + + tmp=$d/eqn2graph$$-$RANDOM + (umask 077 && mkdir $tmp) 2> /dev/null && break +done; +if test -z "$tmp"; then + echo "$0: cannot create temporary directory" >&2 + { (exit 1); exit 1; } +fi + +trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 2 15 + # Here goes: # 1. Add .EQ/.EN. # 2. Process through eqn(1) to emit troff markup. # 3. Process through groff(1) to emit Postscript. # 4. Use convert(1) to crop the Postscript and turn it into a bitmap. -tmp=/usr/tmp/eqn2graph-$$ -trap "rm ${tmp}.*" 0 2 15 read equation -(echo ".EQ"; echo 'delim $$'; echo ".EN"; echo '$'"${equation}"'$') | \ - groff -e $groff_opts -Tps >${tmp}.ps \ - && convert -crop 0x0 $convert_opts ${tmp}.ps ${tmp}.${format} \ - && cat ${tmp}.${format} +(echo ".EQ"; echo 'delim $$'; echo ".EN"; echo '$'"$equation"'$') | \ + groff -e $groff_opts -Tps -P-pletter > $tmp/eqn2graph.ps \ + && convert -crop 0x0 $convert_opts $tmp/eqn2graph.ps $tmp/eqn2graph.$format \ + && cat $tmp/eqn2graph.$format # End |