avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
AVAHI_LLIST_REMOVE(DNSServerInfo, servers, servers, i);
avahi_free(i);
}
AVAHI_LLIST_REMOVE(DNSServerInfo, servers, servers, i);
avahi_free(i);
}
static DNSServerInfo* new_server_info(AvahiIfIndex interface, AvahiProtocol protocol, const char *address) {
DNSServerInfo *i;
static DNSServerInfo* new_server_info(AvahiIfIndex interface, AvahiProtocol protocol, const char *address) {
DNSServerInfo *i;
i->address = avahi_strdup(address);
AVAHI_LLIST_PREPEND(DNSServerInfo, servers, servers, i);
i->address = avahi_strdup(address);
AVAHI_LLIST_PREPEND(DNSServerInfo, servers, servers, i);
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX;
strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1);
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX;
strncpy(sa.sun_path, AVAHI_SOCKET, sizeof(sa.sun_path)-1);
if (connect(fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) {
daemon_log(LOG_ERR, "connect(): %s", strerror(errno));
if (connect(fd, (struct sockaddr*) &sa, sizeof(sa)) < 0) {
daemon_log(LOG_ERR, "connect(): %s", strerror(errno));
- daemon_log(LOG_INFO, "Failed to connect to the daemon. This probably means that you");
- daemon_log(LOG_INFO, "didn't start avahi-daemon before avahi-dnsconfd.");
+ daemon_log(LOG_INFO, "Failed to connect to the daemon. This probably means that you");
+ daemon_log(LOG_INFO, "didn't start avahi-daemon before avahi-dnsconfd.");
p = concat_dns_servers(interface);
set_env(ENV_INTERFACE_DNS_SERVERS, p ? p : "");
p = concat_dns_servers(interface);
set_env(ENV_INTERFACE_DNS_SERVERS, p ? p : "");
p = concat_dns_servers(-1);
set_env(ENV_DNS_SERVERS, p ? p : "");
p = concat_dns_servers(-1);
set_env(ENV_DNS_SERVERS, p ? p : "");
snprintf(ia, sizeof(ia), "%i", (int) interface);
snprintf(pa, sizeof(pa), "%i", (int) protocol);
snprintf(ia, sizeof(ia), "%i", (int) interface);
snprintf(pa, sizeof(pa), "%i", (int) protocol);
AvahiProtocol protocol;
int i_interface, i_protocol, port;
char a[AVAHI_ADDRESS_STR_MAX];
AvahiProtocol protocol;
int i_interface, i_protocol, port;
char a[AVAHI_ADDRESS_STR_MAX];
if (*l != '<' && *l != '>') {
daemon_log(LOG_ERR, "Avahi sent us an invalid browsing line: %s", l);
if (*l != '<' && *l != '>') {
daemon_log(LOG_ERR, "Avahi sent us an invalid browsing line: %s", l);
if ((i = get_server_info(interface, protocol, a))) {
daemon_log(LOG_INFO, "DNS Server %s removed (interface: %i.%s)", a, interface, avahi_proto_to_string(protocol));
server_info_free(i);
if ((i = get_server_info(interface, protocol, a))) {
daemon_log(LOG_INFO, "DNS Server %s removed (interface: %i.%s)", a, interface, avahi_proto_to_string(protocol));
server_info_free(i);
AvahiProtocol protocol = servers->protocol;
char *address = avahi_strdup(servers->address);
server_info_free(servers);
AvahiProtocol protocol = servers->protocol;
char *address = avahi_strdup(servers->address);
server_info_free(servers);
run_script(0, interface, protocol, address);
avahi_free(address);
}
run_script(0, interface, protocol, address);
avahi_free(address);
}
" -k --kill Kill a running daemon\n"
" -r --refresh Request a running daemon to refresh DNS server data\n"
" -c --check Return 0 if a daemon is already running\n"
" -k --kill Kill a running daemon\n"
" -r --refresh Request a running daemon to refresh DNS server data\n"
" -c --check Return 0 if a daemon is already running\n"
static const struct option long_options[] = {
{ "help", no_argument, NULL, 'h' },
{ "daemonize", no_argument, NULL, 'D' },
static const struct option long_options[] = {
{ "help", no_argument, NULL, 'h' },
{ "daemonize", no_argument, NULL, 'D' },
{ "kill", no_argument, NULL, 'k' },
{ "version", no_argument, NULL, 'V' },
{ "refresh", no_argument, NULL, 'r' },
{ "kill", no_argument, NULL, 'k' },
{ "version", no_argument, NULL, 'V' },
{ "refresh", no_argument, NULL, 'r' },
- opterr = 0;
- while ((c = getopt_long(argc, argv, "hDkVrc", long_options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) {
daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP, 0);
/* Allocate some memory for our environment variables */
putenv(avahi_strdup(ENV_INTERFACE"="));
putenv(avahi_strdup(ENV_DNS_SERVERS"="));
putenv(avahi_strdup(ENV_INTERFACE_DNS_SERVERS"="));
daemon_signal_init(SIGINT, SIGTERM, SIGCHLD, SIGHUP, 0);
/* Allocate some memory for our environment variables */
putenv(avahi_strdup(ENV_INTERFACE"="));
putenv(avahi_strdup(ENV_DNS_SERVERS"="));
putenv(avahi_strdup(ENV_INTERFACE_DNS_SERVERS"="));
r = 0;
} else if (command == DAEMON_VERSION) {
printf("%s "PACKAGE_VERSION"\n", argv0);
r = 0;
} else if (command == DAEMON_VERSION) {
printf("%s "PACKAGE_VERSION"\n", argv0);
r = 0;
} else if (command == DAEMON_KILL) {
if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) {
daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno));
goto finish;
}
r = 0;
} else if (command == DAEMON_KILL) {
if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) {
daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno));
goto finish;
}