From c4cf9a635169cc7d903fc34fe9bd929f42ade127 Mon Sep 17 00:00:00 2001 From: Suhas Satish Date: Wed, 13 Aug 2014 18:33:27 -0700 Subject: [PATCH] Do not hardcode username=hue. Make it configurable from hue.ini --- apps/beeswax/src/beeswax/server/hive_server2_lib.py | 5 +++-- desktop/conf.dist/hue.ini | 4 ++++ desktop/core/src/desktop/conf.py | 11 +++++++++++ desktop/core/src/desktop/settings.py | 4 ++++ desktop/libs/hadoop/src/hadoop/fs/webhdfs.py | 6 +++--- desktop/libs/liboozie/src/liboozie/oozie_api.py | 3 ++- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/apps/beeswax/src/beeswax/server/hive_server2_lib.py b/apps/beeswax/src/beeswax/server/hive_server2_lib.py index fc5338d..b780da5 100644 --- a/apps/beeswax/src/beeswax/server/hive_server2_lib.py +++ b/apps/beeswax/src/beeswax/server/hive_server2_lib.py @@ -22,6 +22,7 @@ from operator import itemgetter from desktop.lib import thrift_util from desktop.conf import LDAP_PASSWORD, LDAP_USERNAME +from desktop.conf import DEFAULT_USER from hadoop import cluster from TCLIService import TCLIService @@ -43,7 +44,7 @@ from impala import conf as impala_conf LOG = logging.getLogger(__name__) IMPALA_RESULTSET_CACHE_SIZE = 'impala.resultset.cache.size' - +DEFAULT_USER = DEFAULT_USER.get() class HiveServerTable(Table): """ @@ -375,7 +376,7 @@ class HiveServerClient: } if self.impersonation_enabled: - kwargs.update({'username': 'hue'}) + kwargs.update({'username': DEFAULT_USER}) if self.query_server['server_name'] == 'impala': # Only when Impala accepts it kwargs['configuration'].update({'impala.doas.user': user.username}) diff --git a/desktop/conf.dist/hue.ini b/desktop/conf.dist/hue.ini index 05d5393..db2c1d8 100644 --- a/desktop/conf.dist/hue.ini +++ b/desktop/conf.dist/hue.ini @@ -45,6 +45,10 @@ # Webserver runs as this user ## server_user=hue ## server_group=hue + # This should be the Hue admin and proxy user + default_user=hue + # This should be the hadoop cluster admin + default_hdfs_superuser=hdfs # If set to false, runcpserver will not actually start the web server. # Used if Apache is being used as a WSGI container. diff --git a/desktop/core/src/desktop/conf.py b/desktop/core/src/desktop/conf.py index 1385712..751902b 100644 --- a/desktop/core/src/desktop/conf.py +++ b/desktop/core/src/desktop/conf.py @@ -392,6 +392,17 @@ SERVER_GROUP = Config( type=str, default="hue") +DEFAULT_USER = Config( + key="default_user", + help=_("This should be the user running hue webserver"), + type=str, + default=None) +DEFAULT_HDFS_SUPERUSER = Config( + key="default_hdfs_superuser", + help=_("This should be the hdfs super user"), + type=str, + default=None) + CUSTOM = ConfigSection( key="custom", help=_("Customizations to the UI."), diff --git a/desktop/core/src/desktop/settings.py b/desktop/core/src/desktop/settings.py index 063ea0d..974771b 100644 --- a/desktop/core/src/desktop/settings.py +++ b/desktop/core/src/desktop/settings.py @@ -310,6 +310,10 @@ EMAIL_HOST_PASSWORD = desktop.conf.SMTP.PASSWORD.get() EMAIL_USE_TLS = desktop.conf.SMTP.USE_TLS.get() DEFAULT_FROM_EMAIL = desktop.conf.SMTP.DEFAULT_FROM.get() +# DEFAULT_USER and DEFAULT_WEBHDFS_USER used in webhdfs.py +DEFAULT_HDFS_SUPERUSER = desktop.conf.DEFAULT_HDFS_SUPERUSER.get() +DEFAULT_USER = desktop.conf.DEFAULT_USER.get() + # Used for securely creating sessions. Should be unique and not shared with anybody. SECRET_KEY = desktop.conf.SECRET_KEY.get() if SECRET_KEY == "": diff --git a/desktop/libs/hadoop/src/hadoop/fs/webhdfs.py b/desktop/libs/hadoop/src/hadoop/fs/webhdfs.py index 1144497..eb45d78 100644 --- a/desktop/libs/hadoop/src/hadoop/fs/webhdfs.py +++ b/desktop/libs/hadoop/src/hadoop/fs/webhdfs.py @@ -36,9 +36,9 @@ from hadoop.fs.webhdfs_types import WebHdfsStat, WebHdfsContentSummary from hadoop.conf import UPLOAD_CHUNK_SIZE import hadoop.conf +import desktop.conf - -DEFAULT_HDFS_SUPERUSER = 'hdfs' +DEFAULT_HDFS_SUPERUSER = desktop.conf.DEFAULT_HDFS_SUPERUSER.get() # The number of bytes to read if not specified DEFAULT_READ_SIZE = 1024*1024 # 1MB @@ -50,7 +50,7 @@ class WebHdfs(Hdfs): """ WebHdfs implements the filesystem interface via the WebHDFS rest protocol. """ - DEFAULT_USER = 'hue' # This should be the user running Hue + DEFAULT_USER = desktop.conf.DEFAULT_USER.get() # This should be the user running Hue TRASH_CURRENT = 'Current' def __init__(self, url, diff --git a/desktop/libs/liboozie/src/liboozie/oozie_api.py b/desktop/libs/liboozie/src/liboozie/oozie_api.py index 189b4f6..6bde145 100644 --- a/desktop/libs/liboozie/src/liboozie/oozie_api.py +++ b/desktop/libs/liboozie/src/liboozie/oozie_api.py @@ -20,6 +20,7 @@ import threading from desktop.conf import TIME_ZONE +from desktop.conf import DEFAULT_USER from desktop.lib.rest.http_client import HttpClient from desktop.lib.rest.resource import Resource @@ -31,7 +32,7 @@ from liboozie.utils import config_gen LOG = logging.getLogger(__name__) -DEFAULT_USER = 'hue' +DEFAULT_USER = DEFAULT_USER.get() API_VERSION = 'v1' # Overridden to v2 for SLA _XML_CONTENT_TYPE = 'application/xml;charset=UTF-8' -- 1.8.5.2 (Apple Git-48)