/mandos/release

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

« back to all changes in this revision

Viewing changes to debian/mandos-client.postinst

  • Committer: Teddy Hogeborn
  • Date: 2019-07-27 10:11:45 UTC
  • mto: This revision was merged to the branch mainline in revision 384.
  • Revision ID: teddy@recompile.se-20190727101145-jnpbpf8220gldbcd
Add dracut(8) support

Add support for the dracut(8) system for generating initramfs image
files; dracut is an alternative to the "initramfs-tools" package.

* .bzrignore (dracut-module/password-agent): Ignore new binary file.
* dracut-module: New directory for the dracut module.
* INSTALL (Prerequisites/Libraries/Mandos Client): Add dracut as an
                                                   alternative to
                                                   initramfs-tools,
                                                   and also add GLib.
* Makefile (DRACUTMODULE, GLIB_CFLAGS, GLIB_LIBS): New.
  (CPROGS): Add "dracut-module/password-agent".
  (DOCS): Add "dracut-module/password-agent.8mandos".
  (dracut-module/password-agent.8mandos): New.
  (dracut-module/password-agent.8mandos.xhtml): - '' -
  (dracut-module/password-agent): - '' -
  (check): Add command to run tests of password-agent(8mandos).
  (install-client-nokey): Also install the dracut module directory,
                          its files, and the password-agent(8mandos)
                          manual page.
  (install-client): To update the initramfs image file, run
                    update-initramfs or dracut depending on what is
                    installed.
  (uninstall-client): - '' - and also uninstall the the files in the
                      dracut module directory, that directory itself,
                      and the password-agent(8mandos) manual page.
* debian/control (Build-Depends): Add "libglib2.0-dev (>=2.40)".
  (Package: mandos-client/Depends): Add "dracut (>= 044+241-3)" as an
                                    alternative dependency to
                                    initramfs-tools.
  (Package: mandos-client/Conflicts): New; set to
                                      "dracut-config-generic".
  (debian/mandos-client.README.Debian): Document alternative commands
                                        to update the initramfs image
                                        for when dracut is used.
* debian/mandos-client.postinst (update_initramfs): Use alternative
                                                    commands to update
                                                    the initramfs
                                                    image for when
                                                    dracut is used.
* debian/tests/control (password-agent, password-agent-suid): Add two
                                                              new tests.
* dracut-module/ask-password-mandos.path: New.
* dracut-module/ask-password-mandos.service: - '' -
* dracut-module/cmdline-mandos.sh: - '' -
* dracut-module/module-setup.sh: - '' -
* dracut-module/password-agent.c: - '' -
* dracut-module/password-agent.xml: - '' -
* initramfs-unpack: Use the dracut "skipcpio" command, if available.
                    Also be more flexible and try hard to detect where
                    compressed data starts.
* plugins.d/mandos-client.xml (SECURITY): Be more precise that the
                                          mandos-client binary might
                                          not always be setuid, but
                                          that the program assumes
                                          that it has been started
                                          that way.
* plugins.d/password-prompt.c: Add new "--prompt" option.
  (conflict_detection): First try to detect the new PID file of
                        plymouth.
  (main): Define and use new "prompt" variable.
* plugins.d/password-prompt.xml (SYNOPSIS): Show new --prompt option.
  (DESCRIPTION): Describe new behavior of looking for plymouth PID
                 file.
  (OPTIONS): Document new "--prompt" option.
  (ENVIRONMENT): Clarify that the CRYPTTAB_SOURCE and CRYPTTAB_NAME
                 environment variables are not used if the --prompt
                 option is used.  Remove unnecessarily specific
                 details about where the CRYPTTAB_SOURCE and
                 CRYPTTAB_NAME comes from, since this can now be
                 either initramfs-tools or dracut.
  (SEE ALSO): Remove superfluous crypttab(5) reference, and add commas
              to separate the other references.
* plugins.d/plymouth.c: Add new "--prompt" and "--debug" options.
  (debug): New global flag.
  (fprintf_plus): New function, used for debug output.
  (exec_and_wait): Add extra "const" to "argv" argument.
  (main): Define and use new "prompt" variable.  Add debug output.
  (main/options, main/parse_opt): New; used to parse options.
* plugins.d/plymouth.xml (SYNOPSIS): Show new options.
  (OPTIONS): Document new options.
  (ENVIRONMENT): Clarify that the cryptsource and crypttarget
                 environment variables are not used if the --prompt
                 option is used.  Remove unnecessarily specific
                 details about where the cryptsource and crypttarget
                 comes from, since this can now be either
                 initramfs-tools or dracut.
  (EXAMPLE): Add an example using an option.
  (SEE ALSO): Remove superfluous crypttab(5) reference.
* plugins.d/splashy.xml (ENVIRONMENT): Clarify that the cryptsource
                                       and crypttarget environment
                                       variables are not used if the
                                       --prompt option is used.
                                       Remove unnecessarily specific
                                       details about where the
                                       cryptsource and crypttarget
                                       comes from, since this can now
                                       be either initramfs-tools or
                                       dracut.
  (SEE ALSO): Remove superfluous crypttab(5) reference.
* plugins.d/usplash.xml (ENVIRONMENT): Clarify that the cryptsource
                                       and crypttarget environment
                                       variables are not used if the
                                       --prompt option is used.
                                       Remove unnecessarily specific
                                       details about where the
                                       cryptsource and crypttarget
                                       comes from, since this can now
                                       be either initramfs-tools or
                                       dracut.
  (SEE ALSO): Remove superfluous crypttab(5) reference.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
update_initramfs()
24
24
{
25
25
    if command -v update-initramfs >/dev/null; then
26
 
        update-initramfs -k all -u 1>&2
 
26
        update-initramfs -k all -u
27
27
    elif command -v dracut >/dev/null; then
28
28
        dracut_version="`dpkg-query --showformat='${Version}' --show dracut`"
29
29
        if dpkg --compare-versions "$dracut_version" lt 043-1 \
37
37
            # Dracut preserves old permissions of initramfs image
38
38
            # files, so we adjust permissions before creating new
39
39
            # initramfs image containing secret keys.
40
 
            if [ -e /boot/initrd.img-"$kversion" ]; then
41
 
                chmod go-r /boot/initrd.img-"$kversion"
42
 
            else
43
 
                # An initrd image has not yet been created for this
44
 
                # kernel, possibly because this new kernel is about to
45
 
                # be, but has not yet been, installed.  In this case,
46
 
                # we create an empty file with the right permissions
47
 
                # so that Dracut will preserve those permissions when
48
 
                # it creates the real, new initrd image for this
49
 
                # kernel.
50
 
                install --mode=u=rw /dev/null \
51
 
                        /boot/initrd.img-"$kversion"
52
 
            fi
 
40
            chmod go-r /boot/initrd.img-"$kversion"
53
41
            if [ "$kversion" != "*" ]; then
54
 
                /etc/kernel/postinst.d/dracut "$kversion" 1>&2
 
42
                /etc/kernel/postinst.d/dracut "$kversion"
55
43
            fi
56
44
        done
57
45
    fi
70
58
    if dpkg --compare-versions "$2" lt "1.0.3-1"; then
71
59
        case "`getent passwd mandos`" in
72
60
            *:Mandos\ password\ system,,,:/nonexistent:/bin/false)
73
 
                usermod --login _mandos mandos 1>&2
74
 
                groupmod --new-name _mandos mandos 1>&2
 
61
                usermod --login _mandos mandos
 
62
                groupmod --new-name _mandos mandos
75
63
                return
76
64
                ;;
77
65
        esac
80
68
    if ! getent passwd _mandos >/dev/null; then
81
69
        adduser --system --force-badname --quiet --home /nonexistent \
82
70
            --no-create-home --group --disabled-password \
83
 
            --gecos "Mandos password system" _mandos 1>&2
 
71
            --gecos "Mandos password system" _mandos
84
72
    fi
85
73
}
86
74
 
90
78
    # mandos-keygen
91
79
    if ! [ -r /etc/keys/mandos/pubkey.txt \
92
80
              -a -r /etc/keys/mandos/seckey.txt ]; then
93
 
        mandos-keygen 1>&2
94
 
        gpg-connect-agent KILLAGENT /bye 1>&2 || :
 
81
        mandos-keygen
 
82
        gpg-connect-agent KILLAGENT /bye || :
95
83
        return 0
96
84
    fi
97
85
 
102
90
        if ! certtool --password='' \
103
91
             --load-privkey=/etc/keys/mandos/tls-privkey.pem \
104
92
             --outfile=/dev/null --pubkey-info --no-text \
105
 
              1>&2 2>/dev/null; then
 
93
             2>/dev/null; then
106
94
            shred --remove -- /etc/keys/mandos/tls-privkey.pem \
107
95
                  2>/dev/null || :
108
96
            rm --force -- /etc/keys/mandos/tls-pubkey.pem
121
109
 
122
110
    if certtool --generate-privkey --password='' \
123
111
                --outfile "$TLS_PRIVKEYTMP" --sec-param ultra \
124
 
                --key-type=ed25519 --pkcs8 --no-text 1>&2 \
125
 
                2>/dev/null; then
 
112
                --key-type=ed25519 --pkcs8 --no-text 2>/dev/null; then
126
113
 
127
114
        local umask=$(umask)
128
115
        umask 077
133
120
        if ! certtool --password='' \
134
121
             --load-privkey=/etc/keys/mandos/tls-privkey.pem \
135
122
             --outfile=/etc/keys/mandos/tls-pubkey.pem --pubkey-info \
136
 
             --no-text 1>&2 2>/dev/null; then
 
123
             --no-text 2>/dev/null; then
137
124
            # Otherwise try OpenSSL
138
125
            if ! openssl pkey -in /etc/keys/mandos/tls-privkey.pem \
139
 
                 -out /etc/keys/mandos/tls-pubkey.pem -pubout \
140
 
                 1>&2; then
 
126
                 -out /etc/keys/mandos/tls-pubkey.pem -pubout; then
141
127
                rm --force /etc/keys/mandos/tls-pubkey.pem
142
128
                # None of the commands succeded; give up
143
129
                umask $umask
169
155
    DHFILE="`mktemp -t mandos-client-dh-parameters.XXXXXXXXXX.pem`"
170
156
    # First try certtool from GnuTLS
171
157
    if ! certtool --generate-dh-params --sec-param high \
172
 
         --outfile "$DHFILE" 1>&2; then
 
158
         --outfile "$DHFILE"; then
173
159
        # Otherwise try OpenSSL
174
160
        if ! openssl genpkey -genparam -algorithm DH -out "$DHFILE" \
175
 
             -pkeyopt dh_paramgen_prime_len:3072 1>&2; then
 
161
             -pkeyopt dh_paramgen_prime_len:3072; then
176
162
            # None of the commands succeded; give up
177
 
            rm --force -- "$DHFILE"
 
163
            rm -- "$DHFILE"
178
164
            return 1
179
165
        fi
180
166
    fi
183
169
    sed --in-place --expression='1i-----BEGIN DH PARAMETERS-----' \
184
170
            "$DHFILE"
185
171
    cp --archive "$DHFILE" /etc/keys/mandos/dhparams.pem
186
 
    rm --force -- "$DHFILE"
 
172
    rm -- "$DHFILE"
187
173
}
188
174
 
189
175
case "$1" in