#!/bin/sh # shellcheck source=../conf/default.conf . "${0%/*}/../conf/default.conf" if [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xget-assignment' ] || \ [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xreturn-assignment' ] || \ [ "x${SSH_ORIGINAL_COMMAND%% *}" = 'xping-from-slave' ]; then # small check to prevent some shell-injections if printf '%s\n' "${SSH_ORIGINAL_COMMAND}" | \ grep -q '[^-a-zA-Z0-9.+_ ]'; then >&2 printf 'Invalid command: "%s".\n' "${SSH_ORIGINAL_COMMAND}" exit 42 fi # shellcheck disable=SC2016 { printf 'INSERT INTO `ssh_log` (`date`,`build_slave`,`action`,`parameters`)' printf ' SELECT NOW(),`build_slaves`.`id`' printf ',from_base64("%s")' \ "$( print '%s' "${SSH_ORIGINAL_COMMAND%% *}" | \ base64 -w0 )" \ "$( print '%s' "${#* }" | \ base64 -w0 )" printf ' FROM `build_slaves`' printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ "$( printf '%s' "$1" | \ base64 -w0 )" printf 'UPDATE `build_slaves`' printf ' SET `build_slaves`.`last_connection`=NOW()' printf ' WHERE `build_slaves`.`name`=from_base64("%s");\n' \ "$( printf '%s' "$1" | \ base64 -w0 )" } | \ mysql_run_query slave="$1" /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}" else >&2 printf 'Invalid command: "%s".\n' "${SSH_ORIGINAL_COMMAND}" exit 42 fi