/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: 2016-03-19 03:51:23 UTC
  • Revision ID: teddy@recompile.se-20160319035123-53w4dbzdyjef29m1
Server: New tmpfiles.d file for persistent state directory

Provide a tmpfiles.d(5) file for systemd to create persistent state
directory on so-called "volatile" systems.

* Makefile (TMPFILES): New.
  (install-server): Also install "tmpfiles.d-mandos.conf" file as
                    "/usr/lib/tmpfiles.d/mandos.conf".
* tmpfiles.d-mandos.conf: New.

Show diffs side-by-side

added added

removed removed

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