summaryrefslogtreecommitdiff
path: root/debian/x11-common.config.in
blob: b81afafd2f950e51454adf8c41ff11e1aaecdbca (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
# Debian x11-common package configuration script
# Copyright 2000--2003 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=x11-common
THIS_SCRIPT=config

#INCLUDE_SHELL_LIB#

CONFIG_DIR=/etc/X11
XWRAPPER_CONFIG="$CONFIG_DIR/Xwrapper.config"

allowed_users_english_to_actual () {
  case "$1" in
    "Root Only")
      echo "rootonly"
      ;;
    "Console Users Only")
      echo "console"
      ;;
    "Anybody")
      echo "anybody"
      ;;
    *)
      # garbage input; return default
      observe "allowed_users_english_to_actual(): unrecognized input \"$1\";" \
              "using default"
      echo "console"
      ;;
  esac
}

allowed_users_actual_to_english () {
  case "$1" in
    "rootonly")
      echo "Root Only"
      ;;
    "console")
      echo "Console Users Only"
      ;;
    "anybody")
      echo "Anybody"
      ;;
    *)
      # garbage input; return default
      observe "allowed_users_actual_to_english(): unrecognized input \"$1\";" \
              "using default"
      echo "Console Users Only"
      ;;
  esac
}

CURRENT_ALLOWED_USERS=

# scan the X wrapper config file for existing settings, if it exists
if [ -e "$XWRAPPER_CONFIG" ]; then
  if MATCHES=$(grep "^allowed_users=.\+" "$XWRAPPER_CONFIG"); then
    CURRENT_ALLOWED_USERS=$(echo "${MATCHES##*=}" | head -n 1)
  fi
fi

if [ -n "$CURRENT_ALLOWED_USERS" ]; then
  observe "setting x11-common/xwrapper/allowed_users from configuration" \
          "file"
  run db_set x11-common/xwrapper/allowed_users \
                      $(allowed_users_actual_to_english \
                      "$CURRENT_ALLOWED_USERS")
fi

run db_input low x11-common/xwrapper/allowed_users
run db_go

RET=
if db_get x11-common/xwrapper/allowed_users; then
  if [ -n "$RET" ]; then
    run db_set x11-common/xwrapper/actual_allowed_users \
                        $(allowed_users_english_to_actual "$RET")
  fi
fi
exit 0

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