~ubuntu-branches/ubuntu/vivid/freeradius/vivid-proposed

« back to all changes in this revision

Viewing changes to debian/freeradius.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Josip Rodin
  • Date: 2010-11-13 15:21:30 UTC
  • Revision ID: james.westby@ubuntu.com-20101113152130-t2zgx0b02szwv297
Tags: 2.1.10+dfsg-2
* The zombie period start time variable mistakenly got set to a random
  value because of an upstream typo. Cherry-picked upstream commit
  7b7dff7724721f8af5fd163f2292d427a869992d into a Debian patch,
  requested for squeeze in #600465.
* Since 2.1.9, the daemon stopped reopening the default radius.log file
  constantly, which means the default logrotate setup breaks the default
  logging. D'oh. We now have to send SIGHUP to the daemon as a postrotate
  action, which makes it reopen log files and continue normally.
  * Added delaycompress to the logrotate options, just to be on the safe
    side.
  * Added a reload action into the init script accordingly, so that the
    right pidfile is picked up (one that can be overridden by the admin
    in /etc/default/freeradius, available since the last release).
  * Called reload from the postrotate section, closes: #602815.
  * However, the latter signal also makes the server re-read configuration
    files, but unlike the initial server start, this all happens under
    the unprivileged user. That in turn means that if by any chance there
    is any part of FR configuration that happens not to be readable by
    group freerad (or whatever non-default is configured), the reload
    will fail, effectively silently, as the log has been moved away. Gah.
    So we have to make an effort to ensure that the configuration files
    are still readable by that user, otherwise the reload fails and the
    aforementioned bug is not fixed. The files seem to revert to
    root:root upon conffile actions, at least that's what happened to me
    and I think that was the cause. So, on upgrade, try to re-apply the
    dpkg-statoverrides on our /etc/freeradius/* stuff, whatever they are,
    under the assumption they will let the freerad group read config files
    as is the initial setup. (I wish dpkg-statoverride --update $file
    just did the right thing, but it doesn't, so there's a new local
    function that does that.)
  * While doing the latter, noticed that we were checking for directories
    in dpkg-statoverride --list output with trailing slashes, but they
    get output without it, so it was a no-op. Fixed the check by removing
    the trailing slashes. Also then noticed that we were grepping --list
    output, but it takes an optional glob pattern, so saved us that
    pointless grep fork by using that facility, just as described in the
    policy manual.
  * force-reload switches from restart to reload, per policy 9.3.2.
* lenny backport needed also libltdl-dev (2.2.x) to build properly, rather
  than libltdl3-dev, which is obsolete and doesn't make sense anyway.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
set -e
4
4
 
 
5
update_fs_from_statoverride() {
 
6
  # I wish a simple dpkg-statoverride --update $file just did
 
7
  # the right thing, but it doesn't, so we have to do it manually.
 
8
  type=$1
 
9
  user=$2
 
10
  group=$3
 
11
  mode=$4
 
12
  file=$5
 
13
  if [ -n "$type" -a -n "$group" -a -n "$mode" -a -n "$file" ]; then
 
14
    if [ "$(find $file -maxdepth 0 -type $type -group $group -perm $mode)" = "" -a -$type $file ]; then
 
15
      chgrp $group $file
 
16
      chmod $mode $file
 
17
    fi
 
18
  fi
 
19
}
 
20
 
 
21
handle_config_files() {
 
22
  runmode=$1
 
23
 
 
24
  for file in /etc/freeradius/preproxy_users \
 
25
              /etc/freeradius/policy.conf \
 
26
              /etc/freeradius/eap.conf \
 
27
              /etc/freeradius/experimental.conf \
 
28
              /etc/freeradius/huntgroups \
 
29
              /etc/freeradius/proxy.conf \
 
30
              /etc/freeradius/attrs.pre-proxy \
 
31
              /etc/freeradius/hints \
 
32
              /etc/freeradius/sql.conf \
 
33
              /etc/freeradius/ldap.attrmap \
 
34
              /etc/freeradius/attrs \
 
35
              /etc/freeradius/policy.txt \
 
36
              /etc/freeradius/attrs.accounting_response \
 
37
              /etc/freeradius/attrs.access_reject \
 
38
              /etc/freeradius/attrs.access_challenge \
 
39
              /etc/freeradius/clients.conf \
 
40
              /etc/freeradius/acct_users
 
41
  do
 
42
    set +e
 
43
    so=$(dpkg-statoverride --list $file)
 
44
    ret=$?
 
45
    set -e
 
46
    case "$runmode" in
 
47
      initial)
 
48
        if [ $ret != 0 ]; then
 
49
          dpkg-statoverride --add --update root freerad 0640 $file
 
50
        fi
 
51
        ;;
 
52
      upgrade)
 
53
        update_fs_from_statoverride f $so
 
54
        ;;
 
55
    esac
 
56
  done
 
57
 
 
58
  for dir in /etc/freeradius/certs \
 
59
             /etc/freeradius/sites-available \
 
60
             /etc/freeradius/sites-enabled
 
61
  do
 
62
    set +e
 
63
    so=$(dpkg-statoverride --list $dir)
 
64
    ret=$?
 
65
    set -e
 
66
    case "$runmode" in
 
67
      initial)
 
68
        if [ $ret != 0 ]; then
 
69
          dpkg-statoverride --add --update freerad freerad 2751 $dir
 
70
        fi
 
71
        ;;
 
72
      upgrade)
 
73
        update_fs_from_statoverride d $so
 
74
        ;;
 
75
    esac
 
76
  done
 
77
}
 
78
 
5
79
case "$1" in
6
80
  configure)
7
81
        if [ -z "$2" ]; then
 
82
 
8
83
          # Changed in 1.1.5-1 for new installs (we used to start at S50
9
84
          # and stop at K50)  We now start at S50 and stop at K19 so we
10
85
          # start after services which may be used and stop before them.
12
87
 
13
88
          # Set up initial permissions on all the freeradius directories
14
89
 
15
 
          if ! dpkg-statoverride --list | grep -q /var/run/freeradius$; then
 
90
          if ! dpkg-statoverride --list /var/run/freeradius >/dev/null; then
16
91
            dpkg-statoverride --add --update freerad freerad 0755 /var/run/freeradius
17
92
          fi
18
93
 
19
 
          if ! dpkg-statoverride --list | grep -q /var/log/freeradius$; then
 
94
          if ! dpkg-statoverride --list /var/log/freeradius >/dev/null; then
20
95
            dpkg-statoverride --add --update freerad freerad 0750 /var/log/freeradius
21
96
          fi
22
97
 
24
99
            [ ! -f "/var/log/freeradius/${file}" ] && install -o freerad -g freerad -m 644 /dev/null /var/log/freeradius/${file}
25
100
          done
26
101
 
27
 
          for file in /etc/freeradius/preproxy_users \
28
 
            /etc/freeradius/policy.conf \
29
 
            /etc/freeradius/eap.conf \
30
 
            /etc/freeradius/experimental.conf \
31
 
            /etc/freeradius/huntgroups \
32
 
            /etc/freeradius/proxy.conf \
33
 
            /etc/freeradius/attrs.pre-proxy \
34
 
            /etc/freeradius/hints \
35
 
            /etc/freeradius/sql.conf \
36
 
            /etc/freeradius/ldap.attrmap \
37
 
            /etc/freeradius/attrs \
38
 
            /etc/freeradius/policy.txt \
39
 
            /etc/freeradius/attrs.accounting_response \
40
 
            /etc/freeradius/attrs.access_reject \
41
 
            /etc/freeradius/attrs.access_challenge \
42
 
            /etc/freeradius/clients.conf \
43
 
            /etc/freeradius/acct_users
44
 
          do
45
 
            if ! dpkg-statoverride --list | grep -qw $file$; then
46
 
              dpkg-statoverride --add --update root freerad 0640 $file
47
 
            fi
48
 
          done
49
 
 
50
 
          for dir in /etc/freeradius/certs/ \
51
 
            /etc/freeradius/sites-available/ \
52
 
            /etc/freeradius/sites-enabled/
53
 
          do
54
 
            if ! dpkg-statoverride --list | grep -qw $dir$; then
55
 
              dpkg-statoverride --add --update freerad freerad 2751 $dir
56
 
            fi
57
 
          done
 
102
          handle_config_files initial
58
103
 
59
104
          action="start"
 
105
 
60
106
        else
 
107
 
 
108
          handle_config_files upgrade
61
109
          action="restart"
 
110
 
62
111
        fi
63
112
 
64
113
        # Create links for default sites, but only if this is an initial