Bug#377618: [Logcheck-devel] Bug#377618: logcheck: Please do not abuse debconf

Thomas Huriaux thomas.huriaux at gmail.com
Thu Jul 20 11:13:45 UTC 2006


tag 377618 patch
thanks

maximilian attems <maks at sternwelten.at> (20/07/2006):
> On Mon, 10 Jul 2006, Thomas Huriaux wrote:
> > You are using two debconf notes which really look like a debconf abuse
> > (from debconf-devel(7): "It should be used only for important notes that
> > the user really should see, since debconf will go to great pains to make
> > sure the user sees it").
> > 
> > The first note (logcheck/install-note) should probably be moved to a
> > README.Debian file or somewhere else in the documentation. Or you should
> > really use debconf to configure these two options (report level and
> > address) instead of displaying a note.
> 
> debconf notes are usually more effective than README's,
> also the note is _only_ displayed at level medium so i fail to see the
> abuse of the install-note.

No, the argument of the priority is not valid. The lowest the priority
is, the more experienced the user is expected to be. An experienced user
usually knows where to find the relevant doc, and expects to find it at
the right place.
Moreover, as I said in my previous mail, you should use debconf to
_configure_ the package, not to tell the user he/she can configure it.
I therefore attach a patch to configure with debconf the two related
items. Please check it carefully as I made it quickly.


> > The second note (logcheck/changes) can probably be removed. It no longer
> > concerns supported transitions in Debian: the version 1.2.39 is in
> > sarge, and if I understand correctly, it is for transitions from a
> > version < 1.2.3. However, this note should have been in a NEWS.Debian
> > file.
> 
> it only shows up on upgrades and will be removed postetch.
> currently we may wish to backport latest etch, so such upgrade
> handling must stay.

Indeed, but once again, it should be in a NEWS.Debian file. Do not
forget that tools such as apt-listchanges display this kind of notes.



See also policy 3.9.1:

  Packages should try to minimize the amount of prompting they need to do

You seem to use debconf only because it is "more effective"


  Copyright messages do not count as vitally important [...] neither do
  instructions on how to use a program (these should be in on-line
  documentation, where all the users can see them).

The second template seems to concern only a new behavior of the package,
without needing the user to change anything to get it working. The first
one is exactly what is disrecommanded by this sentence.

-- 
Thomas Huriaux
-------------- next part --------------
diff -Nur logcheck-1.2.47/debian/logcheck.config logcheck.new/debian/logcheck.config
--- logcheck-1.2.47/debian/logcheck.config	2004-05-24 03:28:22.000000000 +0200
+++ logcheck.new/debian/logcheck.config	2006-07-20 12:33:27.000000000 +0200
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+CONFIGFILE="/etc/logcheck/logcheck.conf"
+
 set -e
 
 action=$1
@@ -9,8 +11,14 @@
 . /usr/share/debconf/confmodule
 db_version 2.0
 
+if [ -e $CONFIGFILE ]; then
+    . $CONFIGFILE || true
+    db_set logcheck/reportlevel "$REPORTLEVEL"
+    db_set logcheck/sendmailto "$SENDMAILTO"
+fi
 
-db_text medium logcheck/install-note || true
+db_input medium logcheck/reportlevel || true
+db_input medium logcheck/sendmailto || true
 
 if [ -n "$version" ] && dpkg --compare-versions "$version" lt "1.2.3"; then
     db_text medium logcheck/changes || true
diff -Nur logcheck-1.2.47/debian/logcheck.postinst logcheck.new/debian/logcheck.postinst
--- logcheck-1.2.47/debian/logcheck.postinst	2006-07-04 19:35:14.000000000 +0200
+++ logcheck.new/debian/logcheck.postinst	2006-07-20 12:33:27.000000000 +0200
@@ -2,6 +2,8 @@
 
 # $Id: logcheck.postinst,v 1.48 2006/07/04 17:35:14 maks-guest Exp $
 
+CONFIGFILE="/etc/logcheck/logcheck.conf"
+
 set -e
 
 # summary of how this script can be called:
@@ -22,9 +24,13 @@
 #     installation fails and the `postinst' is called with `abort-upgrade',
 #     `abort-remove' or `abort-deconfigure'.
 
+DEFAULTREPORTLEVEL="server"
+DEFAULTSENDMAILTO="root"
+
 # Source debconf library.
 . /usr/share/debconf/confmodule
 
+
 case "$1" in
     configure)
 	# Add logcheck user
@@ -88,6 +94,38 @@
           chown logcheck /var/lock/logcheck > /dev/null || true
 	fi
 
+	if [ ! -e $CONFIGFILE ]; then
+		echo "# Configuration file for logcheck" > $CONFIGFILE
+		echo "REPORTLEVEL=" >> $CONFIGFILE
+		echo "SENDMAILTO=" >> $CONFIGFILE
+	fi
+
+	db_get logcheck/reportlevel
+	REPORTLEVEL="$RET"
+	if [ "$REPORTLEVEL" = "" ]
+	then
+	    REPORTLEVEL="$DEFAULTREPORTLEVEL"
+	fi
+
+	db_get logcheck/sendmailto
+	SENDMAILTO="$RET"
+	if [ "$SENDMAILTO" = "" ]
+	then
+	    SENDMAILTO="$DEFAULTSENDMAILTO"
+	fi
+
+	cp -a -f $CONFIGFILE $CONFIGFILE.tmp
+
+	test -z "$TOTO" || grep -Eq '^ *REPORTLEVEL=' $CONFIGFILE || \
+	    echo "REPORTLEVEL=" >> $CONFIGFILE
+	test -z "$TITI" || grep -Eq '^ *SENDMAILTO=' $CONFIGFILE || \
+	    echo "SENDMAILTO=" >> $CONFIGFILE
+
+	sed -e "s/^ *REPORTLEVEL=.*/REPORTLEVEL=\"$REPORTLEVEL\"/" \
+	    -e "s/^ *SENDMAILTO=.*/SENDMAILTO=\"$SENDMAILTO\"/" \
+	    < $CONFIGFILE > $CONFIGFILE.tmp
+	mv -f $CONFIGFILE.tmp $CONFIGFILE
+
 	;;
     
     abort-upgrade|abort-remove|abort-deconfigure)
diff -Nur logcheck-1.2.47/debian/logcheck.templates logcheck.new/debian/logcheck.templates
--- logcheck-1.2.47/debian/logcheck.templates	2006-07-08 14:14:39.000000000 +0200
+++ logcheck.new/debian/logcheck.templates	2006-07-20 12:45:41.000000000 +0200
@@ -1,10 +1,19 @@
-Template: logcheck/install-note
-Type: note
-_Description: Changing the report level or email address
- To change from the default report level (server) or the default email
- address (root) you need to edit "/etc/logcheck/logcheck.conf".
- .
- Please see /usr/share/doc/logcheck for more details.
+Template: logcheck/reportlevel
+Type: select
+__Choices: workstation, server, paranoid
+Default: server
+_Description: Report level:
+ Report levels function rather like verbosity settings. This is a
+ three-way division between high (paranoid), medium (server) and
+ low (workstation) "security ratings".
+
+Template: logcheck/sendmailto
+Type: string
+Default: root
+_Description: Recipient:
+ The output of logcheck is sent through mails to an e-mail address.
+ It can be either an alias known on the system, or a fully qualified
+ address.
 
 Template: logcheck/changes
 Type: note
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/logcheck-devel/attachments/20060720/2a99b39a/attachment.pgp 


More information about the Logcheck-devel mailing list