qusal/salt/sys-ssh-agent/files/server/rpc/qusal.SshAgent
Ben Grande 011a71a36d
style: limit line length per file extension
Editorconfig can only act based on file extension and path, not
attributes, it remains a mean only for multiple collaborators to use the
same configuration on their editor. When it is too restrictive, such as
not considering the file syntax, use a lint tool for the specific file
type instead of trusting editorconfig. Changes were made to increase
readability.
2024-07-09 17:42:07 +02:00

37 lines
879 B
Bash

#!/bin/sh
# SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
set -eu
die(){
echo "error: ${1}" >&2
exit 1
}
untrusted_agent="$QREXEC_SERVICE_ARGUMENT"
if test -z "${untrusted_agent}"; then
die "Agent name is empty"
fi
if ! (echo "${untrusted_agent}" | grep -q "^[A-Za-z0-9][A-Za-z0-9_.-]\+$")
then
msg="Forbidden characters in agent name."
msg="${msg} Allowed chars: letters, numbers, hyphen, underscore and dot."
msg="${msg} Name cannot begin with hyphen, underscore or dot"
die "${msg}"
fi
## Length arbitrarily set.
if test "${#untrusted_agent}" -gt 128; then
die "Repository name is too long: ${#untrusted_agent}"
fi
agent="${untrusted_agent}"
socket="/tmp/qusal-ssh-agent/${agent}.sock"
qvm-ssh-agent add "${agent}" >/dev/null
exec socat STDIO UNIX-CLIENT:"${socket}"