From acea7040bc74a126a0235ab011e3d3bcd7439beb Mon Sep 17 00:00:00 2001 From: Aditya Kali Date: Tue, 23 Aug 2016 18:57:48 -0700 Subject: [PATCH] Add validation for KUBE_USER Malformed KUBE_USER causes error in cluster setup. --- cluster/gce/gci/configure-helper.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cluster/gce/gci/configure-helper.sh b/cluster/gce/gci/configure-helper.sh index 57430cb914..60e5e94610 100644 --- a/cluster/gce/gci/configure-helper.sh +++ b/cluster/gce/gci/configure-helper.sh @@ -755,7 +755,7 @@ function start-kube-apiserver { if [[ -n "${KUBE_USER:-}" ]]; then local -r abac_policy_json="${src_dir}/abac-authz-policy.jsonl" remove-salt-config-comments "${abac_policy_json}" - sed -i -e "s@{{kube_user}}@${KUBE_USER}@g" "${abac_policy_json}" + sed -i -e "s/{{kube_user}}/${KUBE_USER}/g" "${abac_policy_json}" cp "${abac_policy_json}" /etc/srv/kubernetes/ fi @@ -1115,6 +1115,14 @@ if [[ ! -e "${KUBE_HOME}/kube-env" ]]; then fi source "${KUBE_HOME}/kube-env" + +if [[ -n "${KUBE_USER:-}" ]]; then + if ! [[ "${KUBE_USER}" =~ ^[-._@a-zA-Z0-9]+$ ]]; then + echo "Bad KUBE_USER format." + exit 1 + fi +fi + config-ip-firewall create-dirs ensure-local-ssds