Add a -V --verbose flag to enable the overly verbose list reciept logging.
Update interface flags only if it would provoke an actual change.
This commit is contained in:
parent
e96dab80fe
commit
b3f9115689
21
ifchd/ifchd.c
Normal file → Executable file
21
ifchd/ifchd.c
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
/* ifchd.c - interface change daemon
|
/* ifchd.c - interface change daemon
|
||||||
* Time-stamp: <2010-12-01 12:19:39 njk>
|
* Time-stamp: <2011-04-30 07:26:54 nk>
|
||||||
*
|
*
|
||||||
* (C) 2004-2010 Nicholas J. Kain <njkain at gmail dot com>
|
* (C) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -99,6 +99,8 @@ static uid_t peer_uid;
|
|||||||
static gid_t peer_gid;
|
static gid_t peer_gid;
|
||||||
static pid_t peer_pid;
|
static pid_t peer_pid;
|
||||||
|
|
||||||
|
static int gflags_verbose = 0;
|
||||||
|
|
||||||
/* Lists of nameservers and search domains. Unfortunately they must be
|
/* Lists of nameservers and search domains. Unfortunately they must be
|
||||||
* per-connection, since otherwise seperate clients could race against
|
* per-connection, since otherwise seperate clients could race against
|
||||||
* one another to write out unpredictable data.
|
* one another to write out unpredictable data.
|
||||||
@ -379,7 +381,8 @@ static void execute_list(int i)
|
|||||||
|
|
||||||
p = curl[i]->str;
|
p = curl[i]->str;
|
||||||
|
|
||||||
log_line("execute_list - p = '%s'", p);
|
if (gflags_verbose)
|
||||||
|
log_line("execute_list - p = '%s'", p);
|
||||||
|
|
||||||
switch (state[i]) {
|
switch (state[i]) {
|
||||||
case STATE_NOTHING:
|
case STATE_NOTHING:
|
||||||
@ -766,10 +769,11 @@ int main(int argc, char** argv) {
|
|||||||
{"interface", 1, 0, 'i'},
|
{"interface", 1, 0, 'i'},
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"version", 0, 0, 'v'},
|
{"version", 0, 0, 'v'},
|
||||||
|
{"verbose", 0, 0, 'V'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "dnp:qc:r:ou:g:U:G:P:i:hv", long_options,
|
c = getopt_long(argc, argv, "dnp:qc:r:ou:g:U:G:P:i:hvV", long_options,
|
||||||
&option_index);
|
&option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
@ -780,7 +784,7 @@ int main(int argc, char** argv) {
|
|||||||
printf(
|
printf(
|
||||||
"ifchd %s, if change daemon. Licensed under GNU GPL.\n", IFCHD_VERSION);
|
"ifchd %s, if change daemon. Licensed under GNU GPL.\n", IFCHD_VERSION);
|
||||||
printf(
|
printf(
|
||||||
"Copyright (C) 2004-2010 Nicholas J. Kain\n"
|
"Copyright (C) 2004-2011 Nicholas J. Kain\n"
|
||||||
"Usage: ifchd [OPTIONS]\n"
|
"Usage: ifchd [OPTIONS]\n"
|
||||||
" -d, --detach detach from TTY and daemonize\n"
|
" -d, --detach detach from TTY and daemonize\n"
|
||||||
" -n, --nodetach stay attached to TTY\n"
|
" -n, --nodetach stay attached to TTY\n"
|
||||||
@ -796,6 +800,7 @@ int main(int argc, char** argv) {
|
|||||||
" -G, --cgroup group name of clients\n"
|
" -G, --cgroup group name of clients\n"
|
||||||
" -P, --cpid process id of client\n"
|
" -P, --cpid process id of client\n"
|
||||||
" -i, --interface ifchd clients may modify this interface\n"
|
" -i, --interface ifchd clients may modify this interface\n"
|
||||||
|
" -V, --verbose log detailed messages\n"
|
||||||
" -h, --help print this help and exit\n"
|
" -h, --help print this help and exit\n"
|
||||||
" -v, --version print version information and exit\n");
|
" -v, --version print version information and exit\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -805,7 +810,7 @@ int main(int argc, char** argv) {
|
|||||||
printf(
|
printf(
|
||||||
"ifchd %s, if change daemon. Licensed under GNU GPL.\n", IFCHD_VERSION);
|
"ifchd %s, if change daemon. Licensed under GNU GPL.\n", IFCHD_VERSION);
|
||||||
printf(
|
printf(
|
||||||
"Copyright (C) 2004-2010 Nicholas J. Kain\n"
|
"Copyright (C) 2004-2011 Nicholas J. Kain\n"
|
||||||
"This is free software; see the source for copying conditions. There is NO\n"
|
"This is free software; see the source for copying conditions. There is NO\n"
|
||||||
"WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
"WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -899,6 +904,10 @@ int main(int argc, char** argv) {
|
|||||||
case 'i':
|
case 'i':
|
||||||
add_permitted_if(optarg);
|
add_permitted_if(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'V':
|
||||||
|
gflags_verbose = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
ifchd/linux.c
Normal file → Executable file
22
ifchd/linux.c
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
/* linux.c - ifchd Linux-specific functions
|
/* linux.c - ifchd Linux-specific functions
|
||||||
* Time-stamp: <2010-11-12 18:41:15 njk>
|
* Time-stamp: <2011-04-30 07:28:08 nk>
|
||||||
*
|
*
|
||||||
* (C) 2004-2010 Nicholas J. Kain <njkain at gmail dot com>
|
* (C) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -144,14 +144,16 @@ static int set_if_flag(int idx, short flag)
|
|||||||
log_line("%s: unknown interface: %s\n", ifnam[idx], strerror(errno));
|
log_line("%s: unknown interface: %s\n", ifnam[idx], strerror(errno));
|
||||||
goto out1;
|
goto out1;
|
||||||
}
|
}
|
||||||
strlcpy(ifrt.ifr_name, ifnam[idx], IFNAMSIZ);
|
if (((ifrt.ifr_flags & flag ) ^ flag) & flag) {
|
||||||
ifrt.ifr_flags |= flag;
|
strlcpy(ifrt.ifr_name, ifnam[idx], IFNAMSIZ);
|
||||||
if (ioctl(fd, SIOCSIFFLAGS, &ifrt) < 0) {
|
ifrt.ifr_flags |= flag;
|
||||||
log_line("%s: failed to set interface flags: %s\n",
|
if (ioctl(fd, SIOCSIFFLAGS, &ifrt) < 0) {
|
||||||
ifnam[idx], strerror(errno));
|
log_line("%s: failed to set interface flags: %s\n",
|
||||||
goto out1;
|
ifnam[idx], strerror(errno));
|
||||||
}
|
goto out1;
|
||||||
ret = 0;
|
}
|
||||||
|
} else
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
out1:
|
out1:
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user