blob: 2ca72a3e4a2e87dd95e5739b7ee8721df7ea51b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/bin/sh
# shellcheck source=conf/default.conf
. "${0%/*}/../conf/default.conf"
if [ "${SSH_ORIGINAL_COMMAND%% *}" = "get-assignment" ] || \
[ "${SSH_ORIGINAL_COMMAND%% *}" = "return-assignment" ]; then
# small check to prevent some shell-injections
if echo "${SSH_ORIGINAL_COMMAND}" | \
grep -q '[^-a-zA-Z0-9.+_ ]'; then
>&2 printf 'Invalid command: "%s".\n' "${SSH_ORIGINAL_COMMAND}"
exit 42
fi
printf '%s %s %s\n' "$(date '+%F %T')" "$1" "${SSH_ORIGINAL_COMMAND}" >> \
"${work_dir}/ssh-log"
# shellcheck disable=SC2016
{
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_command}
slave="$1" /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}"
else
>&2 printf 'Invalid command: "%s".\n' "${SSH_ORIGINAL_COMMAND}"
exit 42
fi
|