summaryrefslogtreecommitdiffstats
path: root/debian/gdm3.preinst
blob: 93ebed932583038b1e277a4a4e5303e01f8e153e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

set -e

if [ "$1" = "upgrade" ] || [ "$1" = "install" ]; then
  # Remove wrongly replaced custom.config file by versions > 3.37.90 && < 3.38.1
  # This script can be safely removed post 20.10 release
  prev_version="$2"
  if dpkg --compare-versions "$prev_version" ge 3.37.90 &&
     dpkg --compare-versions "$prev_version" lt-nl 3.38.1; then
    conf_file=/etc/gdm3/daemon.conf
    if [ "${prev_version#*ubuntu}" != "$prev_version" ]; then
      conf_file=/etc/gdm3/custom.conf
    fi

    conf="${DPKG_ROOT}$conf_file"
    if [ -f "$conf" ] &&
       echo "ed0a2d19ba7344faa0feadd783bb4fa5 $conf" | md5sum -c --status; then
      # If the file matches this checksum, then it's a file generated by
      # /usr/libexec/gdm-disable-wayland that was wrongly replaced, so we
      # replace the conf file to match the one that was default in these
      # broken versions, so that dpkg would replace it in case.
      echo "Configuration file $conf_file has likely been damaged by" \
        "https://pad.lv/1899673, replacing with the gdm default..."
      cat <<'EOF' > "$conf"
# GDM configuration storage
#
# See /usr/share/gdm/gdm.schemas for a list of available options.

[daemon]
# Uncomment the line below to force the login screen to use Xorg
#WaylandEnable=false

# Enabling automatic login
#  AutomaticLoginEnable = true
#  AutomaticLogin = user1

# Enabling timed login
#  TimedLoginEnable = true
#  TimedLogin = user1
#  TimedLoginDelay = 10

[security]

[xdmcp]

[chooser]

[debug]
# Uncomment the line below to turn on debugging
# More verbose logs
# Additionally lets the X server dump core if it crashes
#Enable=true

EOF

      # Verify that the file we've just added matches the default one
      # We don't fail as it's not a fatal error, but will cause manual
      # intervention at later points
      default_md5sum="$(dpkg-query -W -f='${Conffiles}' gdm3 | \
       sed -n -e "\\'^ $conf_file ' { s/ obsolete$//; s/.* //; p }")"
      echo "$default_md5sum $conf" | md5sum -c --status ||
        echo "Replaced configuration file isn't matching expected default"
    fi
  fi
fi

#DEBHELPER#