/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-16 23:01:02 UTC
  • Revision ID: teddy@recompile.se-20150716230102-62u5uwaguiufc6ac
mandos-client: Don't use memset().

* plugins.d/mandos-client.c (start_mandos_communication): Use compound
                                                          literal
                                                          struct
                                                          assignment
                                                          instead of
                                                          memset().

Show diffs side-by-side

added added

removed removed

Lines of Context:
305
305
      return false;
306
306
    }
307
307
    
308
 
    ret = close(fd);
 
308
    ret = (int)TEMP_FAILURE_RETRY(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 = close(devnull);
 
934
    ret = (int)TEMP_FAILURE_RETRY(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);
958
957
      _exit(EX_UNAVAILABLE);
959
958
    }
960
 
    close(helperdir_fd);
 
959
    TEMP_FAILURE_RETRY(close(helperdir_fd));
961
960
#ifdef __GNUC__
962
961
#pragma GCC diagnostic push
963
962
#pragma GCC diagnostic ignored "-Wcast-qual"
1467
1466
    free(decrypted_buffer);
1468
1467
    free(buffer);
1469
1468
    if(tcp_sd >= 0){
1470
 
      ret = close(tcp_sd);
 
1469
      ret = (int)TEMP_FAILURE_RETRY(close(tcp_sd));
1471
1470
    }
1472
1471
    if(ret == -1){
1473
1472
      if(e == 0){
2012
2011
        perror_plus("openat");
2013
2012
        _exit(EXIT_FAILURE);
2014
2013
      }
2015
 
      if(close(hookdir_fd) == -1){
 
2014
      if((int)TEMP_FAILURE_RETRY(close(hookdir_fd)) == -1){
2016
2015
        perror_plus("close");
2017
2016
        _exit(EXIT_FAILURE);
2018
2017
      }
2021
2020
        perror_plus("dup2(devnull, STDIN_FILENO)");
2022
2021
        _exit(EX_OSERR);
2023
2022
      }
2024
 
      ret = close(devnull);
 
2023
      ret = (int)TEMP_FAILURE_RETRY(close(devnull));
2025
2024
      if(ret == -1){
2026
2025
        perror_plus("close");
2027
2026
        _exit(EX_OSERR);
2076
2075
    free(direntry);
2077
2076
  }
2078
2077
  free(direntries);
2079
 
  if(close(hookdir_fd) == -1){
 
2078
  if((int)TEMP_FAILURE_RETRY(close(hookdir_fd)) == -1){
2080
2079
    perror_plus("close");
2081
2080
  } else {
2082
2081
    hookdir_fd = -1;
2122
2121
    }
2123
2122
    
2124
2123
    if(quit_now){
2125
 
      ret = close(sd);
 
2124
      ret = (int)TEMP_FAILURE_RETRY(close(sd));
2126
2125
      if(ret == -1){
2127
2126
        perror_plus("close");
2128
2127
      }
2178
2177
    }
2179
2178
    
2180
2179
    /* Close the socket */
2181
 
    ret = close(sd);
 
2180
    ret = (int)TEMP_FAILURE_RETRY(close(sd));
2182
2181
    if(ret == -1){
2183
2182
      perror_plus("close");
2184
2183
    }
2266
2265
    }
2267
2266
    
2268
2267
    /* Close the socket */
2269
 
    int ret = close(sd);
 
2268
    int ret = (int)TEMP_FAILURE_RETRY(close(sd));
2270
2269
    if(ret == -1){
2271
2270
      perror_plus("close");
2272
2271
    }
2288
2287
 
2289
2288
int main(int argc, char *argv[]){
2290
2289
  mandos_context mc = { .server = NULL, .dh_bits = 0,
2291
 
                        .priority = "SECURE256:!CTYPE-X.509"
2292
 
                        ":+CTYPE-OPENPGP:!RSA:+SIGN-DSA-SHA256",
2293
 
                        .current_server = NULL, .interfaces = NULL,
2294
 
                        .interfaces_size = 0 };
 
2290
                        .priority = "SECURE256:!CTYPE-X.509:"
 
2291
                        "+CTYPE-OPENPGP:!RSA", .current_server = NULL,
 
2292
                        .interfaces = NULL, .interfaces_size = 0 };
2295
2293
  AvahiSServiceBrowser *sb = NULL;
2296
2294
  error_t ret_errno;
2297
2295
  int ret;
2524
2522
              }
2525
2523
            }
2526
2524
          }
2527
 
          close(seckey_fd);
 
2525
          TEMP_FAILURE_RETRY(close(seckey_fd));
2528
2526
        }
2529
2527
      }
2530
2528
      
2545
2543
              }
2546
2544
            }
2547
2545
          }
2548
 
          close(pubkey_fd);
 
2546
          TEMP_FAILURE_RETRY(close(pubkey_fd));
2549
2547
        }
2550
2548
      }
2551
2549
      
2552
 
      if(dh_params_file != NULL
2553
 
         and strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
 
2550
      if(strcmp(dh_params_file, PATHDIR "/dhparams.pem" ) == 0){
2554
2551
        int dhparams_fd = open(dh_params_file, O_RDONLY);
2555
2552
        if(dhparams_fd == -1){
2556
2553
          perror_plus("open");
2567
2564
              }
2568
2565
            }
2569
2566
          }
2570
 
          close(dhparams_fd);
 
2567
          TEMP_FAILURE_RETRY(close(dhparams_fd));
2571
2568
        }
2572
2569
      }
2573
2570
      
3086
3083
          perror_plus("rmdir");
3087
3084
        }
3088
3085
      }
3089
 
      close(tempdir_fd);
 
3086
      TEMP_FAILURE_RETRY(close(tempdir_fd));
3090
3087
    }
3091
3088
  }
3092
3089