From 8f968c3d7faf27b7d765676558fe80ebf331afe0 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Wed, 11 Jun 2014 17:07:03 -0400 Subject: [PATCH] Replace mknod() with chmod() Using mknod() can be troublesome on Macs since the underlying system call requires super-user privileges. Since its main use here is to set the mode of the file (the subsequent call to open() is enough to create it), we remove it and replace it with the less troublesome chmod(). Partial-Bug: #1329077 Change-Id: I30c767792f44d27c6c0179474112015c5ab9bac3 --- ironic/drivers/modules/console_utils.py | 2 +- ironic/tests/drivers/test_console_utils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ironic/drivers/modules/console_utils.py b/ironic/drivers/modules/console_utils.py index abc3ab4960..bf60e9cc7b 100644 --- a/ironic/drivers/modules/console_utils.py +++ b/ironic/drivers/modules/console_utils.py @@ -90,8 +90,8 @@ def make_persistent_password_file(path, password): try: utils.delete_if_exists(path) - os.mknod(path, 0o600) with open(path, 'wb') as file: + os.chmod(path, 0o600) file.write(password) return path except Exception as e: diff --git a/ironic/tests/drivers/test_console_utils.py b/ironic/tests/drivers/test_console_utils.py index 9f9bc4b1d6..fb2ecdf731 100644 --- a/ironic/tests/drivers/test_console_utils.py +++ b/ironic/tests/drivers/test_console_utils.py @@ -121,9 +121,9 @@ class ConsoleUtilsTestCase(base.TestCase): # delete the file os.unlink(filepath) - @mock.patch.object(os, 'mknod', autospec=True) - def test_make_persistent_password_file_fail(self, mock_mknod): - mock_mknod.side_effect = IOError() + @mock.patch.object(os, 'chmod', autospec=True) + def test_make_persistent_password_file_fail(self, mock_chmod): + mock_chmod.side_effect = IOError() filepath = '%(tempdir)s/%(node_uuid)s' % { 'tempdir': tempfile.gettempdir(), 'node_uuid': self.info['uuid']}