/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: 2017-01-25 20:25:22 UTC
  • mfrom: (237.4.88 release)
  • Revision ID: teddy@recompile.se-20170125202522-1q5dajim8u7urevc
Merge from release branch

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
      }
1501
1494
  return retval;
1502
1495
}
1503
1496
 
 
1497
__attribute__((nonnull))
1504
1498
static void resolve_callback(AvahiSServiceResolver *r,
1505
1499
                             AvahiIfIndex interface,
1506
1500
                             AvahiProtocol proto,
1661
1655
      perror_plus("ioctl SIOCGIFFLAGS");
1662
1656
      errno = old_errno;
1663
1657
    }
1664
 
    if((close(s) == -1) and debug){
1665
 
      old_errno = errno;
1666
 
      perror_plus("close");
1667
 
      errno = old_errno;
1668
 
    }
1669
1658
    return false;
1670
1659
  }
1671
 
  if((close(s) == -1) and debug){
1672
 
    old_errno = errno;
1673
 
    perror_plus("close");
1674
 
    errno = old_errno;
1675
 
  }
1676
1660
  return true;
1677
1661
}
1678
1662
 
1939
1923
      return;
1940
1924
    }
1941
1925
  }
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
1926
  int numhooks = scandirat(hookdir_fd, ".", &direntries,
1948
1927
                           runnable_hook, alphasort);
1949
1928
  if(numhooks == -1){
1950
1929
    perror_plus("scandir");
1951
 
    close(devnull);
1952
1930
    return;
1953
1931
  }
1954
1932
  struct dirent *direntry;
1955
1933
  int ret;
 
1934
  int devnull = (int)TEMP_FAILURE_RETRY(open("/dev/null", O_RDONLY));
 
1935
  if(devnull == -1){
 
1936
    perror_plus("open(\"/dev/null\", O_RDONLY)");
 
1937
    return;
 
1938
  }
1956
1939
  for(int i = 0; i < numhooks; i++){
1957
1940
    direntry = direntries[i];
1958
1941
    if(debug){
3078
3061
                                                | O_PATH));
3079
3062
    if(dir_fd == -1){
3080
3063
      perror_plus("open");
3081
 
      return;
3082
3064
    }
3083
3065
    int numentries = scandirat(dir_fd, ".", &direntries,
3084
3066
                               notdotentries, alphasort);
3101
3083
            clean_dir_at(dir_fd, direntries[i]->d_name, level+1);
3102
3084
            dret = 0;
3103
3085
          }
3104
 
          if((dret == -1) and (errno != ENOENT)){
 
3086
          if(dret == -1){
3105
3087
            fprintf_plus(stderr, "unlink(\"%s/%s\"): %s\n", dirname,
3106
3088
                         direntries[i]->d_name, strerror(errno));
3107
3089
          }
3111
3093
      
3112
3094
      /* need to clean even if 0 because man page doesn't specify */
3113
3095
      free(direntries);
 
3096
      if(numentries == -1){
 
3097
        perror_plus("scandirat");
 
3098
      }
3114
3099
      dret = unlinkat(base, dirname, AT_REMOVEDIR);
3115
3100
      if(dret == -1 and errno != ENOENT){
3116
3101
        perror_plus("rmdir");