Package: samba
Severity: normal
Tags: patch

On a fresh install of Samba, I answer "No" to the following question:

  Create samba password database, /var/lib/samba/passdb.tdb?

However, it goes ahead and creates it anyway.  The problem is that the
debconf config file is not idempotent--it overwrites my answer with
its calculated default value on its second run (since apt runs it
twice as described in the debconf-devel man page).

How to reproduce the problem:

  # DO NOT DO THIS EXCEPT ON A TEST SYSTEM!
  # (be sure you have debconf configured to ask medium-priority questions)
  rm -rf /var/lib/samba /etc/samba
  apt-get remove --purge samba samba-common
  apt-get install samba

A workaround is to create an empty /var/lib/samba/passdb.tdb before
installing samba:

  mkdir /var/lib/samba
  touch /var/lib/samba/passdb.tdb
  apt-get install samba
  rm /var/lib/samba/passdb.tdb

Better yet, attached is a patch for Samba to set the calculated
default value only if the user is going to be asked the question.

Note well that this patch introduces a different behavior if the user
has configured debconf to only ask high priority questions.  In this
case Samba would generate the passdb.tdb file by default.  But with
this patch, Samba will not generate the passdb.tdb file by default
because the user does not get asked the question to confirm it.  I
think this behavior is ok, though, because I don't think that Samba
should be generating this password file in any case without first
confirming it with the user.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.8-2-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

--- config.orig 2006-02-01 18:16:03.080719972 +0000
+++ config      2006-02-01 18:13:25.927964124 +0000
@@ -64,6 +64,8 @@
        db_input "$TDBPRIORITY" samba/tdbsam || true
 fi
 
+db_get samba/generate_smbpasswd || true
+DEFAULT_GENERATE_SMBPASSWD="${RET}"
 # We vary the priority of the next question depending on whether
 #      the password database already exists...
 if [ -e /etc/samba/smbpasswd -o -e /var/lib/samba/passdb.tdb ]; then
@@ -82,11 +84,14 @@
                        if [ "$ENCRYPT" = "no" ]; then
                                ENCRYPT=false
                        fi
+                       DEFAULT_GENERATE_SMBPASSWD="$ENCRYPT"
                fi
-                db_set samba/generate_smbpasswd "$ENCRYPT"
         fi
        PRIORITY="medium"
 fi
 
-db_input $PRIORITY samba/generate_smbpasswd || true
+if db_input $PRIORITY samba/generate_smbpasswd; then
+       # Question will be asked, so set default value.
+       db_set samba/generate_smbpasswd "$DEFAULT_GENERATE_SMBPASSWD"
+fi
 db_go

Reply via email to