/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to debian/mandos-client.postinst

  • Committer: Teddy Hogeborn
  • Date: 2009-09-21 21:39:25 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090921213925-jbpt6tzu99otseng
Use D-Bus properties instead of our own methods.

* mandos (Client._datetime_to_milliseconds): Renamed to
                                             "_timedelta_to_milliseconds".
                                             All callers changed.
  (dbus_service_property): New decorator for D-Bus properties.
  (DBusPropertyException, DBusPropertyAccessException,
  DBusPropertyNotFound): New D-Bus exception classes.
  (DBusObjectWithProperties): New; extends "dbus.service.Object" with
                              support for properties.
  (ClientDBus): Inherit from, and call up to, "DBusObjectWithProperties".
  (ClientDBus.CheckedOK, ClientDBus.GetAllProperties,
  ClientDBus.SetChecker, ClientDBus.SetHost, ClientDBus.SetInterval,
  ClientDBus.SetSecret, ClientDBus.SetTimeout, ClientDBus.Enable,
  ClientDBus.StartChecker, ClientDBus.Disable,
  ClientDBus.StopChecker): Removed, replaced with properties.
  (ClientDBus.IsStillValid): Removed, superfluous.
  (ClientDBus.name_dbus_property,
  ClientDBus.fingerprint_dbus_property, ClientDBus.host_dbus_property,
  ClientDBus.created_dbus_property,
  ClientDBus.last_enabled_dbus_property,
  ClientDBus.enabled_dbus_property,
  ClientDBus.last_checked_ok_dbus_property,
  ClientDBus.timeout_dbus_property, ClientDBus.interval_dbus_property,
  ClientDBus.checker_dbus_property,
  ClientDBus.checker_running_dbus_property,
  ClientDBus.object_path_dbus_property,
  ClientDBus.secret_dbus_property): New D-Bus properties.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
 
1
#!/bin/sh -e
2
2
# This script can be called in the following ways:
3
3
#
4
4
# After the package was installed:
15
15
# If prerm fails during replacement due to conflict:
16
16
#       <postinst> abort-remove in-favour <new-package> <version>
17
17
 
18
 
set -e
19
 
 
20
18
# Update the initial RAM file system image
21
19
update_initramfs()
22
20
{
23
 
    update-initramfs -u -k all
 
21
    if [ -x /usr/sbin/update-initramfs ]; then
 
22
        update-initramfs -u -k all
 
23
    fi
24
24
    
25
25
    if dpkg --compare-versions "$2" lt-nl "1.0.10-1"; then
26
26
        # Make old initrd.img files unreadable too, in case they were
56
56
        -a -r /etc/keys/mandos/seckey.txt ]; then
57
57
        return 0
58
58
    fi
59
 
    mandos-keygen
60
 
    gpg-connect-agent KILLAGENT /bye || :
61
 
}
62
 
 
63
 
create_dh_params(){
64
 
    if [ -r /etc/keys/mandos/dhparams.pem ]; then
65
 
        return 0
66
 
    fi
67
 
    # Create a Diffe-Hellman parameters file
68
 
    DHFILE="`mktemp -t mandos-client-dh-parameters.XXXXXXXXXX.pem`"
69
 
    # First try certtool from GnuTLS
70
 
    if ! certtool --generate-dh-params --sec-param high \
71
 
         --outfile "$DHFILE"; then
72
 
        # Otherwise try OpenSSL
73
 
        if ! openssl genpkey -genparam -algorithm DH -out "$DHFILE" \
74
 
             -pkeyopt dh_paramgen_prime_len:3072; then
75
 
            # None of the commands succeded; give up
76
 
            rm -- "$DHFILE"
77
 
            return 1
78
 
        fi
79
 
    fi
80
 
    sed --in-place --expression='0,/^-----BEGIN DH PARAMETERS-----$/d' \
81
 
        "$DHFILE"
82
 
    sed --in-place --expression='1i-----BEGIN DH PARAMETERS-----' \
83
 
            "$DHFILE"
84
 
    cp --archive "$DHFILE" /etc/keys/mandos/dhparams.pem
85
 
    rm -- "$DHFILE"
 
59
    if [ -x /usr/sbin/mandos-keygen ]; then
 
60
        mandos-keygen
 
61
    fi
86
62
}
87
63
 
88
64
case "$1" in
89
65
    configure)
90
66
        add_mandos_user "$@"
91
67
        create_key "$@"
92
 
        create_dh_params "$@" || :
93
68
        update_initramfs "$@"
94
 
        if dpkg --compare-versions "$2" lt-nl "1.7.10-1"; then
95
 
            PLUGINHELPERDIR=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)/mandos/plugin-helpers
96
 
            if ! dpkg-statoverride --list "$PLUGINHELPERDIR" \
97
 
                 >/dev/null 2>&1; then
98
 
                chmod u=rwx,go= -- "$PLUGINHELPERDIR"
99
 
            fi
100
 
            if ! dpkg-statoverride --list /etc/mandos/plugin-helpers \
101
 
                 >/dev/null 2>&1; then
102
 
                chmod u=rwx,go= -- /etc/mandos/plugin-helpers
103
 
            fi
104
 
        fi
105
69
        ;;
106
70
    abort-upgrade|abort-deconfigure|abort-remove)
107
71
        ;;