/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

* Makefile (plugins.d/mandos-client): Bug fix: Put $^ before all
                                      libraries.  Remove "$(COMMON)".
                                      Thanks to Angel Abad
                                      <angelabad@ubuntu.com>.
* initramfs-tools-script: Work around change in initramfs-tools,
                          Debian bug #633582.
* plugins.d/mandos-client.c (init_gnutls_global): Bug fix: check for
                errors from gnutls_certificate_allocate_credentials().

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-2011 Teddy Hogeborn
 
13
 * Copyright © 2008-2011 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
73
73
#include <unistd.h>             /* close(), SEEK_SET, off_t, write(),
74
74
                                   getuid(), getgid(), seteuid(),
75
75
                                   setgid(), pause() */
76
 
#include <arpa/inet.h>          /* inet_pton(), htons */
 
76
#include <arpa/inet.h>          /* inet_pton(), htons, inet_ntop() */
77
77
#include <iso646.h>             /* not, or, and */
78
78
#include <argp.h>               /* struct argp_option, error_t, struct
79
79
                                   argp_state, struct argp,
423
423
  }
424
424
  
425
425
  /* OpenPGP credentials */
426
 
  gnutls_certificate_allocate_credentials(&mc.cred);
 
426
  ret = gnutls_certificate_allocate_credentials(&mc.cred);
427
427
  if(ret != GNUTLS_E_SUCCESS){
428
 
    fprintf(stderr, "GnuTLS memory error: %s\n", /* Spurious warning
429
 
                                                    from
430
 
                                                    -Wunreachable-code
431
 
                                                 */
 
428
    fprintf(stderr, "GnuTLS memory error: %s\n",
432
429
            safer_gnutls_strerror(ret));
433
430
    gnutls_global_deinit();
434
431
    return -1;
1032
1029
int good_interface(const struct dirent *if_entry){
1033
1030
  ssize_t ssret;
1034
1031
  char *flagname = NULL;
 
1032
  if(if_entry->d_name[0] == '.'){
 
1033
    return 0;
 
1034
  }
1035
1035
  int ret = asprintf(&flagname, "%s/%s/flags", sys_class_net,
1036
1036
                     if_entry->d_name);
1037
1037
  if(ret < 0){
1038
1038
    perror("asprintf");
1039
1039
    return 0;
1040
1040
  }
1041
 
  if(if_entry->d_name[0] == '.'){
1042
 
    return 0;
1043
 
  }
1044
1041
  int flags_fd = (int)TEMP_FAILURE_RETRY(open(flagname, O_RDONLY));
1045
1042
  if(flags_fd == -1){
1046
1043
    perror("open");
 
1044
    free(flagname);
1047
1045
    return 0;
1048
1046
  }
 
1047
  free(flagname);
1049
1048
  typedef short ifreq_flags;    /* ifreq.ifr_flags in netdevice(7) */
1050
1049
  /* read line from flags_fd */
1051
 
  ssize_t to_read = (sizeof(ifreq_flags)*2)+3; /* "0x1003\n" */
 
1050
  ssize_t to_read = 2+(sizeof(ifreq_flags)*2)+1; /* "0x1003\n" */
1052
1051
  char *flagstring = malloc((size_t)to_read+1); /* +1 for final \0 */
1053
1052
  flagstring[(size_t)to_read] = '\0';
1054
1053
  if(flagstring == NULL){
1111
1110
    }
1112
1111
    return 0;
1113
1112
  }
 
1113
  /* Reject non-ARP interfaces (including dummy interfaces) */
 
1114
  if(flags & IFF_NOARP){
 
1115
    if(debug){
 
1116
      fprintf(stderr, "Rejecting non-ARP interface \"%s\"\n",
 
1117
              if_entry->d_name);
 
1118
    }
 
1119
    return 0;
 
1120
  }
1114
1121
  /* Accept this device */
1115
1122
  if(debug){
1116
1123
    fprintf(stderr, "Interface \"%s\" is acceptable\n",