diff options
author | Martin Schwenke <martin@meltin.net> | 2014-12-19 14:19:32 +1100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2015-04-19 21:21:38 +0200 |
commit | 3aecf288501e29f6d55f128d5b82f93eb84e6e73 (patch) | |
tree | 5a9fba129083f1978d2737227651590fe8cd31b1 /ctdb | |
parent | 6cbfa359fb150cc1e9284d6ace8a3ddee09b5651 (diff) | |
download | samba-3aecf288501e29f6d55f128d5b82f93eb84e6e73.tar.gz |
ctdb-scripts: Don't use the GNU awk gensub() function
This is a gawk extension and can't be used reliably if just running
"awk". It is simple enough to switch to using the standard sub() and
gsub() functions.
The alternative is to switch to explicitly running "gawk". However,
although the eventscripts aren't exactly portable, it is probably
better to move closer to portability than further away.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit 4638010abb116aed0c180207aaa11475277aecb7)
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/config/functions | 7 | ||||
-rwxr-xr-x | ctdb/config/statd-callout | 4 | ||||
-rwxr-xr-x | ctdb/tests/complex/18_ctdb_reloadips.sh | 2 | ||||
-rw-r--r-- | ctdb/tests/scripts/integration.bash | 5 |
4 files changed, 11 insertions, 7 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions index e900f7f06e6..8707413de0d 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -890,7 +890,7 @@ delete_ip_from_iface() } } -# If the given IP is hosted then print 2 items: maskbits and iface +# If the given IP is hosted then print 2 items: maskbits and iface ip_maskbits_iface () { _addr="$1" @@ -902,8 +902,9 @@ ip_maskbits_iface () ip addr show to "${_addr}/${_bits}" 2>/dev/null | \ awk -v family="${_family}" \ - 'NR == 1 { iface = gensub(":$", "", 1, $2) } \ - $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }' + 'NR == 1 { iface = $2; sub(":$", "", iface) } \ + $1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \ + print mask, iface, family }' } drop_ip () diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index 5e8eb0e789c..e2a955eab5f 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -145,7 +145,9 @@ case "$1" in # server-IP client-IP # but only for the server-IPs that are hosted on this node. sed_expr=$(ctdb ip | tail -n +2 | - awk -v pnn=$pnn 'pnn == $2 { printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", gensub(/\./, "\\\\.", "g", $1) }') + awk -v pnn=$pnn 'pnn == $2 { \ + ip = $1; gsub(/\./, "\\\\.", ip); \ + printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }') statd_state=$(ctdb catdb ctdb.tdb | sed -n "$sed_expr" | sort) [ -n "$statd_state" ] || exit 0 diff --git a/ctdb/tests/complex/18_ctdb_reloadips.sh b/ctdb/tests/complex/18_ctdb_reloadips.sh index 13f7c213af0..71f997cda56 100755 --- a/ctdb/tests/complex/18_ctdb_reloadips.sh +++ b/ctdb/tests/complex/18_ctdb_reloadips.sh @@ -56,7 +56,7 @@ ctdb_ip_info=$(echo "$out" | awk -F'|' 'NR > 1 { print $2, $3, $5 }') echo "Getting IP information from interfaces..." try_command_on_node all "ip addr show" ip_addr_info=$(echo "$out" | \ - awk '$1 == "inet" { print gensub(/\/.*/, "", "", $2)}') + awk '$1 == "inet" { ip = $2; sub(/\/.*/, "", ip); print ip }') prefix="" for b in $(seq 0 255) ; do diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index 0d27c93643f..139a9a23cb2 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -699,8 +699,9 @@ ip_maskbits_iface () ip addr show to "${_addr}/${_bits}" 2>/dev/null | \ awk -v family="${_family}" \ - 'NR == 1 { iface = gensub(":$", "", 1, $2) } \ - $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }' + 'NR == 1 { iface = $2; sub(":$", "", iface) } \ + $1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \ + print mask, iface, family }' } drop_ip () |