/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: 2015-07-20 00:18:59 UTC
  • Revision ID: teddy@recompile.se-20150720001859-4373dkxokj7bt666
plugin-runner: Minor fix: close helperdir before exiting in fork.

* plugin-runner.c: Minor fix: close helperdir before exiting in fork
                   if helper program could not be opened.

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-2016 Teddy Hogeborn
13
 
 * Copyright © 2008-2016 Björn Påhlsson
 
12
 * Copyright © 2008-2015 Teddy Hogeborn
 
13
 * Copyright © 2008-2015 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
47
47
                                   strtof(), abort() */
48
48
#include <stdbool.h>            /* bool, false, true */
49
49
#include <string.h>             /* strcmp(), strlen(), strerror(),
50
 
                                   asprintf(), strncpy() */
 
50
                                   asprintf(), strcpy() */
51
51
#include <sys/ioctl.h>          /* ioctl */
52
52
#include <sys/types.h>          /* socket(), inet_pton(), sockaddr,
53
53
                                   sockaddr_in6, PF_INET6,
513
513
  fprintf_plus(stderr, "GnuTLS: %s", string);
514
514
}
515
515
 
516
 
__attribute__((nonnull(1, 2, 4), warn_unused_result))
 
516
__attribute__((nonnull, warn_unused_result))
517
517
static int init_gnutls_global(const char *pubkeyfilename,
518
518
                              const char *seckeyfilename,
519
519
                              const char *dhparamsfilename,
1223
1223
                    sizeof(struct sockaddr_in));
1224
1224
    }
1225
1225
    if(ret < 0){
1226
 
      if(((errno == ENETUNREACH) or (errno == EHOSTUNREACH))
 
1226
      if(errno == ENETUNREACH
1227
1227
         and if_index != AVAHI_IF_UNSPEC
1228
1228
         and connect_to == NULL
1229
1229
         and not route_added and
1637
1637
    errno = ret_errno;
1638
1638
    return false;
1639
1639
  }
1640
 
  strncpy(ifr->ifr_name, ifname, IF_NAMESIZE);
1641
 
  ifr->ifr_name[IF_NAMESIZE-1] = '\0'; /* NUL terminate */
 
1640
  strcpy(ifr->ifr_name, ifname);
1642
1641
  ret = ioctl(s, SIOCGIFFLAGS, ifr);
1643
1642
  if(ret == -1){
1644
1643
    if(debug){
1914
1913
      return;
1915
1914
    }
1916
1915
  }
 
1916
#ifdef __GLIBC__
 
1917
#if __GLIBC_PREREQ(2, 15)
1917
1918
  int numhooks = scandirat(hookdir_fd, ".", &direntries,
1918
1919
                           runnable_hook, alphasort);
 
1920
#else  /* not __GLIBC_PREREQ(2, 15) */
 
1921
  int numhooks = scandir(hookdir, &direntries, runnable_hook,
 
1922
                         alphasort);
 
1923
#endif  /* not __GLIBC_PREREQ(2, 15) */
 
1924
#else   /* not __GLIBC__ */
 
1925
  int numhooks = scandir(hookdir, &direntries, runnable_hook,
 
1926
                         alphasort);
 
1927
#endif  /* not __GLIBC__ */
1919
1928
  if(numhooks == -1){
1920
1929
    perror_plus("scandir");
1921
1930
    return;
2279
2288
 
2280
2289
int main(int argc, char *argv[]){
2281
2290
  mandos_context mc = { .server = NULL, .dh_bits = 0,
2282
 
                        .priority = "SECURE256:!CTYPE-X.509"
2283
 
                        ":+CTYPE-OPENPGP:!RSA:+SIGN-DSA-SHA256",
2284
 
                        .current_server = NULL, .interfaces = NULL,
2285
 
                        .interfaces_size = 0 };
 
2291
                        .priority = "SECURE256:!CTYPE-X.509:"
 
2292
                        "+CTYPE-OPENPGP:!RSA", .current_server = NULL,
 
2293
                        .interfaces = NULL, .interfaces_size = 0 };
2286
2294
  AvahiSServiceBrowser *sb = NULL;
2287
2295
  error_t ret_errno;
2288
2296
  int ret;
2540
2548
        }
2541
2549
      }
2542
2550
      
2543
 
      if(dh_params_file != NULL
2544
 
         and strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
 
2551
      if(strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
2545
2552
        int dhparams_fd = open(dh_params_file, O_RDONLY);
2546
2553
        if(dhparams_fd == -1){
2547
2554
          perror_plus("open");
3044
3051
    if(tempdir_fd == -1){
3045
3052
      perror_plus("open");
3046
3053
    } else {
 
3054
#ifdef __GLIBC__
 
3055
#if __GLIBC_PREREQ(2, 15)
3047
3056
      int numentries = scandirat(tempdir_fd, ".", &direntries,
3048
3057
                                 notdotentries, alphasort);
 
3058
#else  /* not __GLIBC_PREREQ(2, 15) */
 
3059
      int numentries = scandir(tempdir, &direntries, notdotentries,
 
3060
                               alphasort);
 
3061
#endif  /* not __GLIBC_PREREQ(2, 15) */
 
3062
#else   /* not __GLIBC__ */
 
3063
      int numentries = scandir(tempdir, &direntries, notdotentries,
 
3064
                               alphasort);
 
3065
#endif  /* not __GLIBC__ */
3049
3066
      if(numentries >= 0){
3050
3067
        for(int i = 0; i < numentries; i++){
3051
3068
          ret = unlinkat(tempdir_fd, direntries[i]->d_name, 0);