debian/update-reader.conf: add a SHA1 on the first line of the

configuration file to detect manual edition. Closes: #565896 "pcscd:
overwrites changes in configuration files"
urgency=medium because of RC bug.
This commit is contained in:
Ludovic Rousseau 2010-01-30 16:48:51 +00:00
parent 3068de54b8
commit 4c69c3a259
2 changed files with 40 additions and 10 deletions

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
pcsc-lite (1.5.5-2) unstable; urgency=medium
* debian/update-reader.conf: add a SHA1 on the first line of the
configuration file to detect manual edition. Closes: #565896 "pcscd:
overwrites changes in configuration files"
urgency=medium because of RC bug.
-- Ludovic Rousseau <rousseau@debian.org> Sat, 30 Jan 2010 17:40:44 +0100
pcsc-lite (1.5.5-1) unstable; urgency=low
* New upstream release

View File

@ -1,4 +1,4 @@
#! /bin/sh
#! /bin/bash
#
# This is the update-reader.conf script for Debian GNU/Linux.
# Written by Ludovic Rousseau <ludovic.rousseau@free.fr>
@ -27,24 +27,44 @@ CFGFILE=/etc/reader.conf
TMPFILE=`mktemp /tmp/reader.conf.XXXXXX`
HEADER="### This file is automatically generated by update-reader.conf"
trap "rm -f $TMPFILE; exit" INT TERM EXIT
set -e
# Reset the sorting order since we depend on it
LC_COLLATE=C
export LC_COLLATE
needforce=0
if [ -f "$CFGFILE" ]; then
if ! sed -ne 1p "$CFGFILE" | grep -q "^$HEADER" ; then
echo "Error: the current $CFGFILE is not automatically generated."
if [ "$1" != "force" ]; then
echo "Use \"update-reader.conf force\" to force (re)generation."
exit 1
FIRSTLINE=$(head -1 "$CFGFILE")
if [ "$FIRSTLINE" != "$HEADER" ]; then
#echo "new format or manual"
sha=$(echo "$FIRSTLINE" | cut -f2 -d' ')
#echo $sha
if [ ${#sha} -ne 40 ]; then
echo "Error: file $CFGFILE is not automatically generated."
needforce=1
else
echo "force specified, (re)generating file anyway."
sha2=$(tail --lines=+2 "$CFGFILE" | sha1sum | cut -f1 -d' ')
#echo $sha2
if [ $sha != $sha2 ]; then
echo "Error: file $CFGFILE was manually edited."
needforce=1
fi
fi
fi
fi
if [ "$1" = "force" ]; then
echo "force specified, (re)generating file anyway."
needforce=0
fi
if [ $needforce -eq 1 ]; then
echo "Use \"update-reader.conf force\" to force (re)generation."
exit 1
fi
if [ 0 -ne "`id -u`" ]; then
echo "You have to be root to run $0"
exit 2
@ -54,11 +74,10 @@ if [ -e "$CFGFILE" ]; then
cp -f "$CFGFILE" "${CFGFILE}.old"
fi
echo "$HEADER" > "$TMPFILE"
for cfg in /etc/reader.conf.d/* ; do
if ! echo "$cfg" | grep -q '\(\.dpkg-[a-z]*\|~\)$' ; then
echo "### update-reader.conf: start processing $cfg" >> "$TMPFILE"
echo >> "$TMPFILE"
if [ -x "$cfg" ]; then
"$cfg" >> "$TMPFILE"
else
@ -70,7 +89,9 @@ for cfg in /etc/reader.conf.d/* ; do
fi
done
cp "$TMPFILE" "$CFGFILE"
echo -n "#SHA1 " > "$CFGFILE"
sha1sum "$TMPFILE" >> "$CFGFILE"
cat "$TMPFILE" >> "$CFGFILE"
chmod 644 "$CFGFILE"
rm -f "$TMPFILE"