/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: 2016-10-09 22:35:41 UTC
  • Revision ID: teddy@recompile.se-20161009223541-2g2xrvfii5m5ibjw
Stop the GnuPG agent after Debian package installation

* debian/mandos-client.postinst (create_key): Stop GPG agent after
                                              running mandos-keygen.

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-2018 Teddy Hogeborn
13
 
 * Copyright © 2008-2018 Björn Påhlsson
14
 
 * 
15
 
 * This file is part of Mandos.
16
 
 * 
17
 
 * Mandos is free software: you can redistribute it and/or modify it
18
 
 * under the terms of the GNU General Public License as published by
19
 
 * the Free Software Foundation, either version 3 of the License, or
20
 
 * (at your option) any later version.
21
 
 * 
22
 
 * Mandos is distributed in the hope that it will be useful, but
 
12
 * Copyright © 2008-2016 Teddy Hogeborn
 
13
 * Copyright © 2008-2016 Björn Påhlsson
 
14
 * 
 
15
 * This program is free software: you can redistribute it and/or
 
16
 * modify it under the terms of the GNU General Public License as
 
17
 * published by the Free Software Foundation, either version 3 of the
 
18
 * License, or (at your option) any later version.
 
19
 * 
 
20
 * This program is distributed in the hope that it will be useful, but
23
21
 * WITHOUT ANY WARRANTY; without even the implied warranty of
24
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25
23
 * General Public License for more details.
26
24
 * 
27
25
 * You should have received a copy of the GNU General Public License
28
 
 * along with Mandos.  If not, see <http://www.gnu.org/licenses/>.
 
26
 * along with this program.  If not, see
 
27
 * <http://www.gnu.org/licenses/>.
29
28
 * 
30
29
 * Contact the authors at <mandos@recompile.se>.
31
30
 */
420
419
      if(result == NULL){
421
420
        fprintf_plus(stderr, "gpgme_op_decrypt_result failed\n");
422
421
      } else {
423
 
        if(result->unsupported_algorithm != NULL) {
424
 
          fprintf_plus(stderr, "Unsupported algorithm: %s\n",
425
 
                       result->unsupported_algorithm);
426
 
        }
 
422
        fprintf_plus(stderr, "Unsupported algorithm: %s\n",
 
423
                     result->unsupported_algorithm);
427
424
        fprintf_plus(stderr, "Wrong key usage: %u\n",
428
425
                     result->wrong_key_usage);
429
426
        if(result->file_name != NULL){
615
612
        }
616
613
        params.size += (unsigned int)bytes_read;
617
614
      }
618
 
      ret = close(dhpfile);
619
 
      if(ret == -1){
620
 
        perror_plus("close");
621
 
      }
622
615
      if(params.data == NULL){
623
616
        dhparamsfilename = NULL;
624
617
      }
1086
1079
    bool match = false;
1087
1080
    {
1088
1081
      char *interface = NULL;
1089
 
      while((interface = argz_next(mc->interfaces,
1090
 
                                   mc->interfaces_size,
1091
 
                                   interface))){
 
1082
      while((interface=argz_next(mc->interfaces, mc->interfaces_size,
 
1083
                                 interface))){
1092
1084
        if(if_nametoindex(interface) == (unsigned int)if_index){
1093
1085
          match = true;
1094
1086
          break;
1501
1493
  return retval;
1502
1494
}
1503
1495
 
 
1496
__attribute__((nonnull))
1504
1497
static void resolve_callback(AvahiSServiceResolver *r,
1505
1498
                             AvahiIfIndex interface,
1506
1499
                             AvahiProtocol proto,
1661
1654
      perror_plus("ioctl SIOCGIFFLAGS");
1662
1655
      errno = old_errno;
1663
1656
    }
1664
 
    if((close(s) == -1) and debug){
1665
 
      old_errno = errno;
1666
 
      perror_plus("close");
1667
 
      errno = old_errno;
1668
 
    }
1669
1657
    return false;
1670
1658
  }
1671
 
  if((close(s) == -1) and debug){
1672
 
    old_errno = errno;
1673
 
    perror_plus("close");
1674
 
    errno = old_errno;
1675
 
  }
1676
1659
  return true;
1677
1660
}
1678
1661
 
1939
1922
      return;
1940
1923
    }
1941
1924
  }
1942
 
  int devnull = (int)TEMP_FAILURE_RETRY(open("/dev/null", O_RDONLY));
1943
 
  if(devnull == -1){
1944
 
    perror_plus("open(\"/dev/null\", O_RDONLY)");
1945
 
    return;
1946
 
  }
1947
1925
  int numhooks = scandirat(hookdir_fd, ".", &direntries,
1948
1926
                           runnable_hook, alphasort);
1949
1927
  if(numhooks == -1){
1950
1928
    perror_plus("scandir");
1951
 
    close(devnull);
1952
1929
    return;
1953
1930
  }
1954
1931
  struct dirent *direntry;
1955
1932
  int ret;
 
1933
  int devnull = (int)TEMP_FAILURE_RETRY(open("/dev/null", O_RDONLY));
 
1934
  if(devnull == -1){
 
1935
    perror_plus("open(\"/dev/null\", O_RDONLY)");
 
1936
    return;
 
1937
  }
1956
1938
  for(int i = 0; i < numhooks; i++){
1957
1939
    direntry = direntries[i];
1958
1940
    if(debug){
2214
2196
  
2215
2197
  /* Sleep checking until interface is running.
2216
2198
     Check every 0.25s, up to total time of delay */
2217
 
  for(int i = 0; i < delay * 4; i++){
 
2199
  for(int i=0; i < delay * 4; i++){
2218
2200
    if(interface_is_running(interface)){
2219
2201
      break;
2220
2202
    }
3041
3023
      /* Take down the network interfaces which were brought up */
3042
3024
      {
3043
3025
        char *interface = NULL;
3044
 
        while((interface = argz_next(interfaces_to_take_down,
3045
 
                                     interfaces_to_take_down_size,
3046
 
                                     interface))){
 
3026
        while((interface=argz_next(interfaces_to_take_down,
 
3027
                                   interfaces_to_take_down_size,
 
3028
                                   interface))){
3047
3029
          ret = take_down_interface(interface);
3048
3030
          if(ret != 0){
3049
3031
            errno = ret;
3078
3060
                                                | O_PATH));
3079
3061
    if(dir_fd == -1){
3080
3062
      perror_plus("open");
3081
 
      return;
3082
3063
    }
3083
3064
    int numentries = scandirat(dir_fd, ".", &direntries,
3084
3065
                               notdotentries, alphasort);
3101
3082
            clean_dir_at(dir_fd, direntries[i]->d_name, level+1);
3102
3083
            dret = 0;
3103
3084
          }
3104
 
          if((dret == -1) and (errno != ENOENT)){
 
3085
          if(dret == -1){
3105
3086
            fprintf_plus(stderr, "unlink(\"%s/%s\"): %s\n", dirname,
3106
3087
                         direntries[i]->d_name, strerror(errno));
3107
3088
          }
3111
3092
      
3112
3093
      /* need to clean even if 0 because man page doesn't specify */
3113
3094
      free(direntries);
 
3095
      if(numentries == -1){
 
3096
        perror_plus("scandirat");
 
3097
      }
3114
3098
      dret = unlinkat(base, dirname, AT_REMOVEDIR);
3115
3099
      if(dret == -1 and errno != ENOENT){
3116
3100
        perror_plus("rmdir");