Discussion:
[OpenWrt-Devel] [PATCH] dnsmasq: Generate rDNS records for custom domain names
Tyler Fenby
2014-08-14 16:56:00 UTC
Permalink
LuCI creates "domain" UCI config sections, which the dnsmasq init file
then, currently, translates into "address" config lines. This is not
the correct usage of "address" (see r36943), and also causes rDNS
records to not be created. This patches dnsmasq.init to utilize the
additional hosts file introduced in r40799 for such domain names,
resolving both issues.

Signed-off-by: Tyler Fenby <***@securecominc.com>
---

This also pretty much makes dhcp_hostrecord_add useless.

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init
b/package/network/services/dnsmasq/files/dnsmasq.init
index 815f424..67d1063 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -438,13 +438,10 @@ dhcp_domain_add() {
[ -n "$ip" ] || return 0

for name in $names; do
- [ "${name%.*}" == "$name" ] && \
- name="$name${DOMAIN:+.$DOMAIN}"
+ record="${record:+$record }$name"
+ done

- record="${record:+$record/}$name"
- done
-
- xappend "--address=/$record/$ip"
+ echo "$ip $record" >> $HOSTFILE
}

dhcp_srv_add() {
@@ -569,7 +566,7 @@ start_service() {
local lanaddr
[ $ADD_LOCAL_HOSTNAME -eq 1 ] && network_get_ipaddr lanaddr "lan" && {
local hostname="$(uci_get system @system[0] hostname OpenWrt)"
- dhcp_hostrecord_add ""
"${hostname%.$DOMAIN}${DOMAIN:+.$DOMAIN ${hostname%.$DOMAIN}}"
"$lanaddr"
+ dhcp_domain_add "" "$hostname" "$lanaddr"
}

echo >> $CONFIGFILE
--
John Crispin
2014-08-25 06:09:36 UTC
Permalink
Hi,

patch is whitespace broken. please fix and resend

John
Post by Tyler Fenby
LuCI creates "domain" UCI config sections, which the dnsmasq init file
then, currently, translates into "address" config lines. This is not
the correct usage of "address" (see r36943), and also causes rDNS
records to not be created. This patches dnsmasq.init to utilize the
additional hosts file introduced in r40799 for such domain names,
resolving both issues.
---
This also pretty much makes dhcp_hostrecord_add useless.
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init
b/package/network/services/dnsmasq/files/dnsmasq.init
index 815f424..67d1063 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -438,13 +438,10 @@ dhcp_domain_add() {
[ -n "$ip" ] || return 0
for name in $names; do
- [ "${name%.*}" == "$name" ] && \
- name="$name${DOMAIN:+.$DOMAIN}"
+ record="${record:+$record }$name"
+ done
- record="${record:+$record/}$name"
- done
-
- xappend "--address=/$record/$ip"
+ echo "$ip $record" >> $HOSTFILE
}
dhcp_srv_add() {
@@ -569,7 +566,7 @@ start_service() {
local lanaddr
[ $ADD_LOCAL_HOSTNAME -eq 1 ] && network_get_ipaddr lanaddr "lan" && {
- dhcp_hostrecord_add ""
"${hostname%.$DOMAIN}${DOMAIN:+.$DOMAIN ${hostname%.$DOMAIN}}"
"$lanaddr"
+ dhcp_domain_add "" "$hostname" "$lanaddr"
}
echo >> $CONFIGFILE
--
_______________________________________________
openwrt-devel mailing list
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Tyler Fenby
2014-08-26 14:54:26 UTC
Permalink
...and it only just occurred to me that by "whitespace broken" John
was referring to the fact that it's tabs and spaces mixed (.vimrc set
up to work with Python, heh). I thought maybe gmail had screwed
something up.
I'm sorry. I'll actually correct the patch and send it again.

Tyler Fenby
Security System Engineer
SecureCom
Office: +1 989 837-4005
Post by Tyler Fenby
LuCI creates "domain" UCI config sections, which the dnsmasq init file
then, currently, translates into "address" config lines. This is not
the correct usage of "address" (see r36943), and also causes rDNS
records to not be created. This patches dnsmasq.init to utilize the
additional hosts file introduced in r40799 for such domain names,
resolving both issues.
---
This also pretty much makes dhcp_hostrecord_add useless.
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init
b/package/network/services/dnsmasq/files/dnsmasq.init
index 815f424..67d1063 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -438,13 +438,10 @@ dhcp_domain_add() {
[ -n "$ip" ] || return 0
for name in $names; do
- [ "${name%.*}" == "$name" ] && \
- name="$name${DOMAIN:+.$DOMAIN}"
+ record="${record:+$record }$name"
+ done
- record="${record:+$record/}$name"
- done
-
- xappend "--address=/$record/$ip"
+ echo "$ip $record" >> $HOSTFILE
}
dhcp_srv_add() {
@@ -569,7 +566,7 @@ start_service() {
local lanaddr
[ $ADD_LOCAL_HOSTNAME -eq 1 ] && network_get_ipaddr lanaddr "lan" && {
- dhcp_hostrecord_add ""
"${hostname%.$DOMAIN}${DOMAIN:+.$DOMAIN ${hostname%.$DOMAIN}}"
"$lanaddr"
+ dhcp_domain_add "" "$hostname" "$lanaddr"
}
echo >> $CONFIGFILE
--
Loading...