/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: 2015-08-10 09:00:23 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 325.
  • Revision ID: teddy@recompile.se-20150810090023-fz6vjqr7zf33e2tf
Support the standard org.freedesktop.DBus.ObjectManager interface.

Now that the D-Bus standard has an interface to keep track of new and
removed objects, use that instead of our own methods.  This deprecates
our D-Bus methods "GetAllClients" and "GetAllClientsWithProperties"
and the signals "ClientAdded" and "ClientRemoved", all on the server
interface "se.recompile.Mandos".

* DBUS-API: Removed references to deprecated methods and signals;
  insert reference to the org.freedesktop.DBus.ObjectManager
  interface.
* mandos (DBusObjectWithProperties._get_all_interface_names): New.
  (dbus.OBJECT_MANAGER_IFACE): If not present, monkey patch.
  (DBusObjectWithObjectManager): New.
  (main/MandosDBusService): Inherit from DBusObjectWithObjectManager.
  (main/MandosDBusService.ClientRemoved): Annotate as deprecated.
  (main/MandosDBusService.GetAllClients): - '' -
  (main/MandosDBusService.GetAllClientsWithProperties): Annotate as
                                                        deprecated.
                                                        Also only
                                                        return
                                                        properties on
                                                        client
                                                        interface.
  (main/MandosDBusService.RemoveClient): Call client_removed_signal
                                         instead of ClientRemoved.
  (main/MandosDBusService.GetManagedObjects): New.
  (main/MandosDBusService.client_added_signal): New.
  (main/MandosDBusService.client_removed_signal): - '' -
  (main/cleanup): Call "client_removed_signal" instead of sending
                  "ClientRemoved" signal directly.
  (main): Call "client_added_signal" instead of sending "ClientAdded"
          signal directly.
* mandos-ctl: Use GetManagedObjects instead of
              GetAllClientsWithProperties.  Also, show better error
              message in case of failure to connect to the D-Bus

* mandos-monitor (MandosClientPropertyCache.properties_changed):
  Bug fix; only update properties on client interface.
  (UserInterface.find_and_remove_client): Change to accept arguments
                                          from InterfacesRemoved
                                          signal.  Also, bug fix:
                                          working error message when
                                          removing unknown client.
  (UserInterface.add_new_client): Change to accept arguments from
                                  InterfacesRemoved signal.  Pass
                                  properties to MandosClientWidget
                                  constructor.
  (UserInterface.run): Connect find_and_remove_client method to
                       InterfacesRemoved signal and the add_new_client
                       method to the InterfacesAdded signal.

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
 
5
 * Copyright © 2008-2015 Teddy Hogeborn
 
6
 * Copyright © 2008-2015 Björn Påhlsson
7
7
 * 
8
8
 * This program is free software: you can redistribute it and/or
9
9
 * modify it under the terms of the GNU General Public License as
58
58
const char usplash_name[] = "/sbin/usplash";
59
59
 
60
60
/* Function to use when printing errors */
 
61
__attribute__((format (gnu_printf, 3, 4)))
61
62
void error_plus(int status, int errnum, const char *formatstring,
62
63
                ...){
63
64
  va_list ap;
66
67
  
67
68
  va_start(ap, formatstring);
68
69
  ret = vasprintf(&text, formatstring, ap);
69
 
  if (ret == -1){
 
70
  if(ret == -1){
70
71
    fprintf(stderr, "Mandos plugin %s: ",
71
72
            program_invocation_short_name);
72
73
    vfprintf(stderr, formatstring, ap);
116
117
      ret = asprintf(&cmd_line_alloc, "%s %s", cmd, arg);
117
118
      if(ret == -1){
118
119
        int e = errno;
119
 
        TEMP_FAILURE_RETRY(close(*fifo_fd_r));
 
120
        close(*fifo_fd_r);
120
121
        errno = e;
121
122
        return false;
122
123
      }
132
133
                 cmd_line_len - written);
133
134
    if(sret == -1){
134
135
      int e = errno;
135
 
      TEMP_FAILURE_RETRY(close(*fifo_fd_r));
 
136
      close(*fifo_fd_r);
136
137
      free(cmd_line_alloc);
137
138
      errno = e;
138
139
      return false;
490
491
        error_plus(0, errno, "read");
491
492
        status = EX_OSERR;
492
493
      }
493
 
      TEMP_FAILURE_RETRY(close(outfifo_fd));
 
494
      close(outfifo_fd);
494
495
      goto failure;
495
496
    }
496
497
    if(interrupted_by_signal){
577
578
  
578
579
  /* Close FIFO */
579
580
  if(fifo_fd != -1){
580
 
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
 
581
    ret = close(fifo_fd);
581
582
    if(ret == -1 and errno != EINTR){
582
583
      error_plus(0, errno, "close");
583
584
    }
586
587
  
587
588
  /* Close output FIFO */
588
589
  if(outfifo_fd != -1){
589
 
    ret = (int)TEMP_FAILURE_RETRY(close(outfifo_fd));
 
590
    ret = close(outfifo_fd);
590
591
    if(ret == -1){
591
592
      error_plus(0, errno, "close");
592
593
    }
654
655
  
655
656
  /* Close FIFO (again) */
656
657
  if(fifo_fd != -1){
657
 
    ret = (int)TEMP_FAILURE_RETRY(close(fifo_fd));
 
658
    ret = close(fifo_fd);
658
659
    if(ret == -1 and errno != EINTR){
659
660
      error_plus(0, errno, "close");
660
661
    }