[blivet] Allow / in StorageDevice names (#1103751)
David Shea
dshea at redhat.com
Tue Jun 3 13:39:59 UTC 2014
---
blivet/devices.py | 11 ++---------
tests/devices_test.py | 4 ++--
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index cdd0642..24610aa 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -1118,10 +1118,8 @@ class StorageDevice(Device):
@classmethod
def isNameValid(cls, name):
- # This device corresponds to a file in /dev, so no /'s or nulls,
- # and the name cannot be . or ..
- badchars = any(c in ('\x00', '/') for c in name)
- return not(badchars or name == '.' or name == '..')
+ # Allow any character except NUL, disallow . and ..
+ return not('\x00' in name or name == '.' or name == '..')
class DiskDevice(StorageDevice):
""" A local/generic disk.
@@ -4143,11 +4141,6 @@ class FileDevice(StorageDevice):
log_method_call(self, self.name, status=self.status)
os.unlink(self.path)
- @classmethod
- def isNameValid(cls, name):
- # Override StorageDevice.isNameValid to allow /
- return not('\x00' in name or name == '.' or name == '..')
-
class SparseFileDevice(FileDevice):
"""A sparse file on a filesystem.
This exists for sparse disk images."""
diff --git a/tests/devices_test.py b/tests/devices_test.py
index 6598eba..6f6f547 100644
--- a/tests/devices_test.py
+++ b/tests/devices_test.py
@@ -508,8 +508,8 @@ class DeviceNameTestCase(unittest.TestCase):
def testStorageDefvice(self):
# Check that / and NUL are rejected along with . and ..
- good_names = ['sda1', '1sda', 'good-name']
- bad_names = ['sda/1', 'sda\x00', '.', '..']
+ good_names = ['sda1', '1sda', 'good-name', 'sda/1']
+ bad_names = ['sda\x00', '.', '..']
for name in good_names:
self.assertTrue(StorageDevice.isNameValid(name))
--
1.9.0
More information about the anaconda-patches
mailing list