Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7C028200B96 for ; Thu, 6 Oct 2016 19:02:26 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7AA60160AEE; Thu, 6 Oct 2016 17:02:26 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CAA2B160AC5 for ; Thu, 6 Oct 2016 19:02:25 +0200 (CEST) Received: (qmail 2980 invoked by uid 500); 6 Oct 2016 17:02:24 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 2966 invoked by uid 99); 6 Oct 2016 17:02:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Oct 2016 17:02:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C2FE8E0200; Thu, 6 Oct 2016 17:02:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dmitriusan@apache.org To: commits@ambari.apache.org Date: Thu, 06 Oct 2016 17:02:25 -0000 Message-Id: <12f35b34c6514436953d6b34600386a6@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/4] ambari git commit: AMBARI-18526. Ambari breaks sudo and user access if Ambari Agent misconfigured (dlysnichenko) archived-at: Thu, 06 Oct 2016 17:02:26 -0000 AMBARI-18526. Ambari breaks sudo and user access if Ambari Agent misconfigured (dlysnichenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/351b8f19 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/351b8f19 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/351b8f19 Branch: refs/heads/branch-2.5 Commit: 351b8f1954db7edf8523698bbb33cc480afc6096 Parents: 8678f46 Author: Lisnichenko Dmitro Authored: Thu Oct 6 19:57:25 2016 +0300 Committer: Lisnichenko Dmitro Committed: Thu Oct 6 19:58:07 2016 +0300 ---------------------------------------------------------------------- ambari-agent/conf/unix/ambari-agent | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/351b8f19/ambari-agent/conf/unix/ambari-agent ---------------------------------------------------------------------- diff --git a/ambari-agent/conf/unix/ambari-agent b/ambari-agent/conf/unix/ambari-agent index ccb0b7a..30897dd 100755 --- a/ambari-agent/conf/unix/ambari-agent +++ b/ambari-agent/conf/unix/ambari-agent @@ -39,6 +39,17 @@ get_agent_property() { echo $value } +valid_path() { + value=${1:?} + value=$(readlink -m ${value}) + if [ "$value" == "/" ]; then + echo "path $1 not valid" 1>&2 + exit 1 + fi + echo $value +} + + export PATH=/usr/sbin:/sbin:/usr/lib/ambari-server/*:$PATH export AMBARI_CONF_DIR=/etc/ambari-server/conf:$PATH @@ -46,8 +57,14 @@ export AMBARI_CONF_DIR=/etc/ambari-server/conf:$PATH export PYTHONPATH=/usr/lib/python2.6/site-packages:${PYTHONPATH:-} export AMBARI_PID_DIR=`get_agent_property piddir` +export AMBARI_PID_DIR=`valid_path "${AMBARI_PID_DIR:?}"` +export AMBARI_PID_DIR="${AMBARI_PID_DIR:?}" export AMBARI_AGENT_LOG_DIR=`get_agent_property logdir` +export AMBARI_AGENT_LOG_DIR=`valid_path "${AMBARI_AGENT_LOG_DIR:?}"` +export AMBARI_AGENT_LOG_DIR="${AMBARI_AGENT_LOG_DIR:?}" KEYSDIR=`get_agent_property keysdir` +KEYSDIR=`valid_path "${KEYSDIR:?}"` +KEYSDIR="${KEYSDIR:?}" AMBARI_AGENT=ambari-agent PYTHON_WRAP=/usr/bin/ambari-python-wrap