Ifchd: Print out log messages when commands are successfully dispatched.

This commit is contained in:
Nicholas J. Kain 2013-05-08 06:36:20 -04:00
parent b7e6f59fc7
commit 3640c5bbf0
2 changed files with 15 additions and 2 deletions

View File

@ -256,6 +256,7 @@ void perform_dns(struct ifchd_client *cl, const char *str, size_t len)
return;
strnkcpy(cl->namesvrs, str, sizeof cl->namesvrs);
write_resolve_conf(cl);
log_line("Added DNS server: '%s'", str);
}
/* Updates for print daemons are too non-standard to be useful. */
@ -269,6 +270,8 @@ void perform_hostname(struct ifchd_client *cl, const char *str, size_t len)
return;
if (sethostname(str, strlen(str) + 1) == -1)
log_line("sethostname returned %s", strerror(errno));
else
log_line("Set hostname: '%s'", str);
}
/* update "domain" and "search" in /etc/resolv.conf */
@ -278,6 +281,7 @@ void perform_domain(struct ifchd_client *cl, const char *str, size_t len)
return;
strnkcpy(cl->domains, str, sizeof cl->domains);
write_resolve_conf(cl);
log_line("Added DNS domain: '%s'", str);
}
/* I don't think this can be done without a netfilter extension

View File

@ -111,6 +111,7 @@ void perform_interface(struct ifchd_client *cl, const char *str, size_t len)
/* Update interface name. */
memset(cl->ifnam, '\0', IFNAMSIZ);
strnkcpy(cl->ifnam, str, IFNAMSIZ);
log_line("Subsequent commands alter interface: '%s'", str);
}
static int set_if_flag(struct ifchd_client *cl, short flag)
@ -182,6 +183,8 @@ void perform_ip(struct ifchd_client *cl, const char *str, size_t len)
if (ioctl(fd, SIOCSIFADDR, &ifrt) < 0)
log_line("%s: failed to configure IP: %s",
cl->ifnam, strerror(errno));
else
log_line("Interface IP set to: '%s'", str);
close(fd);
}
@ -217,7 +220,8 @@ void perform_subnet(struct ifchd_client *cl, const char *str, size_t len)
if (ioctl(fd, SIOCSIFNETMASK, &ifrt) < 0)
log_line("%s: failed to configure subnet: %s",
cl->ifnam, strerror(errno));
}
} else
log_line("Interface subnet set to: '%s'", str);
close(fd);
}
@ -263,7 +267,8 @@ void perform_router(struct ifchd_client *cl, const char *str, size_t len)
if (errno != EEXIST)
log_line("%s: failed to set route: %s",
cl->ifnam, strerror(errno));
}
} else
log_line("Gateway router set to: '%s'", str);
close(fd);
}
@ -294,6 +299,8 @@ void perform_mtu(struct ifchd_client *cl, const char *str, size_t len)
if (ioctl(fd, SIOCSIFMTU, &ifrt) < 0)
log_line("%s: failed to set MTU (%d): %s", cl->ifnam, mtu,
strerror(errno));
else
log_line("MTU set to: '%s'", str);
close(fd);
}
@ -325,5 +332,7 @@ void perform_broadcast(struct ifchd_client *cl, const char *str, size_t len)
if (ioctl(fd, SIOCSIFBRDADDR, &ifrt) < 0)
log_line("%s: failed to set broadcast: %s",
cl->ifnam, strerror(errno));
else
log_line("Broadcast address set to: '%s'", str);
close(fd);
}