Hi,

After looking over cups-daemon's preinst script which generates the
cupsd-systemd-listen.conf file, I think I found the problem(s):

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  
     6  case "$1" in
     7  install|upgrade)
     8      if dpkg --compare-versions "$2" le "1.6.1" && [ -e 
/etc/cups/cupsd.conf ]; then
     9          # Move cupsd.conf away as it becomes a non-conffile
    10          mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.conffile-bak
    11      fi
    12  
    13      # If file doesn't exist or if it has two conflicting stanzas
    14      if [ ! -f /etc/cups/cupsd-systemd-listen.conf ] || \
    15         ( grep -q '^ListenStream=0.0.0.0:' 
/etc/cups/cupsd-systemd-listen.conf 2>/dev/null && \
    16           grep -q '^ListenStream=127.0.0.1:' 
/etc/cups/cupsd-systemd-listen.conf 2>/dev/null ) ;\
    17      then

This is problem #1. This means that /etc/cups/cupsd-systemd-listen.conf
will not regenerated if it already exists unless there are conflicting
stanzas. While this is generally a good idea for configuration files, it
also means that an incorrect file will never be corrected.

    18          mkdir -p /etc/cups
    19          cat >/etc/cups/cupsd-systemd-listen.conf <<EOF
    20  [Socket]
    21  # This file was generated by CUPS and _WILL_ be deleted or overwritten 
by it!
    22  # It has to be kept in sync with the Port and Listen stanzas in 
/etc/cups/cupsd.conf
    23  # It is by default symlinked as cups-listen.conf in the
    24  # /etc/systemd/system/cups.socket.d/ directory. Remove the symlink
    25  # and write your own file there if you don't want this. See 
systemd.socket(5).
    26  EOF
    27          if [ -e /etc/cups/cupsd.conf ]; then

This is problem #2. This means, that the /etc/cups/cupsd.conf file will
only be parsed if it exists. However, this is the *pre*inst script,
meaning that this check will always fail on new installations since the
package isn't unpacked yet when this runs. [0]

    28              if grep -q '^\s*Port' /etc/cups/cupsd.conf 2>/dev/null; then
    29                  localport=`grep '^\s*Port' /etc/cups/cupsd.conf | head 
-n1 | sed -e 's/.*Port \([[:digit:]]*\)$/\1/'`
    30                  cat >>/etc/cups/cupsd-systemd-listen.conf <<EOF
    31  # Matches 'Port $localport' from cupsd.conf
    32  ListenStream=0.0.0.0:$localport
    33  ListenStream=[::]:$localport
    34  EOF
    35              elif grep -q '^\s*Listen localhost:' /etc/cups/cupsd.conf 
2>/dev/null; then
    36                  localport=`grep '^\s*Listen localhost:' 
/etc/cups/cupsd.conf | head -n1 | sed -e 's/.*localhost\:\([[:digit:]]*\)$/\1/'`
    37                  cat >>/etc/cups/cupsd-systemd-listen.conf <<EOF
    38  # Matches 'Listen localhost:$localport' from cupsd.conf
    39  ListenStream=127.0.0.1:$localport
    40  ListenStream=[::1]:$localport
    41  EOF
    42              fi
    43          else
    44              cat >>/etc/cups/cupsd-systemd-listen.conf <<EOF
    45  # Matches the default 'Listen localhost:631' from cupsd.conf.default
    46  ListenStream=0.0.0.0:631
    47  ListenStream=[::]:631

This is problem #3. This means that CUPS will listen on all interfaces
even though the comment directly above says exactly the opposite. This
looks a lot like a simple typo.

    48  EOF
    49          fi
    50      fi
    51  esac
    52  
    53  # Automatically added by dh_installdeb
    54  dpkg-maintscript-helper rm_conffile /etc/cups/cupsd.conf.default 
1.7.1-3~ -- "$@"
    55  # End automatically added section
    56  # Automatically added by dh_installdeb
    57  dpkg-maintscript-helper rm_conffile /etc/default/cups 1.7.1-6~ -- "$@"
    58  # End automatically added section
    59  # Automatically added by dh_installdeb
    60  dpkg-maintscript-helper mv_conffile /etc/pam.d/cups-daemon 
/etc/pam.d/cups 1.7.3-2~ -- "$@"
    61  # End automatically added section
    62  
    63  
    64  exit 0

The result is, that because of problem #2, /etc/cups/cupsd.conf will
never actually be parsed on new installations. Instead the incorrect
fallback configuration will be used (problem #3). And because of problem
#1, this will never be corrected, even when the package is updated or
reinstalled.

Best regards

Alexander Kurtz

[0] http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to