Bug#228926: /var/lib/dpkg/info/tetex-bin.postinst: line 209: 5576: Permission denied
On Thu, Jan 22, 2004 at 06:43:57PM +0100, Frank K?ster wrote:
> --- tetex-bin-2.0.2/debian/postinst.orig Thu Jan 22 18:37:25 2004
> +++ tetex-bin-2.0.2/debian/postinst Thu Jan 22 18:36:51 2004
> @@ -200,23 +200,24 @@
> (cd ${LDATD} ; ln -s ${LDAT} .)
> fi
> db_get tetex-bin/hyphen || true
> + TMP_LDAT=`tempfile`
> IFS=' ,'
> lang="$RET"
> for l in $lang; do
> case $l in
> none) cp -f $DFLT $LDAT ;;
> - british) sed -e "s/%! british ukhyphen.tex/british ukhyphen.tex/" $LDAT | sed -e "s/%! =UKenglish/=UKenglish/" > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
> - french\[=patois\]) sed -e "s/%! french/french/" $LDAT | sed -e "s/%! =patois/=patois/" > $LDAT_$$; mv $LDAT_$$ $LDAT ;;
Note that the line above must be inside the for loop, not ahead of it. It
creates a temporary file in a secure manner so that the redirection will not
create a security vulnerability by allowing a symlink attack.
> I would prefer to write a function "uncomment_once" and "uncomment_twice"
> that gets the filenames and patterns, but I fear that doesn't work in
> sed (s/$pattern/$newpattern/ gives an "unterminated s command"). perl
> would do, I think.
There's no reason why your idea shouldn't work with sed, unless the quoting
or pattern is messed up somehow:
mizar:[~] pattern="foo.*bar"
mizar:[~] newpattern="baz"
mizar:[~] echo "foo blah bar" | sed -e "s/$pattern/$newpattern/"
baz
mizar:[~]
This whole thing could probably be simplified a great deal, though, by
generalizing that case statement so that it doesn't need to explicitly
handle every possible $lang value. For example:
langpat=$(echo "$RET" | sed -e 's/, */\|/g')
sed -e "s/^%! \($langpat\)/\1/" < $LDAT > $TMP_LDAT
chown --reference=$LDAT $TMP_LDAT
chmod --reference=$LDAT $TMP_LDAT
mv $TMP_LDAT $LDAT
--
- mdz
Reply to: