/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 plugin-runner.c

  • Committer: Teddy Hogeborn
  • Date: 2014-10-08 21:07:10 UTC
  • Revision ID: teddy@recompile.se-20141008210710-x0rg80z2aabdg05d
Handle local Zeroconf service name collisions.

Service name collisions from other servers have always been handled,
but not *local* name collisions from services on the same host.

* mandos (AvahiService/rename): Handle local Zeroconf service name
                                collision.
  (AvahiServiceToSyslog.rename): Pass on any extra arguments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
#define BUFFER_SIZE 256
77
77
 
78
78
#define PDIR "/lib/mandos/plugins.d"
79
 
#define PHDIR "/lib/mandos/plugin-helpers"
80
79
#define AFILE "/conf/conf.d/mandos/plugin-runner.conf"
81
80
 
82
81
const char *argp_program_version = "plugin-runner " VERSION;
348
347
 
349
348
int main(int argc, char *argv[]){
350
349
  char *plugindir = NULL;
351
 
  char *pluginhelperdir = NULL;
352
350
  char *argfile = NULL;
353
351
  FILE *conffp;
354
352
  struct dirent **direntries = NULL;
416
414
      .doc = "Group ID the plugins will run as", .group = 3 },
417
415
    { .name = "debug", .key = 132,
418
416
      .doc = "Debug mode", .group = 4 },
419
 
    { .name = "plugin-helper-dir", .key = 133,
420
 
      .arg = "DIRECTORY",
421
 
      .doc = "Specify a different plugin helper directory",
422
 
      .group = 2 },
423
417
    /*
424
418
     * These reproduce what we would get without ARGP_NO_HELP
425
419
     */
551
545
    case 132:                   /* --debug */
552
546
      debug = true;
553
547
      break;
554
 
    case 133:                   /* --plugin-helper-dir */
555
 
      free(pluginhelperdir);
556
 
      pluginhelperdir = strdup(arg);
557
 
      if(pluginhelperdir != NULL){
558
 
        errno = 0;
559
 
      }
560
 
      break;
561
548
      /*
562
549
       * These reproduce what we would get without ARGP_NO_HELP
563
550
       */
614
601
    case 130:                   /* --userid */
615
602
    case 131:                   /* --groupid */
616
603
    case 132:                   /* --debug */
617
 
    case 133:                   /* --plugin-helper-dir */
618
604
    case '?':                   /* --help */
619
605
    case -3:                    /* --usage */
620
606
    case 'V':                   /* --version */
775
761
    goto fallback;
776
762
  }
777
763
  
778
 
  {
779
 
    char *pluginhelperenv;
780
 
    bool bret = true;
781
 
    ret = asprintf(&pluginhelperenv, "MANDOSPLUGINHELPERDIR=%s",
782
 
                   pluginhelperdir != NULL ? pluginhelperdir : PHDIR);
783
 
    if(ret != -1){
784
 
      bret = add_environment(getplugin(NULL), pluginhelperenv, true);
785
 
    }
786
 
    if(ret == -1 or not bret){
787
 
      error(0, errno, "Failed to set MANDOSPLUGINHELPERDIR"
788
 
            " environment variable to \"%s\" for all plugins\n",
789
 
            pluginhelperdir != NULL ? pluginhelperdir : PHDIR);
790
 
    }
791
 
    if(ret != -1){
792
 
      free(pluginhelperenv);
793
 
    }
794
 
  }
795
 
  
796
764
  if(debug){
797
765
    for(plugin *p = plugin_list; p != NULL; p=p->next){
798
766
      fprintf(stderr, "Plugin: %s has %d arguments\n",
1368
1336
  free_plugin_list();
1369
1337
  
1370
1338
  free(plugindir);
1371
 
  free(pluginhelperdir);
1372
1339
  free(argfile);
1373
1340
  
1374
1341
  return exitstatus;