Uploaded image for project: 'Ambari'
  1. Ambari
  2. AMBARI-18317

ambari-agent script does not check for unset variables. (Leading to chown root:root /)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.4.0
    • 2.4.2
    • ambari-agent
    • None
    • Ubuntu 14.04
      Hortonworks provided package: ambari-agent 4.2.0.1-1

    Description

      Using the following config (unchanged from a previous install, so missing options relevant to 2.4.0.1) with ambari-agent 2.4.0.1 causes the ambari-agent script to chown the entire filesystem as root.

      [logging]
      syslog_enabled=0
      
      [agent]
      ping_port=8670
      data_cleanup_max_size_MB=100
      prefix=/var/lib/ambari-agent/data
      cache_dir=/var/lib/ambari-agent/cache
      tolerate_download_failures=true
      parallel_execution=0
      data_cleanup_interval=86400
      tolerate_download_failuresf=false
      data_cleanup_max_age=2592000
      loglevel=INFO
      run_as_user=root
      
      [server]
      secured_url_port=8441
      hostname=cs-vagrant-hadoop-ambarimaster-01.gel.zone
      url_port=8440
      
      [services]
      pidLookupPath=/var/run/
      
      [heartbeat]
      dirs=/etc/hadoop,/etc/hadoop/conf,/etc/hbase,/etc/hcatalog,/etc/hive,/etc/oozie,/etc/sqoop,/etc/ganglia,/var/run/hadoop,/var/run/zookeeper,/var/run/hbase,/var/run/templeton,/var/run/oozie,/var/log/hadoop,/var/log/zookeeper,/var/log/hbase,/var/run/templeton,/var/log/hive
      log_lines_count=300
      state_interval=6
      
      [security]
      server_crt=ca.crt
      keysdir=/var/lib/ambari-agent/keys
      passphrase_env_var_name=AMBARI_PASSPHRASE
      ryanwalder@ryanwlaptop:~$ vi old 
      ryanwalder@ryanwlaptop:~$ vi old 
      ryanwalder@ryanwlaptop:~$ vi old 
      ryanwalder@ryanwlaptop:~$ cat old 
      [logging]
      syslog_enabled=0
      
      [agent]
      ping_port=8670
      data_cleanup_max_size_MB=100
      prefix=/var/lib/ambari-agent/data
      cache_dir=/var/lib/ambari-agent/cache
      tolerate_download_failures=true
      parallel_execution=0
      data_cleanup_interval=86400
      tolerate_download_failuresf=false
      data_cleanup_max_age=2592000
      loglevel=INFO
      run_as_user=root
      
      [server]
      secured_url_port=8441
      hostname=cs-vagrant-hadoop-ambarimaster-01.gel.zone
      url_port=8440
      
      [services]
      pidLookupPath=/var/run/
      
      [heartbeat]
      dirs=/etc/hadoop,/etc/hadoop/conf,/etc/hbase,/etc/hcatalog,/etc/hive,/etc/oozie,/etc/sqoop,/etc/ganglia,/var/run/hadoop,/var/run/zookeeper,/var/run/hbase,/var/run/templeton,/var/run/oozie,/var/log/hadoop,/var/log/zookeeper,/var/log/hbase,/var/run/templeton,/var/log/hive
      log_lines_count=300
      state_interval=6
      
      [security]
      server_crt=ca.crt
      keysdir=/var/lib/ambari-agent/keys
      passphrase_env_var_name=AMBARI_PASSPHRASE
      

      It looks like the following lines are to blame

              ambari-sudo.sh chown -R $current_user "$AMBARI_PID_DIR/"
              ambari-sudo.sh mkdir -p "$AMBARI_AGENT_LOG_DIR"
              ambari-sudo.sh chown -R $current_user:$current_group "$AMBARI_AGENT_LOG_DIR/"
      

      No checking for unset variables in 2016? Top notch.

      http://www.davidpashley.com/articles/writing-robust-shell-scripts/

      Attachments

        Activity

          People

            aonishuk Andrew Onischuk
            ryanwalder Ryan Walder
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: