/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

* plugins.d/mandos-client.c (runnable_hook): Bug fix: stat using the
                                             full path.
  (mail): Take new "--network-hook-dir" option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
const char *argp_program_bug_address = "<mandos@recompile.se>";
134
134
static const char sys_class_net[] = "/sys/class/net";
135
135
char *connect_to = NULL;
 
136
const char *hookdir = HOOKDIR;
136
137
 
137
138
/* Doubly linked list that need to be circularly linked when used */
138
139
typedef struct server{
1304
1305
  
1305
1306
  /* XXX more rules here */
1306
1307
  
1307
 
  ret = stat(direntry->d_name, &st);
 
1308
  char *fullname = NULL;
 
1309
  ret = asprintf(&fullname, "%s/%s", hookdir,
 
1310
                 direntry->d_name);
 
1311
  if(ret < 0){
 
1312
    perror_plus("asprintf");
 
1313
    return 0;
 
1314
  }
 
1315
  
 
1316
  ret = stat(fullname, &st);
1308
1317
  if(ret == -1){
1309
1318
    if(debug){
1310
1319
      perror_plus("Could not stat plugin");
1482
1491
        .arg = "SECONDS",
1483
1492
        .doc = "Retry interval used when denied by the mandos server",
1484
1493
        .group = 2 },
 
1494
      { .name = "network-hook-dir", .key = 133,
 
1495
        .arg = "DIR",
 
1496
        .doc = "Directory where network hooks are located",
 
1497
        .group = 2 },
1485
1498
      /*
1486
1499
       * These reproduce what we would get without ARGP_NO_HELP
1487
1500
       */
1540
1553
          argp_error(state, "Bad retry interval");
1541
1554
        }
1542
1555
        break;
 
1556
      case 133:                 /* --network-hook-dir */
 
1557
        hookdir = arg;
 
1558
        break;
1543
1559
        /*
1544
1560
         * These reproduce what we would get without ARGP_NO_HELP
1545
1561
         */
1646
1662
  {
1647
1663
    struct dirent **direntries;
1648
1664
    struct dirent *direntry;
1649
 
    int numhooks = scandir(HOOKDIR, &direntries, runnable_hook,
 
1665
    int numhooks = scandir(hookdir, &direntries, runnable_hook,
1650
1666
                           alphasort);
1651
1667
    if(numhooks == -1){
1652
1668
      perror_plus("scandir");
1655
1671
      for(int i = 0; i < numhooks; i++){
1656
1672
        direntry = direntries[0];
1657
1673
        char *fullname = NULL;
1658
 
        ret = asprintf(&fullname, "%s/%s", tempdir,
1659
 
                       direntry->d_name);
 
1674
        ret = asprintf(&fullname, "%s/%s", hookdir, direntry->d_name);
1660
1675
        if(ret < 0){
1661
1676
          perror_plus("asprintf");
1662
1677
          continue;