Ticket #147: avahi-0.6.16-autoipd-action-script.patch

File avahi-0.6.16-autoipd-action-script.patch, 2.5 kB (added by dcbw, 2 years ago)

Add a --script option

  • avahi-0.6.16/avahi-autoipd/main.c

    old new  
    117117#endif 
    118118static int no_drop_root = 0; 
    119119static int wrote_pid_file = 0; 
     120static char *action_script = NULL; 
    120121 
    121122static enum { 
    122123    DAEMON_RUN, 
     
    575576            } 
    576577             
    577578            if (daemon_exec("/", &k, 
    578                             AVAHI_IPCONF_SCRIPT, AVAHI_IPCONF_SCRIPT
     579                            action_script, action_script
    579580                            callout_event_table[info.event], 
    580581                            name, 
    581582                            inet_ntop(AF_INET, &info.address, buf, sizeof(buf)), NULL) < 0) { 
     
    11541155            "    -V --version        Show version\n" 
    11551156            "    -S --start=ADDRESS  Start with this address from the IPv4LL range\n" 
    11561157            "                        169.254.0.0/16\n" 
     1158            "    -t --script=script  Action script to run (defaults to\n" 
     1159            "                        /etc/avahi/avahi-autoipd.action)\n" 
    11571160            "    -w --wait           Wait until an address has been acquired before\n" 
    11581161            "                        daemonizing\n" 
    11591162            "       --force-bind     Assign an IPv4LL address even if a routable address\n" 
     
    11891192        { "check",         no_argument,       NULL, 'c' }, 
    11901193        { "version",       no_argument,       NULL, 'V' }, 
    11911194        { "start",         required_argument, NULL, 'S' }, 
     1195        { "script",        required_argument, NULL, 't' }, 
    11921196        { "wait",          no_argument,       NULL, 'w' }, 
    11931197        { "force-bind",    no_argument,       NULL, OPTION_FORCE_BIND }, 
    11941198        { "no-drop-root",  no_argument,       NULL, OPTION_NO_DROP_ROOT }, 
     
    12011205    }; 
    12021206 
    12031207    opterr = 0; 
    1204     while ((c = getopt_long(argc, argv, "hDskrcVS:w", long_options, NULL)) >= 0) { 
     1208    while ((c = getopt_long(argc, argv, "hDskrcVS:t:w", long_options, NULL)) >= 0) { 
    12051209 
    12061210        switch(c) { 
    12071211            case 's': 
     
    12321236                    return -1; 
    12331237                } 
    12341238                break; 
     1239            case 't': 
     1240                action_script = avahi_strdup(optarg); 
     1241                break; 
    12351242            case 'w': 
    12361243                wait_for_address = 1; 
    12371244                break; 
     
    12811288        fprintf(stderr, "Too many arguments\n"); 
    12821289        return -1; 
    12831290    } 
     1291 
     1292    if (!action_script) 
     1293        action_script = avahi_strdup(AVAHI_IPCONF_SCRIPT); 
    12841294         
    12851295    return 0; 
    12861296}