aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-run-hooks.in
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2012-07-23 16:45:46 -0700
committerDmitry Shmidt <dimitrysh@google.com>2012-07-23 16:54:15 -0700
commita3a2260384a906e1674c7498c2f479e9f37bc503 (patch)
tree5e5adc874a930144f847f57a08da862413b63668 /dhcpcd-run-hooks.in
parent2af699ea51cca49bd0f19080c9d73170e5bdadbc (diff)
downloadexternal_dhcpcd-a3a2260384a906e1674c7498c2f479e9f37bc503.zip
external_dhcpcd-a3a2260384a906e1674c7498c2f479e9f37bc503.tar.gz
external_dhcpcd-a3a2260384a906e1674c7498c2f479e9f37bc503.tar.bz2
dhcpcd: Update to Version 5.5.6
Change-Id: I98c378688be723a2a602ec17c26bc13f2fd83cc8 Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'dhcpcd-run-hooks.in')
-rw-r--r--dhcpcd-run-hooks.in66
1 files changed, 53 insertions, 13 deletions
diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in
index cb897b4..2125f9a 100644
--- a/dhcpcd-run-hooks.in
+++ b/dhcpcd-run-hooks.in
@@ -2,25 +2,25 @@
# dhcpcd client configuration script
# Handy variables and functions for our hooks to use
+if [ "$reason" = ROUTERADVERT ]; then
+ ifsuffix=":ra"
+else
+ ifsuffix=
+fi
+ifname="$interface$ifsuffix"
+
from=from
signature_base="# Generated by dhcpcd"
-signature="$signature_base $from $interface"
+signature="$signature_base $from $ifname"
signature_base_end="# End of dhcpcd"
-signature_end="$signature_base_end $from $interface"
+signature_end="$signature_base_end $from $ifname"
state_dir=/var/run/dhcpcd
-if_up=false
-if_down=false
-case "$reason" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) if_up=true;;
-PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) if_down=true;;
-esac
-
# Ensure that all arguments are unique
uniqify()
{
local result= i=
- for i; do
+ for i do
case " $result " in
*" $i "*);;
*) result="$result $i";;
@@ -62,7 +62,7 @@ key_get_value()
if type sed >/dev/null 2>&1; then
sed -n "s/^$key//p" $@
else
- for x; do
+ for x do
while read line; do
case "$line" in
"$key"*) echo "${line##$key}";;
@@ -82,7 +82,7 @@ remove_markers()
if type sed >/dev/null 2>&1; then
sed "/^$m1/,/^$m2/d" $@
else
- for x; do
+ for x do
while read line; do
case "$line" in
"$m1"*) in_marker=1;;
@@ -142,11 +142,51 @@ syslog()
[ -n "$lvl" ] && shift
if [ -n "$*" ]; then
if type logger >/dev/null 2>&1; then
- logger -t dhcpcd -p daemon."$lvl" -s "$*"
+ logger -t dhcpcd -p daemon."$lvl" -is "$interface: $*"
fi
fi
}
+# Check for a valid domain name as per RFC1123 with the exception of
+# allowing - and _ as they seem to be widely used.
+valid_domainname()
+{
+ local name="$1" label
+
+ [ -z "$name" -o ${#name} -gt 255 ] && return 1
+
+ while [ -n "$name" ]; do
+ label="${name%%.*}"
+ [ -z "$label" -o ${#label} -gt 63 ] && return 1
+ case "$label" in
+ -*|_*|*-|*_) return 1;;
+ *[![:alnum:]-_]*) return 1;;
+ esac
+ [ "$name" = "${name#*.}" ] && break
+ name="${name#*.}"
+ done
+ return 0
+}
+
+valid_domainname_list()
+{
+ local name
+
+ for name do
+ valid_domainname "$name" || return $?
+ done
+ return 0
+}
+
+# Check for a valid path
+valid_path()
+{
+ case "$@" in
+ *[![:alnum:]#%+-_:\.,@~\\/\[\]=\ ]*) return 1;;
+ esac
+ return 0
+}
+
# Check a system service exists
service_exists()
{