summaryrefslogtreecommitdiff
path: root/bin/slave-build-connect
blob: 84abba1bfdced6a91632e207088cedec491b36fe (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
#!/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

  slave="$1" /bin/sh -c "${base_dir}/bin/${SSH_ORIGINAL_COMMAND}"

else

  >&2 printf 'Invalid command: "%s".\n' "${SSH_ORIGINAL_COMMAND}"
  exit 42

fi