Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevented ifup-local from writing duplicate DNS entries #4674

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion kura/distrib/src/main/resources/common/ifup-local.debian
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ if [ $IFACE == "lo" ] ; then
exit
fi

write_dns() {
if [ -z "$1" ]; then
return
fi

ARG=$(echo "${1}" | xargs)

WRITE_DNS=1

if [ -e /etc/resolv.conf ]; then
while read -r line
do
if [[ "$line" == nameserver* ]]; then
DNS=$(echo "${line#*\ }" | xargs)
if [ "${DNS}" == "${ARG}" ]; then
WRITE_DNS=0
break
fi
fi
done < /etc/resolv.conf
fi

if [ "${WRITE_DNS}" == 1 ]; then
echo "nameserver ${ARG}" >> /etc/resolv.conf
fi
}

DEVICE=$IFACE
FILENAME="/tmp/.kura/coninfo-"$DEVICE
FLAG=0
Expand Down Expand Up @@ -40,7 +67,7 @@ do
DnsInd=`expr $DnsInd + 1`
IFS=' ' read -ra Dns <<< "${line:$ind}"
for i in "${Dns[@]}"; do
echo "nameserver $i" >> /etc/resolv.conf
write_dns "$i"
done
break
fi
Expand Down
29 changes: 28 additions & 1 deletion kura/distrib/src/main/resources/common/ifup-local.raspbian
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ if [ $IFACE == "lo" ] ; then
exit
fi

write_dns() {
if [ -z "$1" ]; then
return
fi

ARG=$(echo "${1}" | xargs)

WRITE_DNS=1

if [ -e /etc/resolv.conf ]; then
while read -r line
do
if [[ "$line" == nameserver* ]]; then
DNS=$(echo "${line#*\ }" | xargs)
if [ "${DNS}" == "${ARG}" ]; then
WRITE_DNS=0
break
fi
fi
done < /etc/resolv.conf
fi

if [ "${WRITE_DNS}" == 1 ]; then
echo "nameserver ${ARG}" >> /etc/resolv.conf
fi
}

DEVICE=$IFACE
FILENAME="/tmp/.kura/coninfo-"$DEVICE
FLAG=0
Expand Down Expand Up @@ -40,7 +67,7 @@ do
DnsInd=`expr $DnsInd + 1`
IFS=' ' read -ra Dns <<< "${line:$ind}"
for i in "${Dns[@]}"; do
echo "nameserver $i" >> /etc/resolv.conf
write_dns "$i"
done
break
fi
Expand Down