Tim Landscheidt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/235378
Change subject: Tools: Fix quoting in sql script
......................................................................
Tools: Fix quoting in sql script
Currently the sql script calls itself if the requested database name
is not explicitly listed in the script and does not end with "_p". A
lack of quoting causes this to fail if the SQL statement given on the
command line contains wildcards, etc.
This change inlines the logic to append "_p" to the database name if
it does not end with that and thus avoids any quoting issues.
Bug: T75595
Change-Id: I727c743dd21f68ce9e6d32453345744fbfcd21d9
---
M modules/toollabs/files/sql
1 file changed, 5 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/78/235378/1
diff --git a/modules/toollabs/files/sql b/modules/toollabs/files/sql
index df999d8..65f5314 100755
--- a/modules/toollabs/files/sql
+++ b/modules/toollabs/files/sql
@@ -96,22 +96,16 @@
*)
# we don't know what the database is so we check if it exist first
Log "This database name is not known by sql script, fallback to dblist
resolution"
- # lookup from hosts
- if [ `echo "$1" | grep -cE '_p$'` -lt 1 ];then
- Log "Invalid database name, recursive attempt suffixing _p..."
- if ($0 $1_p ${*:2});then
- exit 0
- fi
- echo "Make sure to ask for a db in format of <wiki>_p"
- exit 1
- fi
- db=$1
- server=`echo "$1" | sed 's/_p//' | sed 's/$/.labsdb/'`
+ db="${1%_p}_p"
+ server="${db%_p}.labsdb"
if getent hosts -- "$server" > /dev/null
then
Log "Resolved to $server $db"
else
echo "Could not find requested database"
+ if [ "$db" != "$1" ]; then
+ echo 'Make sure to ask for a db in format of <wiki>_p'
+ fi
exit 1
fi
;;
--
To view, visit https://gerrit.wikimedia.org/r/235378
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I727c743dd21f68ce9e6d32453345744fbfcd21d9
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Tim Landscheidt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits