Commit 00ae6a2e authored by Tails developers's avatar Tails developers

Simplify regex by using grep's --extended-regexp.

parent a3bf5959
...@@ -99,13 +99,13 @@ if [ -r "${NM_ENV_FILE}" ]; then ...@@ -99,13 +99,13 @@ if [ -r "${NM_ENV_FILE}" ]; then
# contain any unexpected data, like (potentially malicious) shell # contain any unexpected data, like (potentially malicious) shell
# script. Note that while the regex used for deciding IP addresses # script. Note that while the regex used for deciding IP addresses
# is far from perfect, it serves our purpose here. # is far from perfect, it serves our purpose here.
IP4_REGEX='[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}' IP4_REGEX='[0-9]{1,3}(\.[0-9]{1,3}){3}'
NAMESERVERS_REGEX="^IP4_NAMESERVERS=\"${IP4_REGEX}\"$" NAMESERVERS_REGEX="^IP4_NAMESERVERS=\"${IP4_REGEX}\"$"
if grep -qv "${NAMESERVERS_REGEX}" "${NM_ENV_FILE}"; then if grep --extended-regexp -qv "${NAMESERVERS_REGEX}" "${NM_ENV_FILE}"; then
error "`gettext \"NetworkManager passed us garbage data when trying to deduce the clearnet DNS server.\"`" error "`gettext \"NetworkManager passed us garbage data when trying to deduce the clearnet DNS server.\"`"
fi fi
# Import the IP4_NAMESERVERS variable. # Import the IP4_NAMESERVERS variable.
eval "$(grep "${NAMESERVERS_REGEX}" "${NM_ENV_FILE}")" eval "$(grep --extended-regexp "${NAMESERVERS_REGEX}" "${NM_ENV_FILE}")"
fi fi
# ... otherwise fail. # ... otherwise fail.
# FIXME: Or would it make sense to fallback to Google's DNS or OpenDNS? # FIXME: Or would it make sense to fallback to Google's DNS or OpenDNS?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment