Repository: ambari Updated Branches: refs/heads/trunk 960ee94a2 -> 46fbae9eb
AMBARI-9663. Modifying the ambari server to run as a sudo root account prints error on start (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/46fbae9e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/46fbae9e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/46fbae9e Branch: refs/heads/trunk Commit: 46fbae9eb84ab09b6d4cae0e37e9dbde64b2543a Parents: 960ee94 Author: Andrew Onishuk <[email protected]> Authored: Mon Feb 16 21:03:29 2015 +0200 Committer: Andrew Onishuk <[email protected]> Committed: Mon Feb 16 21:03:29 2015 +0200 ---------------------------------------------------------------------- ambari-server/src/main/python/ambari_server_main.py | 14 +++++++++----- ambari-server/src/test/python/TestAmbariServer.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/46fbae9e/ambari-server/src/main/python/ambari_server_main.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari_server_main.py b/ambari-server/src/main/python/ambari_server_main.py index 6bd4f19..4d47e5c 100644 --- a/ambari-server/src/main/python/ambari_server_main.py +++ b/ambari-server/src/main/python/ambari_server_main.py @@ -213,28 +213,32 @@ def generate_child_process_param_list(ambari_user, current_user, java_exe, class command_base = SERVER_START_CMD_DEBUG if debug_start else SERVER_START_CMD - command = "%s %s; %s" % (ULIMIT_CMD, str(get_ulimit_open_files(properties)), - command_base.format(java_exe, + ulimit_cmd = "%s %s" % (ULIMIT_CMD, str(get_ulimit_open_files(properties))) + command = command_base.format(java_exe, ambari_provider_module_option, jvm_args, class_path, configDefaults.SERVER_OUT_FILE, os.path.join(configDefaults.PID_DIR, EXITCODE_NAME), suspend_mode) - ) # required to start properly server instance os.chdir(configDefaults.ROOT_FS_PATH) #For properly daemonization server should be started using shell as parent + param_list = [locate_file('sh', '/bin'), "-c"] if is_root() and ambari_user != "root": # To inherit exported environment variables (especially AMBARI_PASSPHRASE), # from subprocess, we have to skip --login option of su command. That's why # we change dir to / (otherwise subprocess can face with 'permission denied' # errors while trying to list current directory - param_list = [locate_file('su', '/bin'), ambari_user, "-s", locate_file('sh', '/bin'), "-c", command] + cmd = "{ulimit_cmd} ; {su} {ambari_user} -s {sh_shell} -c '{command}'".format(ulimit_cmd=ulimit_cmd, + su=locate_file('su', '/bin'), ambari_user=ambari_user, + sh_shell=locate_file('sh', '/bin'), command=command) else: - param_list = [locate_file('sh', '/bin'), "-c", command] + cmd = "{ulimit_cmd} ; {command}".format(ulimit_cmd=ulimit_cmd, command=command) + + param_list.append(cmd) return param_list @OsFamilyFuncImpl(OSConst.WINSRV_FAMILY) http://git-wip-us.apache.org/repos/asf/ambari/blob/46fbae9e/ambari-server/src/test/python/TestAmbariServer.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py index 075477b..62e462f 100644 --- a/ambari-server/src/test/python/TestAmbariServer.py +++ b/ambari-server/src/test/python/TestAmbariServer.py @@ -3477,7 +3477,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV self.assertTrue(chdir_mock.called) self.assertTrue(popenMock.called) popen_arg = popenMock.call_args_list[0][0][0] - self.assertTrue(popen_arg[0] == "/bin/su") + self.assertTrue("; /bin/su" in popen_arg[2]) self.assertTrue(perform_housekeeping_mock.called) args = reset_mocks()
