/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/mandos-client.c

First version of a somewhat complete D-Bus server interface.  Also
change user/group name to "_mandos".

* debian/mandos.postinst: Rename old "mandos" user and group to
                          "_mandos"; create "_mandos" user and group
                          if none exist.
* debian/mandos-client.postinst: - '' -

* initramfs-tools-hook: Try "_mandos" before "mandos" as user and
                        group name.

* mandos (_datetime_to_dbus_struct): New; was previously local.
  (Client.started): Renamed to "last_started".  All users changed.
  (Client.started): New; boolean.
  (Client.dbus_object_path): New.
  (Client.check_command): Renamed to "checker_command".  All users
                          changed.
  (Client.__init__): Set and use "self.dbus_object_path".  Set
                     "self.started".
  (Client.start): Update "self.started".  Emit "self.PropertyChanged"
                  signals for both "started" and "last_started".
  (Client.stop): Update "self.started".  Emit "self.PropertyChanged"
                 signal for "started".
  (Client.checker_callback): Take additional "command" argument.  All
                             callers changed. Emit
                             "self.PropertyChanged" signal.
  (Client.bump_timeout): Emit "self.PropertyChanged" signal for
                         "last_checked_ok".
  (Client.start_checker): Emit "self.PropertyChanged" signal for
                          "checker_running".
  (Client.stop_checker): Emit "self.PropertyChanged" signal for
                         "checker_running".
  (Client.still_valid): Bug fix: use "getattr(self, started, False)"
                        instead of "self.started" in case this client
                        object is so new that the "started" attribute
                        has not been created yet.
  (Client.IntervalChanged, Client.CheckerIsRunning, Client.GetChecker,
  Client.GetCreated, Client.GetFingerprint, Client.GetHost,
  Client.GetInterval, Client.GetName, Client.GetStarted,
  Client.GetTimeout, Client.StateChanged, Client.TimeoutChanged):
  Removed; all callers changed.
  (Client.CheckerCompleted): Add "condition" and "command" arguments.
                             All callers changed.
  (Client.GetAllProperties, Client.PropertyChanged): New.
  (Client.StillValid): Renamed to "IsStillValid".
  (Client.StartChecker): Changed to its own function to avoid the
                         return value from "Client.start_checker()".
  (Client.Stop): Changed to its own function to avoid the return value
                 from "Client.stop()".
  (main): Try "_mandos" before "mandos" as user and group name.
          Removed inner function "remove_from_clients".  New inner
          class "MandosServer".

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 * "browse_callback", and parts of "main".
10
10
 * 
11
11
 * Everything else is
12
 
 * Copyright © 2008,2009 Teddy Hogeborn
13
 
 * Copyright © 2008,2009 Björn Påhlsson
 
12
 * Copyright © 2008 Teddy Hogeborn
 
13
 * Copyright © 2008 Björn Påhlsson
14
14
 * 
15
15
 * This program is free software: you can redistribute it and/or
16
16
 * modify it under the terms of the GNU General Public License as
156
156
    int fd;
157
157
    gpgme_data_t pgp_data;
158
158
    
159
 
    fd = (int)TEMP_FAILURE_RETRY(open(filename, O_RDONLY));
 
159
    fd = TEMP_FAILURE_RETRY(open(filename, O_RDONLY));
160
160
    if(fd == -1){
161
161
      perror("open");
162
162
      return false;
176
176
      return false;
177
177
    }
178
178
    
179
 
    ret = (int)TEMP_FAILURE_RETRY(close(fd));
 
179
    ret = TEMP_FAILURE_RETRY(close(fd));
180
180
    if(ret == -1){
181
181
      perror("close");
182
182
    }
501
501
                                      AvahiIfIndex if_index,
502
502
                                      mandos_context *mc){
503
503
  int ret, tcp_sd;
504
 
  ssize_t sret;
505
504
  union { struct sockaddr in; struct sockaddr_in6 in6; } to;
506
505
  char *buffer = NULL;
507
506
  char *decrypted_buffer;
578
577
  written = 0;
579
578
  while (true){
580
579
    size_t out_size = strlen(out);
581
 
    ret = (int)TEMP_FAILURE_RETRY(write(tcp_sd, out + written,
 
580
    ret = TEMP_FAILURE_RETRY(write(tcp_sd, out + written,
582
581
                                   out_size - written));
583
582
    if (ret == -1){
584
583
      perror("write");
633
632
      goto mandos_end;
634
633
    }
635
634
    
636
 
    sret = gnutls_record_recv(session, buffer+buffer_length,
637
 
                              BUFFER_SIZE);
638
 
    if (sret == 0){
 
635
    ret = gnutls_record_recv(session, buffer+buffer_length,
 
636
                             BUFFER_SIZE);
 
637
    if (ret == 0){
639
638
      break;
640
639
    }
641
 
    if (sret < 0){
642
 
      switch(sret){
 
640
    if (ret < 0){
 
641
      switch(ret){
643
642
      case GNUTLS_E_INTERRUPTED:
644
643
      case GNUTLS_E_AGAIN:
645
644
        break;
662
661
        goto mandos_end;
663
662
      }
664
663
    } else {
665
 
      buffer_length += (size_t) sret;
 
664
      buffer_length += (size_t) ret;
666
665
    }
667
666
  }
668
667
  
704
703
  
705
704
 mandos_end:
706
705
  free(buffer);
707
 
  ret = (int)TEMP_FAILURE_RETRY(close(tcp_sd));
 
706
  ret = TEMP_FAILURE_RETRY(close(tcp_sd));
708
707
  if(ret == -1){
709
708
    perror("close");
710
709
  }
941
940
          goto end;
942
941
        }
943
942
      }
944
 
      ret = (int)TEMP_FAILURE_RETRY(close(sd));
 
943
      ret = TEMP_FAILURE_RETRY(close(sd));
945
944
      if(ret == -1){
946
945
        perror("close");
947
946
      }