Переглянути джерело

Revert "AMBARI-16810. Ambari Agent security bypassed in Python=>2.7.9 (aonishuk)"

This reverts commit 0cee925319939c38bdbd46cbba1ae49f638127b8.
Sumit Mohanty 9 роки тому
батько
коміт
0c324ca80b

+ 0 - 1
ambari-agent/conf/unix/ambari-agent.ini

@@ -39,7 +39,6 @@ system_resource_overrides=/etc/resource_overrides
 keysdir=/var/lib/ambari-agent/keys
 server_crt=ca.crt
 passphrase_env_var_name=AMBARI_PASSPHRASE
-ssl_verify_cert=0
 
 [services]
 pidLookupPath=/var/run/

+ 1 - 1
ambari-agent/src/main/python/ambari_agent/AmbariConfig.py

@@ -157,7 +157,7 @@ class AmbariConfig:
   def __init__(self):
     global content
     self.config = ConfigParser.RawConfigParser()
-    self.net = NetUtil(self)
+    self.net = NetUtil()
     self.config.readfp(StringIO.StringIO(content))
 
   def get(self, section, value, default=None):

+ 1 - 1
ambari-agent/src/main/python/ambari_agent/Controller.py

@@ -72,7 +72,7 @@ class Controller(threading.Thread):
     self.registerUrl = server_secured_url + '/agent/v1/register/' + self.hostname
     self.heartbeatUrl = server_secured_url + '/agent/v1/heartbeat/' + self.hostname
     self.componentsUrl = server_secured_url + '/agent/v1/components/'
-    self.netutil = NetUtil(self.config, heartbeat_stop_callback)
+    self.netutil = NetUtil(heartbeat_stop_callback)
     self.responseId = -1
     self.repeatRegistration = False
     self.isRegistered = False

+ 2 - 5
ambari-agent/src/main/python/ambari_agent/NetUtil.py

@@ -46,11 +46,10 @@ class NetUtil:
   # Returns true if the application is stopping, false if continuing execution
   stopCallback = None
 
-  def __init__(self, config, stop_callback=None):
+  def __init__(self, stop_callback=None):
     if stop_callback is None:
       stop_callback = HeartbeatStopHandlers()
     self.stopCallback = stop_callback
-    self.config = config
 
   def checkURL(self, url):
     """Try to connect to a given url. Result is True if url returns HTTP code 200, in any other case
@@ -61,12 +60,10 @@ class NetUtil:
     logger.info("Connecting to " + url)
     responseBody = ""
 
-    ssl_verify_cert = self.config.get("security","ssl_verify_cert") != "0"
-
     try:
       parsedurl = urlparse(url)
       
-      if sys.version_info >= (2,7,9) and not ssl_verify_cert:
+      if sys.version_info >= (2,7,9):
           import ssl
           ca_connection = httplib.HTTPSConnection(parsedurl[1], context=ssl._create_unverified_context())
       else:

+ 1 - 1
ambari-agent/src/main/python/ambari_agent/main.py

@@ -329,7 +329,7 @@ def main(heartbeat_stop_callback=None):
         logger.warn("Unable to determine the IP address of the Ambari server '%s'", server_hostname)
 
       # Wait until MAX_RETRIES to see if server is reachable
-      netutil = NetUtil(config, heartbeat_stop_callback)
+      netutil = NetUtil(heartbeat_stop_callback)
       (retries, connected, stopped) = netutil.try_to_connect(server_url, MAX_RETRIES, logger)
 
       # if connected, launch controller