[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Pax Displayicus Managerius, v2



Hi folks.

As may be expected, users of the now-cooperating display manager
packages have uncovered a few bugs in the way my proposal works.

See, for instance:

bugs.debian.org/115776

So, attached you will find new versions of the config script, the
templates file, the postinst, and the prerm.  Ryan Murray and I worked
out these fixes on IRC.

In summary:

1) The config script removes the default display manager file if the
user changes his answer to the question (instead of only if the new
choice is the same as the current package).

2) All the packages need to be able to write the full path to the newly
selected display manager, even if it's not the same as the package
currently being configured.  In other words, it needs to be possible for
the user to run, e.g., "dpkg-reconfigure gdm", pick wdm as the new
default, and have this fact written to the default display manager file
instead of having to run "dpkg --configure wdm" subsequently.  It will
still be necessary in some cases (depending on how the package works) to
run the postinst script of the new default display manager package, but
at least this way the default display manager *file* will be correct no
matter which package's config script is run to change the default.

To enable this, each display manager package needs to provide a new,
read-only template (i.e., you never use a db_input on it in your config
script) that contains the full path to the display manager executable.

3) The prerm script has also been made more robust, removing the default
display manager file if it currently references the display manager that
is being removed, then writing it if it does not exist after the user
has answered the question.

Needless to say, there is a lot of stuff in the attached prerm and
postinst scripts that maintainers of other display managers don't need
to worry about.  I'll be rolling this stuff out for testing in
4.1.0-8pre9v2.

Finally, please be sure and incorporate debconf translation patches, so
that everyone can understand and marvel at the coolness of being able to
have 4 display managers installed simultaneously.

-- 
G. Branden Robinson                |      Mob rule isn't any prettier just
Debian GNU/Linux                   |      because you call your mob a
branden@debian.org                 |      government.
http://people.debian.org/~branden/ |
#!/bin/sh
# Debian xdm package configuration script
# Copyright 2000-2001 Branden Robinson.
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.

set -e

# source debconf library
. /usr/share/debconf/confmodule

THIS_PACKAGE=xdm
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager

# set default display manager

db_get shared/default-x-display-manager
OLD_DEFAULT="$RET"

db_metaget shared/default-x-display-manager owners
OWNERS="$RET"
db_metaget shared/default-x-display-manager choices
CHOICES="$RET"

if [ "$OWNERS" != "$CHOICES" ]; then
  db_subst shared/default-x-display-manager choices $OWNERS
  db_fset shared/default-x-display-manager seen false
fi

db_input high shared/default-x-display-manager || true
db_go

# using this display manager?
db_get shared/default-x-display-manager
CURRENT_DEFAULT="$RET"

# remove the default display manager file if we're going to change it
if [ "$OLD_DEFAULT" != "$CURRENT_DEFAULT" ]; then
  rm -f $DEFAULT_DISPLAY_MANAGER_FILE
fi

if [ "$CURRENT_DEFAULT" = "$THIS_PACKAGE" ]; then
  # give 'em the news
  db_input medium xdm/default_nolisten_udp || true
  db_input medium xdm/default_servers_100dpi || true
  db_input medium xdm/default_servers_nolisten_tcp || true
  db_go
fi

exit 0

# vim:set ai et sts=2 sw=2 tw=0:
Template: shared/default-x-display-manager
Type: select
Choices: ${choices}
Description: Select the desired default display manager.
 A display manager is a program that provides graphical login capabilities
 for the X Window System.
 .
 Only one display manager can manage a given X server, but multiple display
 manager packages are installed.  Please select which display manager
 should run by default.
 .
 (Multiple display managers can run simultaneously if they are configured
 to manage different servers; to achieve this, configure the display
 managers accordingly, edit each of their init scripts in /etc/init.d, and
 disable the check for a default display manager.)

Template: xdm/default_nolisten_udp
Type: note
Description: xdm does not listen on a UDP port by default.
 Because xdm (the X Display Manager) is a daemon that runs with superuser
 privileges, by default it runs with UDP port listening disabled as a security
 measure.  This means that, as shipped, xdm is not reachable via the network
 and is unable to manage X servers running on remote hosts.  Most people do
 not need to enable UDP port listening in xdm; it can manage local X servers
 without this functionality enabled.
 .
 xdm can be configured to manage remote X servers by appropriately editing
 /etc/X11/xdm/Xaccess and /etc/X11/xdm/xdm-config.  See the xdm(1) manual page
 for more information.

Template: xdm/default_servers_100dpi
Type: note
Description: xdm starts X servers using 100 dpi.
 You should be aware that, by default, xdm (the X Display Manager) manages a
 local X server using the "-dpi 100" argument, which forces the X server to
 treat the display as having 100 dots per inch.  This particularly affects the
 visible font size.  Another common default is 75 dpi; some font rasterizers
 do not deal well with dpi settings other than 75 or 100.
 .
 The "-dpi 100" setting can be changed or removed by editing
 /etc/X11/xdm/Xservers.

Template: xdm/default_servers_nolisten_tcp
Type: note
Description: X servers started with xdm do not listen on a TCP port by default.
 Because the X server runs with superuser privileges, by default it operates
 with TCP port listening disabled as a security measure.  This means that, as
 shipped, X servers started with xdm are not reachable via the network and
 will refuse connections from X clients running on remote hosts.   (Outbound
 connections, such as those to X font servers, are not affected; neither are
 sessions tunneled or forwarded with ssh.)
 .
 Many people do not need to enable TCP port listening in their X servers; if
 you do, for instance to display remote X clients to your local X server, you
 can edit /etc/X11/xdm/Xservers to remove the "-nolisten tcp" option.  Note
 that editing this file has no effect on X servers started with startx, xinit,
 or other display managers.

Template: xdm/daemon_name
Type: string
Default: /usr/bin/X11/xdm
Description: internal use only
#!/bin/sh
# Debian xdm package post-installation script
# Copyright 1998-2001 Branden Robinson.
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
# Acknowlegements to Stephen Early, Mark Eichin, and Manoj Srivastava.

set -e

THIS_PACKAGE=xdm
THIS_SCRIPT=postinst

#INCLUDE_SHELL_LIB#

# source debconf library
. /usr/share/debconf/confmodule

check_symlinks_and_bomb /usr/X11R6/lib/X11/xdm

# now safe to remove old xserver dir
if [ -e /usr/X11R6/lib/X11/xdm.moved-by-preinst -a -L /usr/X11R6/lib/X11/xdm ]; then
  rm -r /usr/X11R6/lib/X11/xdm.moved-by-preinst
fi

# deal with a bug in very old versions of xbase
for DIR in rc0.d rc1.d rc6.d; do
  if [ -L /etc/$DIR/K1xdm ]; then
    mv /etc/$DIR/K1xdm /etc/$DIR/K01xdm
  fi
done

DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager

# debconf is not a registry, so we only fiddle with the default file if it
# does not exist
if [ ! -e $DEFAULT_DISPLAY_MANAGER_FILE ]; then
  db_get shared/default-x-display-manager
  if [ "$THIS_PACKAGE" != "$RET" ]; then
    message "Please be sure to run \"dpkg --configure $RET\"."
  fi
  db_get "$RET"/daemon_name
  echo "$RET" > $DEFAULT_DISPLAY_MANAGER_FILE
fi

# restarting the daemon may cause output to stdout
db_stop

NOSTART=
XDM_RUNNING=
# don't start xdm if we are upgrading without stopping it
if [ -e /var/run/xdm.upgrade ]; then
  NOSTART=yes
fi
# or if we're currently in X on the display it attempts to manage by default
for HOSTNAME in "" "localhost" "$(hostname)" "$(hostname -f)"; do
  if echo $DISPLAY | grep -q "^$HOSTNAME:0.*"; then
    NOSTART=yes
  fi
done
# or if it's already running
if start-stop-daemon --stop --quiet --signal 0 --pid /var/run/xdm.pid --exec /usr/bin/X11/xdm; then
  NOSTART=yes
  XDM_RUNNING=yes
fi
# or if the options file says not to
if ! grep -qs ^restart-on-upgrade /etc/X11/xdm/xdm.options; then
  NOSTART=yes
fi

if [ -n "$XDM_RUNNING" ]; then
  if [ -d /var/state/xdm ]; then
    message "Note: obsolete directory /var/state/xdm cannot be removed" \
            "because xdm is still running.  Reinstall the xdm package" \
            "(or remove the directory manually) when xdm is not running."
  fi
else
  if [ -d /var/state/xdm ]; then
    rm -r /var/state/xdm
  fi
fi

update-rc.d xdm defaults 99 01 > /dev/null 2>&1

[ -n "$NOSTART" ] || /etc/init.d/xdm start || true

#DEBHELPER#

exit 0

# vim:set ai et sts=2 sw=2 tw=0:
#!/bin/sh
# Debian xdm package pre-removal script
# Copyright 1998-2001 Branden Robinson.
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
# Acknowlegements to Stephen Early, Mark Eichin, and Manoj Srivastava.

set -e

THIS_PACKAGE=xdm
THIS_SCRIPT=prerm

#INCLUDE_SHELL_LIB#

parseans () {
  if [ -z "$1" ]; then
    echo $DEFAULT
  else
    echo "$1" | cut -c1 | tr '[A-Z]' '[a-z]';
  fi;
}

case "$1" in
  # we NEVER want to stop xdm without doing some checks first, see below
  upgrade|failed-upgrade)
    REMOVING=
    ;;
  remove|deconfigure)
    REMOVING=yes
    ;;
esac

STOP=
# are we supposed to restart on upgrade?  if REMOVING xdm, we don't care
if grep -qs ^restart-on-upgrade /etc/X11/xdm/xdm.options || [ -n "$REMOVING" ]; then
  # is there an xdm process running?
  if start-stop-daemon --stop --quiet --signal 0 --exec /usr/bin/X11/xdm; then
    # any children?
    PARENTS=$(pidof /usr/bin/X11/xdm || true)
    CHILDREN=
    for PROCESS in $PARENTS; do
      # make sure we got numbers back
      if ! [ $PROCESS -eq $PROCESS ] 2> /dev/null; then
        # freak out
        errormsg "ERROR: pidof returned non-numeric value!"
      fi
      # we could use grep -q here if ps would ignore SIGPIPE :-P
      if (ps axj | grep "^ *$PROCESS" > /dev/null 2>&1); then
        CHILDREN=yes
      fi
    done
    if [ -n "$CHILDREN" ]; then
      message "WARNING: Preparing to stop X display manager (xdm) daemon," \
              "and it appears to be managing at least one running X" \
              "session.  If xdm is stopped now, any X sessions it manages" \
              "will be terminated.  Otherwise you may leave xdm running," \
              "and the new version will take effect the next time xdm is" \
              "restarted."
      message
      DEFAULT=n
      VALID_ANSWER=
      while [ -z "$VALID_ANSWER" ]; do
        message_nonl "Do you wish to stop the xdm daemon? (y/n) [$DEFAULT] "
        read ANSWER
        ANSWER=$(parseans $ANSWER)
        case "$ANSWER" in
          y) VALID_ANSWER=true; STOP=yes ;;
          n) VALID_ANSWER=true ;;
          *) message "\"$ANSWER\" not understood." ;;
        esac
      done
    else
      STOP=yes
    fi
  fi
fi

if [ -n "$STOP" ]; then
  /etc/init.d/xdm stop || true
else
  if [ "$1" = "upgrade" -o "$1" = "failed-upgrade" ]; then
    touch /var/run/xdm.upgrade
  fi
fi

THIS_DISPLAY_MANAGER=/usr/bin/X11/xdm
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager

if [ "$1" = "remove" -o "$1" = "deconfigure" ]; then
  update-alternatives --remove xdm-greeter /usr/X11R6/lib/libXdmGreet.so.1
  rm -f /usr/X11R6/lib/libXdmGreet.so

  if [ -e /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
    # disown this question
    db_unregister shared/default-x-display-manager
    # does the question still exist?
    if db_get shared/default-x-display-manager; then
      db_metaget shared/default-x-display-manager owners
      db_subst shared/default-x-display-manager choices "$RET"
      db_get shared/default-x-display-manager
      # are we removing the currently selected display manager?
      if [ "$THIS_PACKAGE" = "$RET" ]; then
        if [ -e $DEFAULT_DISPLAY_MANAGER_FILE ]; then
          db_get "$RET"/daemon_name
          # does the display manager file reference the current default?
          # if so, remove it because it will now be wrong
          if [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" = "$RET" ]; then
            rm $DEFAULT_DISPLAY_MANAGER_FILE
          fi
        fi
        # ask the user to choose a new default
        db_fset shared/default-x-display-manager seen false
        db_input critical shared/default-x-display-manager || true
        db_go
        # if the display manager file doesn't exist, write it with the path
        # to the new default display manager
        if [ ! -e $DEFAULT_DISPLAY_MANAGER_FILE ]; then
          db_get shared/default-x-display-manager
          message "Please be sure to run \"dpkg-reconfigure $RET\"."
          db_get "$RET"/daemon_name
          echo "$RET" > $DEFAULT_DISPLAY_MANAGER_FILE
        fi
      fi
    fi
  fi
fi

#DEBHELPER#

exit 0

# vim:set ai et sts=2 sw=2 tw=0:

Attachment: pgpHEAqif17tD.pgp
Description: PGP signature


Reply to: