From bed9b9f3f2a8db6d843492f7c4910593bebc4467 Mon Sep 17 00:00:00 2001 From: weiting-chen Date: Mon, 10 Aug 2015 20:55:54 +0800 Subject: [PATCH] Fix bug to run command as root in HDFS driver A complete proposal is like below steps: 1. Assume the HDFS user in manila.conf has the authority to launch hdfs command. 2. Set run_as_root to False if there is no argument by default, all the cases in Manila HDFS Driver don't need be a root to run hdfs command. 3. If root is required, please deliver run_as_root parameter and set it as True Change-Id: I310713c3c1b74ff9990832f61e777cf4c12696fe Closes-Bug: #1481567 --- manila/share/drivers/hdfs/hdfs_native.py | 2 +- manila/tests/share/drivers/hdfs/test_hdfs_native.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manila/share/drivers/hdfs/hdfs_native.py b/manila/share/drivers/hdfs/hdfs_native.py index 9c48b06662..de8d79b88a 100644 --- a/manila/share/drivers/hdfs/hdfs_native.py +++ b/manila/share/drivers/hdfs/hdfs_native.py @@ -107,7 +107,7 @@ class HDFSNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver): def _hdfs_local_execute(self, *cmd, **kwargs): if 'run_as_root' not in kwargs: - kwargs.update({'run_as_root': True}) + kwargs.update({'run_as_root': False}) return utils.execute(*cmd, **kwargs) diff --git a/manila/tests/share/drivers/hdfs/test_hdfs_native.py b/manila/tests/share/drivers/hdfs/test_hdfs_native.py index a7889e99bb..e221e3389b 100644 --- a/manila/tests/share/drivers/hdfs/test_hdfs_native.py +++ b/manila/tests/share/drivers/hdfs/test_hdfs_native.py @@ -358,7 +358,7 @@ class HDFSNativeShareDriverTestCase(test.TestCase): cmd = 'testcmd' self.mock_object(utils, 'execute', mock.Mock(return_value=True)) self._driver._hdfs_local_execute(cmd) - utils.execute.assert_called_once_with(cmd, run_as_root=True) + utils.execute.assert_called_once_with(cmd, run_as_root=False) def test__hdfs_remote_execute(self): self._driver._run_ssh = mock.Mock(return_value=True)