/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 Makefile

  • Committer: Teddy Hogeborn
  • Date: 2019-08-02 22:16:53 UTC
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: teddy@recompile.se-20190802221653-ic1iko9hbefzwsk7
Fix bug in server Debian package: Fails to start on first install

There has been a very long-standing bug where installation of the
server (the "mandos" Debian package) would fail to start the server
properly right after installation.  It would work on manual (re)start
after installation, or after reboot, and even after package purge and
reinstall, it would then work the first time.  The problem, it turns
out, is when the new "_mandos" user (and corresponding group) is
created, the D-Bus server is not reloaded, and is therefore not aware
of that user, and does not recognize the user and group name in the
/etc/dbus-1/system.d/mandos.conf file.  The Mandos server, when it
tries to start and access the D-Bus, is then not permitted to connect
to its D-Bus bus name, and disables D-Bus use as a fallback measure;
i.e. the server works, but it is not controllable via D-Bus commands
(via mandos-ctl or mandos-monitor).  The next time the D-Bus daemon is
reloaded for any reason, the new user & group would become visible to
the D-Bus daemon and after that, any restart of the Mandos server
would succeed and it would bind to its D-Bus name properly, and
thereby be visible and controllable by mandos-ctl & mandos-monitor.
This was mostly invisible when using sysvinit, but systemd makes the
problem visible since the systemd service file for the Mandos server
is configured to not consider the Mandos server "started" until the
D-Bus name has been bound; this makes the starting of the service wait
for 90 seconds and then fail with a timeout error.

Fixing this should also make the Debian CI autopkgtest tests work.

* debian/mandos.postinst (configure): After creating (or renaming)
                                      user & group, reload D-Bus
                                      daemon (if present).

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
htmldir:=man
45
45
version:=1.8.5
46
46
SED:=sed
 
47
PKG_CONFIG?=pkg-config
47
48
 
48
49
USER:=$(firstword $(subst :, ,$(shell getent passwd _mandos \
49
50
        || getent passwd nobody || echo 65534)))
50
51
GROUP:=$(firstword $(subst :, ,$(shell getent group _mandos \
51
52
        || getent group nogroup || echo 65534)))
52
53
 
 
54
LINUXVERSION:=$(shell uname --kernel-release)
 
55
 
53
56
## Use these settings for a traditional /usr/local install
54
57
# PREFIX:=$(DESTDIR)/usr/local
55
58
# CONFDIR:=$(DESTDIR)/etc/mandos
71
74
STATEDIR:=$(DESTDIR)/var/lib/mandos
72
75
LIBDIR:=$(shell \
73
76
        for d in \
74
 
        "/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null`" \
 
77
        "/usr/lib/`dpkg-architecture \
 
78
                        -qDEB_HOST_MULTIARCH 2>/dev/null`" \
75
79
        "`rpm --eval='%{_libdir}' 2>/dev/null`" /usr/lib; do \
76
80
                if [ -d "$$d" -a "$$d" = "$${d%/}" ]; then \
77
81
                        echo "$(DESTDIR)$$d"; \
80
84
        done)
81
85
##
82
86
 
83
 
SYSTEMD:=$(DESTDIR)$(shell pkg-config systemd --variable=systemdsystemunitdir)
84
 
TMPFILES:=$(DESTDIR)$(shell pkg-config systemd --variable=tmpfilesdir)
 
87
SYSTEMD:=$(DESTDIR)$(shell $(PKG_CONFIG) systemd \
 
88
                        --variable=systemdsystemunitdir)
 
89
TMPFILES:=$(DESTDIR)$(shell $(PKG_CONFIG) systemd \
 
90
                        --variable=tmpfilesdir)
85
91
 
86
 
GNUTLS_CFLAGS:=$(shell pkg-config --cflags-only-I gnutls)
87
 
GNUTLS_LIBS:=$(shell pkg-config --libs gnutls)
88
 
AVAHI_CFLAGS:=$(shell pkg-config --cflags-only-I avahi-core)
89
 
AVAHI_LIBS:=$(shell pkg-config --libs avahi-core)
 
92
GNUTLS_CFLAGS:=$(shell $(PKG_CONFIG) --cflags-only-I gnutls)
 
93
GNUTLS_LIBS:=$(shell $(PKG_CONFIG) --libs gnutls)
 
94
AVAHI_CFLAGS:=$(shell $(PKG_CONFIG) --cflags-only-I avahi-core)
 
95
AVAHI_LIBS:=$(shell $(PKG_CONFIG) --libs avahi-core)
90
96
GPGME_CFLAGS:=$(shell gpgme-config --cflags; getconf LFS_CFLAGS)
91
97
GPGME_LIBS:=$(shell gpgme-config --libs; getconf LFS_LIBS; \
92
98
        getconf LFS_LDFLAGS)
93
 
LIBNL3_CFLAGS:=$(shell pkg-config --cflags-only-I libnl-route-3.0)
94
 
LIBNL3_LIBS:=$(shell pkg-config --libs libnl-route-3.0)
95
 
GLIB_CFLAGS:=$(shell pkg-config --cflags glib-2.0)
96
 
GLIB_LIBS:=$(shell pkg-config --libs glib-2.0)
 
99
LIBNL3_CFLAGS:=$(shell $(PKG_CONFIG) --cflags-only-I libnl-route-3.0)
 
100
LIBNL3_LIBS:=$(shell $(PKG_CONFIG) --libs libnl-route-3.0)
 
101
GLIB_CFLAGS:=$(shell $(PKG_CONFIG) --cflags glib-2.0)
 
102
GLIB_LIBS:=$(shell $(PKG_CONFIG) --libs glib-2.0)
97
103
 
98
104
# Do not change these two
99
105
CFLAGS+=$(WARN) $(DEBUG) $(FORTIFY) $(COVERAGE) \
312
318
        ./dracut-module/password-agent --test
313
319
 
314
320
# Run the client with a local config and key
315
 
run-client: all keydir/seckey.txt keydir/pubkey.txt keydir/tls-privkey.pem keydir/tls-pubkey.pem
316
 
        @echo "###################################################################"
317
 
        @echo "# The following error messages are harmless and can be safely     #"
318
 
        @echo "# ignored:                                                        #"
319
 
        @echo "# From plugin-runner: setgid: Operation not permitted             #"
320
 
        @echo "#                     setuid: Operation not permitted             #"
321
 
        @echo "# From askpass-fifo:  mkfifo: Permission denied                   #"
322
 
        @echo "# From mandos-client:                                             #"
323
 
        @echo "#             Failed to raise privileges: Operation not permitted #"
324
 
        @echo "#             Warning: network hook \"*\" exited with status *      #"
325
 
        @echo "#                                                                 #"
326
 
        @echo "# (The messages are caused by not running as root, but you should #"
327
 
        @echo "# NOT run \"make run-client\" as root unless you also unpacked and  #"
328
 
        @echo "# compiled Mandos as root, which is also NOT recommended.)        #"
329
 
        @echo "###################################################################"
 
321
run-client: all keydir/seckey.txt keydir/pubkey.txt \
 
322
                        keydir/tls-privkey.pem keydir/tls-pubkey.pem
 
323
        @echo '######################################################'
 
324
        @echo '# The following error messages are harmless and can  #'
 
325
        @echo '#  be safely ignored:                                #'
 
326
        @echo '## From plugin-runner:                               #'
 
327
        @echo '# setgid: Operation not permitted                    #'
 
328
        @echo '# setuid: Operation not permitted                    #'
 
329
        @echo '## From askpass-fifo:                                #'
 
330
        @echo '# mkfifo: Permission denied                          #'
 
331
        @echo '## From mandos-client:                               #'
 
332
        @echo '# Failed to raise privileges: Operation not permi... #'
 
333
        @echo '# Warning: network hook "*" exited with status *     #'
 
334
        @echo '# ioctl SIOCSIFFLAGS +IFF_UP: Operation not permi... #'
 
335
        @echo '# Failed to bring up interface "*": Operation not... #'
 
336
        @echo '#                                                    #'
 
337
        @echo '# (The messages are caused by not running as root,   #'
 
338
        @echo '# but you should NOT run "make run-client" as root   #'
 
339
        @echo '# unless you also unpacked and compiled Mandos as    #'
 
340
        @echo '# root, which is also NOT recommended.)              #'
 
341
        @echo '######################################################'
330
342
# We set GNOME_KEYRING_CONTROL to block pam_gnome_keyring
331
343
        ./plugin-runner --plugin-dir=plugins.d \
332
344
                --plugin-helper-dir=plugin-helpers \
372
384
        elif install --directory --mode=u=rwx $(STATEDIR); then \
373
385
                chown -- $(USER):$(GROUP) $(STATEDIR) || :; \
374
386
        fi
375
 
        if [ "$(TMPFILES)" != "$(DESTDIR)" -a -d "$(TMPFILES)" ]; then \
 
387
        if [ "$(TMPFILES)" != "$(DESTDIR)" \
 
388
                        -a -d "$(TMPFILES)" ]; then \
376
389
                install --mode=u=rw,go=r tmpfiles.d-mandos.conf \
377
390
                        $(TMPFILES)/mandos.conf; \
378
391
        fi
425
438
        install --mode=u=rwx,go=rx \
426
439
                --target-directory=$(LIBDIR)/mandos plugin-runner
427
440
        install --mode=u=rwx,go=rx \
428
 
                --target-directory=$(LIBDIR)/mandos mandos-to-cryptroot-unlock
 
441
                --target-directory=$(LIBDIR)/mandos \
 
442
                mandos-to-cryptroot-unlock
429
443
        install --mode=u=rwx,go=rx --target-directory=$(PREFIX)/sbin \
430
444
                mandos-keygen
431
445
        install --mode=u=rwx,go=rx \
494
508
        if command -v update-initramfs >/dev/null; then \
495
509
            update-initramfs -k all -u; \
496
510
        elif command -v dracut >/dev/null; then \
497
 
            for initrd in $(DESTDIR)/boot/initr*-$(shell uname --kernel-release); do \
 
511
            for initrd in $(DESTDIR)/boot/initr*-$(LINUXVERSION); do \
498
512
                if [ -w "$$initrd" ]; then \
499
513
                    chmod go-r "$$initrd"; \
500
514
                    dracut --force "$$initrd"; \
553
567
        if command -v update-initramfs >/dev/null; then \
554
568
            update-initramfs -k all -u; \
555
569
        elif command -v dracut >/dev/null; then \
556
 
            for initrd in $(DESTDIR)/boot/initr*-$(shell uname --kernel-release); do \
 
570
            for initrd in $(DESTDIR)/boot/initr*-$(LINUXVERSION); do \
557
571
                test -w "$$initrd" && dracut --force "$$initrd"; \
558
572
            done; \
559
573
        fi