/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: 2011-03-08 19:41:59 UTC
  • mto: (237.4.29 release)
  • mto: This revision was merged to the branch mainline in revision 473.
  • Revision ID: teddy@fukt.bsnet.se-20110308194159-h0p66a3rabn8cjkb
Tags: version-1.3.0-1
* Makefile (version): Changed to "1.3.0".
* NEWS (Version 1.3.0): New entry.
* debian/changelog (1.3.0-1): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
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, inet_ntop() */
 
76
#include <arpa/inet.h>          /* inet_pton(), htons */
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
 
  ret = gnutls_certificate_allocate_credentials(&mc.cred);
 
426
  gnutls_certificate_allocate_credentials(&mc.cred);
427
427
  if(ret != GNUTLS_E_SUCCESS){
428
 
    fprintf(stderr, "GnuTLS memory error: %s\n",
 
428
    fprintf(stderr, "GnuTLS memory error: %s\n", /* Spurious warning
 
429
                                                    from
 
430
                                                    -Wunreachable-code
 
431
                                                 */
429
432
            safer_gnutls_strerror(ret));
430
433
    gnutls_global_deinit();
431
434
    return -1;
1029
1032
int good_interface(const struct dirent *if_entry){
1030
1033
  ssize_t ssret;
1031
1034
  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
  }
1041
1044
  int flags_fd = (int)TEMP_FAILURE_RETRY(open(flagname, O_RDONLY));
1042
1045
  if(flags_fd == -1){
1043
1046
    perror("open");
1044
 
    free(flagname);
1045
1047
    return 0;
1046
1048
  }
1047
 
  free(flagname);
1048
1049
  typedef short ifreq_flags;    /* ifreq.ifr_flags in netdevice(7) */
1049
1050
  /* read line from flags_fd */
1050
 
  ssize_t to_read = 2+(sizeof(ifreq_flags)*2)+1; /* "0x1003\n" */
 
1051
  ssize_t to_read = (sizeof(ifreq_flags)*2)+3; /* "0x1003\n" */
1051
1052
  char *flagstring = malloc((size_t)to_read+1); /* +1 for final \0 */
1052
1053
  flagstring[(size_t)to_read] = '\0';
1053
1054
  if(flagstring == NULL){
1110
1111
    }
1111
1112
    return 0;
1112
1113
  }
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
 
  }
1121
1114
  /* Accept this device */
1122
1115
  if(debug){
1123
1116
    fprintf(stderr, "Interface \"%s\" is acceptable\n",