The branch, master has been updated via e0aae9f ctdb-tests: Add shellcheck test suite via b51f604 ctdb-tests: Add new test support script for script install paths via 355c49f ctdb-scripts: Avoid shellcheck warning SC2006 (legacy `..`) via dfa2c1d ctdb-scripts: Avoid shellcheck warning SC2124 (string=array) via f19f44e ctdb-scripts: Avoid shellcheck warning SC2155 (declare, assign) via aa51875 ctdb-scripts: Avoid shellcheck warning SC2059 ($ in printf format) via 8bd2c55 ctdb-scripts: Avoid chellcheck warning SC2012 (ls for file list) via 52b43d7 ctdb-scripts: Avoid shellcheck warning SC2012 (ls for file list) via 5e9aa57 ctdb-scripts: Avoid shellcheck warning SC2038 (find without -print0) via d138cb8 ctdb-scripts: Avoid shellcheck warning SC2039 (non-portable ulimit options) via e96c122 ctdb-scripts: Avoid shellcheck warning SC2039 (test -nt operator) via 524eac9 ctdb-scripts: Avoid shellcheck warning SC2094 (read/write same file) via d7f3b19 ctdb-scripts: Avoid shellcheck warning SC2039 (echo -n) via f43df8f ctdb-scripts: Avoid shellcheck warning SC2039 (type command) via b0c1dbf ctdb-scripts: Avoid shellcheck warning SC2015 (A && B || C) via 987fd07 ctdb-scripts: Avoid shellcheck warnings SC2119, SC2120 (function arguments) via 77341f6 ctdb-scripts: Avoid shellcheck warning SC2002 (useless cat) via fc858a1 ctdb-scripts: Avoid shellcheck warning SC2017 (arithmetic precision) via 0ca0026 ctdb-scripts: Avoid shellcheck warning SC1004 (backslash in quotes) via b208ae7 ctdb-scripts: Avoid shellcheck warning SC2154 (unassigned variables) via 9255d64 ctdb-scripts: Avoid shellcheck warnings SC2046, SC2086 (double-quoting) via f6c25a4 ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables) via 13b3c6a ctdb-scripts: Avoid shellcheck warning SC2004 ($ in arithmetic) via efc9af2 ctdb-scripts: Avoid shellcheck warnings SC2030, SC2031 (subshell variables) via 0ea90f6 ctdb-scripts: Avoid shellcheck warning SC2016 ($ in single quotes) via 113529f ctdb-scripts: Drop function ctdb_check_counter() via 770fe1f ctdb-scripts: Drop use of ctdb_check_counter from vsftpd event script via 0825eff ctdb-scripts: Drop use of ctdb_check_counter from reclock event script via 92d0d44 ctdb-scripts: Drop use of ctdb_check_counter from httpd event script via fc53256 ctdb-scripts: Drop use of service_tcp_ports via 09a7a78 ctdb-scripts: Event script indentation and whitespace cleanups via d52409d ctdb-scripts: Drop use of ctdb_standard_event_handler() via 5cf45ed ctdb-tests: New event script test for corrupt TDB checking via 0d60ecf ctdb-tests: Add new httpd event script test via ca28a47 ctdb-tests: Add new vsftpd event script test via c7a730c ctdb-tests: Add reclock event script tests via 91eb421 ctdb-scripts: Fix a bug in counter checking from 5437fdc s4:torture/ndr: add more krb5pac tests with PAC blobs from pkinit
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit e0aae9f0d374cda639371aa3e395e848682e5737 Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jul 14 12:01:14 2016 +1000 ctdb-tests: Add shellcheck test suite CTDB has a lot of scripts and shellcheck can be useful to find dubious scripting practices. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Thu Jul 21 06:06:49 CEST 2016 on sn-devel-144 commit b51f604f753abc094bf0151165173c5a27b5711f Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jul 14 11:58:51 2016 +1000 ctdb-tests: Add new test support script for script install paths This helps unit tests locate CTDB's scripts. It is being created to support some new shellcheck unit tests. Hopefully, it can also be used to simplify some of the symlink complexity in some other unit tests suites, such as eventscripts. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 355c49fc7469d7a82e507c87250a60d490d112ac Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jul 14 12:58:31 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2006 (legacy `..`) SC2006: Use $(..) instead of legacy `..`. Make the obvious changes to $(...) but convert some to $((...)). Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit dfa2c1d5d205d1281060732547996954fd1b1f02 Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jul 14 12:28:17 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2124 (string=array) SC2124: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit f19f44e0c396a421e9479ef10e2f2ff15fd2e4ec Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jul 14 12:27:05 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2155 (declare, assign) SC2155: Declare and assign separately to avoid masking return values. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit aa5187510f599da9b2dc4f048f37592c1667fbd8 Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jul 14 12:08:04 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2059 ($ in printf format) SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo". Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 8bd2c55f98e3fe337d762e01974f877b885fd8ab Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 13 11:50:58 2016 +1000 ctdb-scripts: Avoid chellcheck warning SC2012 (ls for file list) SC2012: Use find instead of ls to better handle non-alphanumeric filenames. Make this cope better with unexpected whitespace. Unfortunately, this results in shellcheck warning: SC2035: Use ./*.tdb.* so names with dashes won't become options. No! Then stat(1) will print ./file.tdb.X. We want the basenames and we know the filenames don't start with dashes. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 52b43d73e9fb925757d7a033b74c9c74bbcc7d32 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 13 06:53:21 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2012 (ls for file list) SC2012: Use find instead of ls to better handle non-alphanumeric filenames. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 5e9aa57c05da9c22ecb5cecd97ea37693b921ba4 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Jul 12 13:27:08 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2038 (find without -print0) SC2038: Use -print0/-0 or -exec + to allow for non-alphanumeric filenames. The suggested options aren't POSIX-compliant. This is more portable. Base filenames can't have whitespace so rework to avoid problems with whitespace in directory name. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit d138cb8062ddaeb58210138059b53326cced96f6 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Jul 12 12:15:12 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2039 (non-portable ulimit options) SC2039: In POSIX sh, ulimit -c/-n is not supported. Have shellcheck suppress the warnings. If -n is not supported then don't set CTDB_MAX_OPEN_FILES. If packaging for a platform where -c is not supported then remove this code and associated documentation. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit e96c1227908257a9371c11dda99ca3d0fa07208d Author: Martin Schwenke <mar...@meltin.net> Date: Tue Jul 12 11:57:55 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2039 (test -nt operator) SC2039: In POSIX sh, -nt is not supported. This script is specific to the Linux NFS implementation. The -nt operator is well supported in Linux shells (e.g. dash, bash, ksh). The alternatives (e.g. using stat(1)) would result in less readable code. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 524eac92347a8adc6745f0cca04358a6f3fb581f Author: Martin Schwenke <mar...@meltin.net> Date: Mon Jul 11 20:53:56 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2094 (read/write same file) SC2094: Make sure not to read and write the same file in the same pipeline. The semantics here are unclear, so use a separate flock file in each case for clarity. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit d7f3b1977f7c48030062132eb307eb873b338e16 Author: Martin Schwenke <mar...@meltin.net> Date: Thu Jul 7 06:41:27 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2039 (echo -n) SC2039: In POSIX sh, echo flags are not supported. echo -n is well supported but the changes are simple. Improve some logic, replace some instances with printf. Who knew printf was in POSIX? Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit f43df8f0e965902d366ed1e83af57b36614f72d2 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 20:43:29 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2039 (type command) SC2039: In POSIX sh, 'type' is not supported. type is commonly supported and is more portable than which(1). Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit b0c1dbfb8f2bd2743b21a6a77343b2a7940958ce Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 20:40:23 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2015 (A && B || C) SC2015: Note that A && B || C is not if-then-else. C may run when A is true. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 987fd078d267a72ccddd6db2f197b8b30f52041e Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 20:25:57 2016 +1000 ctdb-scripts: Avoid shellcheck warnings SC2119, SC2120 (function arguments) SC2119: Use FUNC "$@" if function's $1 should meanscript's $1. SC2120: FUNC references arguments, but none are ever passed. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 77341f61baa2e90a8935fd16a0775be8eb9005c9 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 20:17:26 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2002 (useless cat) SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit fc858a13e71c30046d35d40b085f172aaa191048 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 20:14:03 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2017 (arithmetic precision) SC2017: Increase precision by replacing a/b*c with a*c/b. This code intentionally rounds to an even value. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 0ca00267cd2620a14968961738bcd2a69b597e95 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 20:09:07 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC1004 (backslash in quotes) SC1004: You don't break lines with \ in single quotes, it results in literal backslash-linefeed. These don't hurt, since awk can cope with the continuations. However, they don't add anything. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit b208ae73d1f65bfd64c343f0396885fa8f5de404 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 17:41:55 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2154 (unassigned variables) SC2154: VAR is referenced but not assigned. Change ctdb_setup_service_state_dir(), ctdb_get_pnn() and ctdb_get_ip_address() to print the value so it can be assigned to a variable. The performance gain from avoiding the sub-shells when calling these functions is close to zero. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 9255d645f3df9d6451ed0f1382c6752b7bec22ff Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 17:31:51 2016 +1000 ctdb-scripts: Avoid shellcheck warnings SC2046, SC2086 (double-quoting) SC2046: Quote this to prevent word splitting. SC2086: Double quote to prevent globbing and word splitting. Add some quoting where it makes sense. Use shellcheck directives for false-positives. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit f6c25a455a62281fd4bf2e3e74cd0ae4233df132 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 17:16:44 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2034 (unused variables) SC2034: VAR appears unused. Verify it or export it. Drop some variables that are unnecessarily used. Use shellcheck directive for false-positives. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 13b3c6af64fb0ac91b47254518287b804ecbef48 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 16:50:30 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2004 ($ in arithmetic) SC2004: $/${} is unnecessary on arithmetic variables. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit efc9af26346621c8fc68c8eb5b16f946d405284c Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 16:13:27 2016 +1000 ctdb-scripts: Avoid shellcheck warnings SC2030, SC2031 (subshell variables) SC2030: Modification of VAR is local (to subshell caused by (..) group). SC2031: VAR was modified in a subshell. That change might be lost. Fix a related, incorrect comment. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 0ea90f61700fad678d6c5166d0f9fff4267f45f9 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 15:22:19 2016 +1000 ctdb-scripts: Avoid shellcheck warning SC2016 ($ in single quotes) SC2016: Expressions don't expand in single quotes, use double quotes for that. Error messages are now arguably more readable. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 113529f05e471673fde8f7a57090470acba0c2e7 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 15:11:43 2016 +1000 ctdb-scripts: Drop function ctdb_check_counter() It is no longer used and adds needless complexity. As a side-effect, the functions file can now be parsed by shellcheck. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 770fe1ff37bb5d3c0407be326ab64fadca71c03e Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 15:06:24 2016 +1000 ctdb-scripts: Drop use of ctdb_check_counter from vsftpd event script This makes the logic more obvious. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 0825eff3e3e1778144789105a9dbb3458f0725e4 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 14:28:06 2016 +1000 ctdb-scripts: Drop use of ctdb_check_counter from reclock event script This makes the logic more obvious. Fix the (probably) accidental fall-through to the regular monitor failure. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 92d0d4489e9dff41b3af419ebdfb71ea15e9ea60 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 14:24:18 2016 +1000 ctdb-scripts: Drop use of ctdb_check_counter from httpd event script This makes the logic more obvious. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit fc53256c3fcd3302746e00762e6d7f876c9b43af Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 14:32:38 2016 +1000 ctdb-scripts: Drop use of service_tcp_ports This makes the logic more obvious. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 09a7a7854ea36056c7bd09cf832d58398492adc1 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 14:44:14 2016 +1000 ctdb-scripts: Event script indentation and whitespace cleanups * Re-indent case labels as per new script style Other indentation can be tweaked later as code changes, but the labels are an obvious bulk change. * Minor whitespace fixes Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit d52409dd952ea7047eadd6524bf5681072802436 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Jul 11 15:04:16 2016 +1000 ctdb-scripts: Drop use of ctdb_standard_event_handler() It doesn't do anything. Add a comment to its definition to explain why it is still there. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 5cf45ede3f2da7efd092738b358c9b34ae070d46 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 13 06:44:08 2016 +1000 ctdb-tests: New event script test for corrupt TDB checking Ensures that backups of corrupt TDB files are correctly limited in number. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 0d60ecf032a47fccf30122af700d8de13d2245fe Author: Martin Schwenke <mar...@meltin.net> Date: Mon Jul 11 14:44:45 2016 +1000 ctdb-tests: Add new httpd event script test Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit ca28a47cb45d42ccec57ff059132b3dfc4706263 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Jul 5 20:10:06 2016 +1000 ctdb-tests: Add new vsftpd event script test Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit c7a730cbc40f2fb81968e0e8fa44d441d825eb7f Author: Martin Schwenke <mar...@meltin.net> Date: Wed Jul 6 14:06:14 2016 +1000 ctdb-tests: Add reclock event script tests Tweak eventscript unit test infrastructure to support. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 91eb421690eade356b0a833ca53d6fadfc3c37ae Author: Martin Schwenke <mar...@meltin.net> Date: Tue Jul 5 20:09:12 2016 +1000 ctdb-scripts: Fix a bug in counter checking If there are insufficient arguments then they can't be shifted. This function will be removed shortly. However, it needs to work for now as tests will be added that depend on it to work. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> ----------------------------------------------------------------------- Summary of changes: ctdb/config/ctdb.init | 10 +- ctdb/config/ctdbd_wrapper | 22 ++- ctdb/config/debug_locks.sh | 21 ++- ctdb/config/events.d/00.ctdb | 23 ++- ctdb/config/events.d/01.reclock | 16 +- ctdb/config/events.d/05.system | 10 +- ctdb/config/events.d/06.nfs | 7 +- ctdb/config/events.d/10.external | 9 +- ctdb/config/events.d/10.interface | 19 +-- ctdb/config/events.d/11.natgw | 27 ++-- ctdb/config/events.d/11.routing | 8 +- ctdb/config/events.d/13.per_ip_routing | 84 +++++----- ctdb/config/events.d/20.multipathd | 19 ++- ctdb/config/events.d/31.clamd | 34 ++--- ctdb/config/events.d/40.vsftpd | 34 ++--- ctdb/config/events.d/41.httpd | 49 +++--- ctdb/config/events.d/49.winbind | 18 +-- ctdb/config/events.d/50.samba | 16 +- ctdb/config/events.d/60.nfs | 39 +++-- ctdb/config/events.d/70.iscsi | 16 +- ctdb/config/events.d/91.lvs | 9 +- ctdb/config/events.d/99.timeout | 7 +- ctdb/config/functions | 170 +++++++++++---------- ctdb/config/nfs-linux-kernel-callout | 2 + ctdb/config/statd-callout | 30 ++-- ctdb/tests/eventscripts/00.ctdb.init.009.sh | 59 +++++++ ...ctdb.setup.001.sh => 01.reclock.monitor.001.sh} | 5 +- ctdb/tests/eventscripts/01.reclock.monitor.002.sh | 10 ++ ...nd.monitor.101.sh => 01.reclock.monitor.003.sh} | 5 +- ctdb/tests/eventscripts/01.reclock.monitor.004.sh | 18 +++ ctdb/tests/eventscripts/01.reclock.monitor.005.sh | 28 ++++ ctdb/tests/eventscripts/40.vsftpd.monitor.002.sh | 20 +++ ctdb/tests/eventscripts/41.httpd.monitor.002.sh | 31 ++++ ctdb/tests/eventscripts/etc/sysconfig/ctdb | 1 - ctdb/tests/eventscripts/scripts/local.sh | 10 ++ ctdb/tests/eventscripts/stubs/df | 15 +- ctdb/tests/run_tests.sh | 2 +- ctdb/tests/scripts/script_install_paths.sh | 21 +++ ctdb/tests/shellcheck/base_scripts.sh | 12 ++ ctdb/tests/shellcheck/ctdb_helpers.sh | 9 ++ ctdb/tests/shellcheck/ctdbd_wrapper.sh | 7 + ctdb/tests/shellcheck/event_scripts.sh | 7 + ctdb/tests/shellcheck/functions.sh | 7 + ctdb/tests/shellcheck/init_script.sh | 20 +++ ctdb/tests/shellcheck/scripts/local.sh | 44 ++++++ ctdb/tests/shellcheck/tools.sh | 9 ++ ctdb/tools/ctdb_diagnostics | 65 ++++---- ctdb/tools/ctdb_natgw | 18 ++- ctdb/tools/onnode | 38 +++-- ctdb/wscript | 9 ++ 50 files changed, 774 insertions(+), 395 deletions(-) create mode 100755 ctdb/tests/eventscripts/00.ctdb.init.009.sh copy ctdb/tests/eventscripts/{00.ctdb.setup.001.sh => 01.reclock.monitor.001.sh} (54%) create mode 100755 ctdb/tests/eventscripts/01.reclock.monitor.002.sh copy ctdb/tests/eventscripts/{49.winbind.monitor.101.sh => 01.reclock.monitor.003.sh} (62%) create mode 100755 ctdb/tests/eventscripts/01.reclock.monitor.004.sh create mode 100755 ctdb/tests/eventscripts/01.reclock.monitor.005.sh create mode 100755 ctdb/tests/eventscripts/40.vsftpd.monitor.002.sh create mode 100755 ctdb/tests/eventscripts/41.httpd.monitor.002.sh create mode 100644 ctdb/tests/scripts/script_install_paths.sh create mode 100755 ctdb/tests/shellcheck/base_scripts.sh create mode 100755 ctdb/tests/shellcheck/ctdb_helpers.sh create mode 100755 ctdb/tests/shellcheck/ctdbd_wrapper.sh create mode 100755 ctdb/tests/shellcheck/event_scripts.sh create mode 100755 ctdb/tests/shellcheck/functions.sh create mode 100755 ctdb/tests/shellcheck/init_script.sh create mode 100644 ctdb/tests/shellcheck/scripts/local.sh create mode 100755 ctdb/tests/shellcheck/tools.sh Changeset truncated at 500 lines: diff --git a/ctdb/config/ctdb.init b/ctdb/config/ctdb.init index 0e0d379..b9c0a6d 100755 --- a/ctdb/config/ctdb.init +++ b/ctdb/config/ctdb.init @@ -60,7 +60,7 @@ pidfile="${CTDB_PIDFILE:-/var/run/ctdb/ctdbd.pid}" start() { - echo -n "Starting ctdbd service: " + printf "Starting ctdbd service: " case "$CTDB_INIT_STYLE" in suse) @@ -85,7 +85,7 @@ start() stop() { - echo -n "Shutting down ctdbd service: " + printf "Shutting down ctdbd service: " case "$CTDB_INIT_STYLE" in suse) @@ -95,6 +95,9 @@ stop() redhat) "$ctdbd_wrapper" "$pidfile" "stop" RETVAL=$? + # Common idiom in Red Hat init scripts - success() always + # succeeds so this does behave like if-then-else + # shellcheck disable=SC2015 [ $RETVAL -eq 0 ] && success || failure echo "" [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb @@ -121,7 +124,8 @@ check_status () # status. Note that this probably won't work if # $CTDB_VALGRIND="yes" but this doesn't need full backward # compatibility because it is a debug option. - if [ -d $(dirname "$pidfile") ] ; then + _d=$(dirname "$pidfile") + if [ -d "$_d" ] ; then _pf_opt="-p $pidfile" else _pf_opt="" diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper index caeb81a..cdf0304 100755 --- a/ctdb/config/ctdbd_wrapper +++ b/ctdb/config/ctdbd_wrapper @@ -62,13 +62,15 @@ ctdbd_is_running () echo "$_pid" # Return value of kill is used - kill -0 $_pid 2>/dev/null + kill -0 "$_pid" 2>/dev/null else # Missing/empty PID file return 1 fi else if _pid=$(pgrep -f "${ctdbd}\>") ; then + # Use word splitting to squash whitespace + # shellcheck disable=SC2086 echo $_pid | sed -e 's@ @,@g' return 0 else @@ -112,6 +114,8 @@ dbdir_tmpfs_stop () fi } +# Only the nested function references its arguments +# shellcheck disable=SC2120 build_ctdb_options () { ctdb_options="" @@ -200,18 +204,24 @@ start() dbdir_tmpfs_start + # build_ctdb_options() takes no arguments + # shellcheck disable=SC2119 build_ctdb_options export_debug_variables + # Explicitly trying to disable core files, no other way + # shellcheck disable=SC2039 if [ "$CTDB_SUPPRESS_COREFILE" = "yes" ]; then ulimit -c 0 else ulimit -c unlimited fi + # Unsupported option easily avoided by not using configuration variable + # shellcheck disable=SC2039 if [ -n "$CTDB_MAX_OPEN_FILES" ]; then - ulimit -n $CTDB_MAX_OPEN_FILES + ulimit -n "$CTDB_MAX_OPEN_FILES" fi _d=$(dirname "$pidfile") @@ -244,7 +254,7 @@ start() _pid="" _timeout="${CTDB_STARTUP_TIMEOUT:-10}" _count=0 - while [ $_count -lt $_timeout ] ; do + while [ "$_count" -lt "$_timeout" ] ; do # If we don't have the PID then try to read it. [ -n "$_pid" ] || read _pid 2>/dev/null <"$pidfile" @@ -263,7 +273,7 @@ start() fi fi - _count=$(($_count + 1)) + _count=$((_count + 1)) sleep 1 done @@ -286,13 +296,13 @@ stop() _timeout=${CTDB_SHUTDOWN_TIMEOUT:-30} _count=0 _terminated=false - while [ $_count -lt $_timeout ] ; do + while [ "$_count" -lt "$_timeout" ] ; do if ! pkill -0 -s "$_session" 2>/dev/null ; then _terminated=true break fi - _count=$(($_count + 1)) + _count=$((_count + 1)) sleep 1 done diff --git a/ctdb/config/debug_locks.sh b/ctdb/config/debug_locks.sh index 62b6799..8c9b466 100755 --- a/ctdb/config/debug_locks.sh +++ b/ctdb/config/debug_locks.sh @@ -24,20 +24,21 @@ loadconfig ctdb echo "===== Start of debug locks PID=$$ =====" - # Create sed expression to convert inodes to names - sed_cmd=$( ls -li "$CTDB_DBDIR"/*.tdb.* "$CTDB_DBDIR_PERSISTENT"/*.tdb.* | - sed -e "s#${CTDB_DBDIR}/\(.*\)#\1#" \ - -e "s#${CTDB_DBDIR_PERSISTENT}/\(.*\)#\1#" | - awk '{printf "s#[0-9a-f]*:[0-9a-f]*:%s #%s #\n", $1, $10}' ) + # Create sed expression to convert inodes to names. + # Filenames don't contain dashes and we want basenames + # shellcheck disable=SC2035 + sed_cmd=$(cd "$CTDB_DBDIR" && + stat -c "s#[0-9a-f]*:[0-9a-f]*:%i #%n #" *.tdb.* 2>/dev/null ; + cd "$CTDB_DBDIR_PERSISTENT" && + stat -c "s#[0-9a-f]*:[0-9a-f]*:%i #%n #" *.tdb.* 2>/dev/null) # Parse /proc/locks and extract following information # pid process_name tdb_name offsets [W] - out=$( cat /proc/locks | - grep -F "POSIX ADVISORY WRITE" | + out=$( grep -F "POSIX ADVISORY WRITE" /proc/locks | awk '{ if($2 == "->") { print $6, $7, $8, $9, "W" } else { print $5, $6, $7, $8 } }' | while read pid rest ; do pname=$(readlink "/proc/${pid}/exe") - echo $pid $pname $rest + echo "$pid $pname $rest" done | sed -e "$sed_cmd" | grep "\.tdb" ) if [ -n "$out" ]; then @@ -51,11 +52,15 @@ loadconfig ctdb pids=$(echo "$out" | grep -v "W$" | grep "$db" | grep -v ctdbd | awk '{print $1}') all_pids="$all_pids $pids" done + # Use word splitting to squash whitespace + # shellcheck disable=SC2086 pids=$(echo $all_pids | tr " " "\n" | sort -u) # For each process waiting, log stack trace for pid in $pids ; do echo "----- Stack trace for PID=$pid -----" + # x is intentionally ignored + # shellcheck disable=SC2034 read x x state x <"/proc/${pid}/stat" if [ "$state" = "D" ] ; then # Don't run gstack on a process in D state since diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index d7b238f..d60b9aa 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -10,10 +10,10 @@ loadconfig -ctdb_setup_service_state_dir "ctdb" - ############################################################ +# type is commonly supported and more portable than which(1) +# shellcheck disable=SC2039 select_tdb_checker () { # Find the best TDB consistency check available. @@ -93,9 +93,12 @@ EOF mv "$_db" "$_backup" # Now remove excess backups - ls -td "${_db}."*".corrupt" | - tail -n +$((${CTDB_MAX_CORRUPT_DB_BACKUPS:-10} + 1)) | - xargs rm -f + _max="${CTDB_MAX_CORRUPT_DB_BACKUPS:-10}" + _bdb="${_db##*/}" # basename + find "$_dir" -name "${_bdb}.*.corrupt" | + sort -r | + tail -n +$((_max + 1)) | + xargs rm -f } done } @@ -121,7 +124,7 @@ set_ctdb_variables () ctdb_check_args "$@" case "$1" in - init) +init) # make sure we have a blank state directory for the scripts to work with rm -rf "$CTDB_SCRIPT_VARDIR" mkdir -p "$CTDB_SCRIPT_VARDIR" || \ @@ -133,19 +136,15 @@ case "$1" in fi ;; - setup) +setup) # Set any tunables from the config file set_ctdb_variables || \ die "Aborting setup due to invalid configuration - fix typos, remove unknown tunables" ;; - startup) +startup) $CTDB attach ctdb.tdb persistent ;; - - *) - ctdb_standard_event_handler "$@" - ;; esac # all OK diff --git a/ctdb/config/events.d/01.reclock b/ctdb/config/events.d/01.reclock index 52e65b9..cceb672 100755 --- a/ctdb/config/events.d/01.reclock +++ b/ctdb/config/events.d/01.reclock @@ -15,7 +15,7 @@ case "$CTDB_RECOVERY_LOCK" in esac case "$1" in - init) +init) ctdb_counter_init if [ -n "$CTDB_RECOVERY_LOCK" ] ; then @@ -24,7 +24,7 @@ case "$1" in fi ;; - monitor) +monitor) # Early exit if not using a reclock file [ -n "$CTDB_RECOVERY_LOCK" ] || exit 0 @@ -38,18 +38,16 @@ case "$1" in ) >/dev/null 2>&1 & ctdb_counter_incr - if ! ctdb_check_counter "quiet" -ge 200 ; then + num_fails=$(ctdb_counter_get) + if [ "$num_fails" -ge 200 ] ; then echo "Reclock file \"$CTDB_RECOVERY_LOCK\" can not be accessed. Shutting down." df sleep 1 $CTDB shutdown + exit 1 + elif [ "$num_fails" -ge 4 ] ; then + die "ERROR: ${num_fails} consecutive failures checking reclock" fi - - ctdb_check_counter "error" -gt 3 - ;; - - *) - ctdb_standard_event_handler "$@" ;; esac diff --git a/ctdb/config/events.d/05.system b/ctdb/config/events.d/05.system index 2dbfca5..3931eac 100755 --- a/ctdb/config/events.d/05.system +++ b/ctdb/config/events.d/05.system @@ -8,7 +8,7 @@ loadconfig -ctdb_setup_service_state_dir "system-monitoring" +service_state_dir=$(ctdb_setup_service_state_dir "system-monitoring") || exit $? validate_percentage () { @@ -135,6 +135,8 @@ monitor_memory_usage () fi _meminfo=$(get_proc "meminfo") + # Intentional word splitting here + # shellcheck disable=SC2046 set -- $(echo "$_meminfo" | awk ' $1 == "MemAvailable:" { memavail += $2 } $1 == "MemFree:" { memfree += $2 } @@ -164,14 +166,10 @@ END { case "$1" in - monitor) +monitor) monitor_filesystem_usage monitor_memory_usage ;; - - *) - ctdb_standard_event_handler "$@" - ;; esac exit 0 diff --git a/ctdb/config/events.d/06.nfs b/ctdb/config/events.d/06.nfs index d0611a5..0ecbb57 100755 --- a/ctdb/config/events.d/06.nfs +++ b/ctdb/config/events.d/06.nfs @@ -6,9 +6,12 @@ . "${CTDB_BASE}/functions" +# service_name is used by various functions +# shellcheck disable=SC2034 service_name="nfs" + loadconfig -ctdb_setup_service_state_dir +service_state_dir=$(ctdb_setup_service_state_dir) || exit $? ###################################################################### @@ -22,7 +25,7 @@ nfs_callout_pre () ###################################################################### -nfs_callout_init +nfs_callout_init "$service_state_dir" ctdb_start_stop_service diff --git a/ctdb/config/events.d/10.external b/ctdb/config/events.d/10.external index 4b22dc7..884357b 100644 --- a/ctdb/config/events.d/10.external +++ b/ctdb/config/events.d/10.external @@ -27,14 +27,15 @@ fi takeover_assigned_ips () { - ctdb_get_pnn + _pnn=$(ctdb_get_pnn) $CTDB -X ip | awk -F'|' '{print $2}' | while read ip ; do - if [ -n "$(ip_maskbits_iface $ip)" ] ; then - echo "Assigning $ip to this node ($pnn)" - $CTDB moveip "$ip" "$pnn" + _ip_details=$(ip_maskbits_iface "$ip") + if [ -n "$_ip_details" ] ; then + echo "Assigning $ip to this node (${_pnn})" + $CTDB moveip "$ip" "$_pnn" fi done } diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface index 9b9a8cd..51abc44 100755 --- a/ctdb/config/events.d/10.interface +++ b/ctdb/config/events.d/10.interface @@ -39,6 +39,8 @@ get_all_interfaces () ctdb_ifaces=$($CTDB -X ifaces | sed -e '1d' -e 's@^|@@' -e 's@|.*@@') # Add $ctdb_interfaces and uniquify + # Use word splitting to squash whitespace + # shellcheck disable=SC2086 all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u) } @@ -84,6 +86,8 @@ get_iface_ip_maskbits () ip="$2" _maskbits_in="$3" + # Intentional word splitting here + # shellcheck disable=SC2046 set -- $(ip_maskbits_iface "$ip") if [ -n "$1" ] ; then maskbits="$1" @@ -138,7 +142,7 @@ ip_unblock () ctdb_check_args "$@" case "$1" in - init) +init) # make sure that we only respond to ARP messages from the NIC where # a particular ip address is associated. get_proc sys/net/ipv4/conf/all/arp_filter >/dev/null 2>&1 && { @@ -154,11 +158,11 @@ case "$1" in drop_all_public_ips ;; - startup) +startup) monitor_interfaces ;; - takeip) +takeip) iface=$2 ip=$3 maskbits=$4 @@ -173,7 +177,7 @@ case "$1" in flush_route_cache ;; - releaseip) +releaseip) # releasing an IP is a bit more complex than it seems. Once the IP # is released, any open tcp connections to that IP on this host will end # up being stuck. Some of them (such as NFS connections) will be unkillable @@ -201,7 +205,7 @@ case "$1" in flush_route_cache ;; - updateip) +updateip) # moving an IP is a bit more complex than it seems. # First we drop all traffic on the old interface. # Then we try to add the ip to the new interface and before @@ -243,12 +247,9 @@ case "$1" in tickle_tcp_connections "$ip" ;; - monitor) +monitor) monitor_interfaces || exit 1 ;; - *) - ctdb_standard_event_handler "$@" - ;; esac exit 0 diff --git a/ctdb/config/events.d/11.natgw b/ctdb/config/events.d/11.natgw index 04eea81..4dc023a 100755 --- a/ctdb/config/events.d/11.natgw +++ b/ctdb/config/events.d/11.natgw @@ -10,6 +10,8 @@ . "${CTDB_BASE}/functions" +# service_name is used by various functions +# shellcheck disable=SC2034 service_name=natgw loadconfig @@ -17,7 +19,7 @@ loadconfig [ -n "$CTDB_NATGW_NODES" ] || exit 0 export CTDB_NATGW_NODES -ctdb_setup_service_state_dir +service_state_dir=$(ctdb_setup_service_state_dir) || exit $? natgw_cfg_new="${service_state_dir}/cfg_new" natgw_cfg_old="${service_state_dir}/cfg_old" @@ -25,9 +27,9 @@ natgw_master_old="${service_state_dir}/master_old" ctdb_natgw_slave_only () { - ctdb_get_ip_address + _ip_address=$(ctdb_get_ip_address) - awk -v my_ip="$ip_address" \ + awk -v my_ip="$_ip_address" \ '$1 == my_ip { if ($2 ~ "slave-only") { exit 0 } else { exit 1 } }' \ "$CTDB_NATGW_NODES" } @@ -155,6 +157,8 @@ natgw_set_slave () natgw_ensure_master () { + # Intentional word splitting here + # shellcheck disable=SC2046 set -- $("${CTDB_HELPER_BINDIR}/ctdb_natgw" master) natgwmaster="${1:--1}" # Default is -1, for failure above -- Samba Shared Repository