/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

  • Committer: Teddy Hogeborn
  • Date: 2016-02-28 15:11:35 UTC
  • Revision ID: teddy@recompile.se-20160228151135-2c001gcl4cgtbbwt
Tags: version-1.7.2-1
* Makefile (version): Changed to "1.7.2".
* NEWS (Version 1.7.2): New entry.
* debian/changelog (1.7.2-1): - '' -
* debian/control (Package: mandos/Depends): Remove duplicate
  "python-dbus".

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-2015 Teddy Hogeborn
13
 
 * Copyright © 2008-2015 Björn Påhlsson
 
12
 * Copyright © 2008-2016 Teddy Hogeborn
 
13
 * Copyright © 2008-2016 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(), strcpy() */
 
50
                                   asprintf(), strncpy() */
51
51
#include <sys/ioctl.h>          /* ioctl */
52
52
#include <sys/types.h>          /* socket(), inet_pton(), sockaddr,
53
53
                                   sockaddr_in6, PF_INET6,
305
305
      return false;
306
306
    }
307
307
    
308
 
    ret = (int)TEMP_FAILURE_RETRY(close(fd));
 
308
    ret = close(fd);
309
309
    if(ret == -1){
310
310
      perror_plus("close");
311
311
    }
931
931
      perror_plus("dup2(devnull, STDIN_FILENO)");
932
932
      _exit(EX_OSERR);
933
933
    }
934
 
    ret = (int)TEMP_FAILURE_RETRY(close(devnull));
 
934
    ret = close(devnull);
935
935
    if(ret == -1){
936
936
      perror_plus("close");
937
937
      _exit(EX_OSERR);
954
954
                                                   helper, O_RDONLY));
955
955
    if(helper_fd == -1){
956
956
      perror_plus("openat");
 
957
      close(helperdir_fd);
957
958
      _exit(EX_UNAVAILABLE);
958
959
    }
959
 
    TEMP_FAILURE_RETRY(close(helperdir_fd));
 
960
    close(helperdir_fd);
960
961
#ifdef __GNUC__
961
962
#pragma GCC diagnostic push
962
963
#pragma GCC diagnostic ignored "-Wcast-qual"
1222
1223
                    sizeof(struct sockaddr_in));
1223
1224
    }
1224
1225
    if(ret < 0){
1225
 
      if(errno == ENETUNREACH
 
1226
      if(((errno == ENETUNREACH) or (errno == EHOSTUNREACH))
1226
1227
         and if_index != AVAHI_IF_UNSPEC
1227
1228
         and connect_to == NULL
1228
1229
         and not route_added and
1466
1467
    free(decrypted_buffer);
1467
1468
    free(buffer);
1468
1469
    if(tcp_sd >= 0){
1469
 
      ret = (int)TEMP_FAILURE_RETRY(close(tcp_sd));
 
1470
      ret = close(tcp_sd);
1470
1471
    }
1471
1472
    if(ret == -1){
1472
1473
      if(e == 0){
1636
1637
    errno = ret_errno;
1637
1638
    return false;
1638
1639
  }
1639
 
  strcpy(ifr->ifr_name, ifname);
 
1640
  strncpy(ifr->ifr_name, ifname, IF_NAMESIZE);
 
1641
  ifr->ifr_name[IF_NAMESIZE-1] = '\0'; /* NUL terminate */
1640
1642
  ret = ioctl(s, SIOCGIFFLAGS, ifr);
1641
1643
  if(ret == -1){
1642
1644
    if(debug){
2011
2013
        perror_plus("openat");
2012
2014
        _exit(EXIT_FAILURE);
2013
2015
      }
2014
 
      if((int)TEMP_FAILURE_RETRY(close(hookdir_fd)) == -1){
 
2016
      if(close(hookdir_fd) == -1){
2015
2017
        perror_plus("close");
2016
2018
        _exit(EXIT_FAILURE);
2017
2019
      }
2020
2022
        perror_plus("dup2(devnull, STDIN_FILENO)");
2021
2023
        _exit(EX_OSERR);
2022
2024
      }
2023
 
      ret = (int)TEMP_FAILURE_RETRY(close(devnull));
 
2025
      ret = close(devnull);
2024
2026
      if(ret == -1){
2025
2027
        perror_plus("close");
2026
2028
        _exit(EX_OSERR);
2075
2077
    free(direntry);
2076
2078
  }
2077
2079
  free(direntries);
2078
 
  if((int)TEMP_FAILURE_RETRY(close(hookdir_fd)) == -1){
 
2080
  if(close(hookdir_fd) == -1){
2079
2081
    perror_plus("close");
2080
2082
  } else {
2081
2083
    hookdir_fd = -1;
2121
2123
    }
2122
2124
    
2123
2125
    if(quit_now){
2124
 
      ret = (int)TEMP_FAILURE_RETRY(close(sd));
 
2126
      ret = close(sd);
2125
2127
      if(ret == -1){
2126
2128
        perror_plus("close");
2127
2129
      }
2177
2179
    }
2178
2180
    
2179
2181
    /* Close the socket */
2180
 
    ret = (int)TEMP_FAILURE_RETRY(close(sd));
 
2182
    ret = close(sd);
2181
2183
    if(ret == -1){
2182
2184
      perror_plus("close");
2183
2185
    }
2265
2267
    }
2266
2268
    
2267
2269
    /* Close the socket */
2268
 
    int ret = (int)TEMP_FAILURE_RETRY(close(sd));
 
2270
    int ret = close(sd);
2269
2271
    if(ret == -1){
2270
2272
      perror_plus("close");
2271
2273
    }
2287
2289
 
2288
2290
int main(int argc, char *argv[]){
2289
2291
  mandos_context mc = { .server = NULL, .dh_bits = 0,
2290
 
                        .priority = "SECURE256:!CTYPE-X.509:"
2291
 
                        "+CTYPE-OPENPGP:!RSA", .current_server = NULL,
2292
 
                        .interfaces = NULL, .interfaces_size = 0 };
 
2292
                        .priority = "SECURE256:!CTYPE-X.509"
 
2293
                        ":+CTYPE-OPENPGP:!RSA:+SIGN-DSA-SHA256",
 
2294
                        .current_server = NULL, .interfaces = NULL,
 
2295
                        .interfaces_size = 0 };
2293
2296
  AvahiSServiceBrowser *sb = NULL;
2294
2297
  error_t ret_errno;
2295
2298
  int ret;
2522
2525
              }
2523
2526
            }
2524
2527
          }
2525
 
          TEMP_FAILURE_RETRY(close(seckey_fd));
 
2528
          close(seckey_fd);
2526
2529
        }
2527
2530
      }
2528
2531
      
2543
2546
              }
2544
2547
            }
2545
2548
          }
2546
 
          TEMP_FAILURE_RETRY(close(pubkey_fd));
 
2549
          close(pubkey_fd);
2547
2550
        }
2548
2551
      }
2549
2552
      
2550
 
      if(strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
 
2553
      if(dh_params_file != NULL
 
2554
         and strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
2551
2555
        int dhparams_fd = open(dh_params_file, O_RDONLY);
2552
2556
        if(dhparams_fd == -1){
2553
2557
          perror_plus("open");
2564
2568
              }
2565
2569
            }
2566
2570
          }
2567
 
          TEMP_FAILURE_RETRY(close(dhparams_fd));
 
2571
          close(dhparams_fd);
2568
2572
        }
2569
2573
      }
2570
2574
      
3083
3087
          perror_plus("rmdir");
3084
3088
        }
3085
3089
      }
3086
 
      TEMP_FAILURE_RETRY(close(tempdir_fd));
 
3090
      close(tempdir_fd);
3087
3091
    }
3088
3092
  }
3089
3093