/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 plugins.d/usplash.c

  • 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:
2
2
/*
3
3
 * Usplash - Read a password from usplash and output it
4
4
 * 
5
 
 * Copyright © 2008-2011 Teddy Hogeborn
6
 
 * Copyright © 2008-2011 Björn Påhlsson
7
 
 * 
8
 
 * This program is free software: you can redistribute it and/or
9
 
 * modify it under the terms of the GNU General Public License as
10
 
 * published by the Free Software Foundation, either version 3 of the
11
 
 * License, or (at your option) any later version.
12
 
 * 
13
 
 * This program is distributed in the hope that it will be useful, but
 
5
 * Copyright © 2008-2018 Teddy Hogeborn
 
6
 * Copyright © 2008-2018 Björn Påhlsson
 
7
 * 
 
8
 * This file is part of Mandos.
 
9
 * 
 
10
 * Mandos is free software: you can redistribute it and/or modify it
 
11
 * under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation, either version 3 of the License, or
 
13
 * (at your option) any later version.
 
14
 * 
 
15
 * Mandos is distributed in the hope that it will be useful, but
14
16
 * WITHOUT ANY WARRANTY; without even the implied warranty of
15
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
18
 * General Public License for more details.
17
19
 * 
18
20
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program.  If not, see
20
 
 * <http://www.gnu.org/licenses/>.
 
21
 * along with Mandos.  If not, see <http://www.gnu.org/licenses/>.
21
22
 * 
22
23
 * Contact the authors at <mandos@recompile.se>.
23
24
 */
67
68
  
68
69
  va_start(ap, formatstring);
69
70
  ret = vasprintf(&text, formatstring, ap);
70
 
  if (ret == -1){
 
71
  if(ret == -1){
71
72
    fprintf(stderr, "Mandos plugin %s: ",
72
73
            program_invocation_short_name);
73
74
    vfprintf(stderr, formatstring, ap);
117
118
      ret = asprintf(&cmd_line_alloc, "%s %s", cmd, arg);
118
119
      if(ret == -1){
119
120
        int e = errno;
120
 
        TEMP_FAILURE_RETRY(close(*fifo_fd_r));
 
121
        close(*fifo_fd_r);
121
122
        errno = e;
122
123
        return false;
123
124
      }
133
134
                 cmd_line_len - written);
134
135
    if(sret == -1){
135
136
      int e = errno;
136
 
      TEMP_FAILURE_RETRY(close(*fifo_fd_r));
 
137
      close(*fifo_fd_r);
137
138
      free(cmd_line_alloc);
138
139
      errno = e;
139
140
      return false;
491
492
        error_plus(0, errno, "read");
492
493
        status = EX_OSERR;
493
494
      }
494
 
      TEMP_FAILURE_RETRY(close(outfifo_fd));
 
495
      close(outfifo_fd);
495
496
      goto failure;
496
497
    }
497
498
    if(interrupted_by_signal){
578
579
  
579
580
  /* Close FIFO */
580
581
  if(fifo_fd != -1){
581
 
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
 
582
    ret = close(fifo_fd);
582
583
    if(ret == -1 and errno != EINTR){
583
584
      error_plus(0, errno, "close");
584
585
    }
587
588
  
588
589
  /* Close output FIFO */
589
590
  if(outfifo_fd != -1){
590
 
    ret = (int)TEMP_FAILURE_RETRY(close(outfifo_fd));
 
591
    ret = close(outfifo_fd);
591
592
    if(ret == -1){
592
593
      error_plus(0, errno, "close");
593
594
    }
655
656
  
656
657
  /* Close FIFO (again) */
657
658
  if(fifo_fd != -1){
658
 
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
 
659
    ret = close(fifo_fd);
659
660
    if(ret == -1 and errno != EINTR){
660
661
      error_plus(0, errno, "close");
661
662
    }