/mandos/trunk

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

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2008-12-29 02:44:54 UTC
  • Revision ID: teddy@fukt.bsnet.se-20081229024454-nbsei556dwy5azr1
* mandos (Client.timeout, Client.interval): Changed from being a
                                            property to be a normal
                                            attribute.
  (Client._timeout, Client._interval): Removed.
  (Client._timeout_milliseconds): Changed from being an attribute to
                                  be a method "timeout_milliseconds".
                                  All users changed.
  (Client._interval_milliseconds): Changed from being an attribute to
                                   be method "interval_milliseconds".
                                   All users changed.
  (Client.__init__): Take additional "use_dbus" keyword argument.
                     Only provide D-Bus interface if "use_dbus" is
                     True.
  (Client.use_dbus): New attribute.
  (Client.dbus_object_path): Changed to only be set if "self.use_dbus"
                             is True.
  (Client.enable, Client.disable, Client.checker_callback,
  Client.bump_timeout, Client.start_checker, Client.stop_checker):
  Only emit D-Bus signals if "self.use_dbus".
  (Client.SetChecker, Client.SetHost, Client.Enable): Bug fix: Emit
                                                      D-Bus signals.
  (Client.SetInterval, Client.SetTimeout): Changed to emit D-Bus
                                           signals.

  (main): Remove deprecated "default" keyword argument to "--check"
          option.  Added new "--no-dbus" option.  Added corresponding
          "use_dbus" server configuration option.  Only provide D-Bus
          interface and emit D-Bus signals if "use_dbus".  Pass
          "use_dbus" on to Client constructor.

* mandos-options.xml ([@id="dbus"]): New option.

* mandos.conf (use_dbus): New option.

* mandos.conf.xml (OPTIONS): New option "use_dbus".
  (EXAMPLE): - '' -

* mandos.xml (SYNOPSIS): New option "--no-dbus".
  (D-BUS INTERFACE): New section.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  -*- coding: utf-8 -*- */
2
2
/*
3
 
 * Mandos-client - get and decrypt data from a Mandos server
 
3
 * Mandos client - get and decrypt data from a Mandos server
4
4
 *
5
5
 * This program is partly derived from an example program for an Avahi
6
6
 * service browser, downloaded from
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
      }