Skip to content

If no NFS ACLs provided, assume everyone #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion drivers/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ def scan_exports(target):
textnode = dom.createTextNode(target)
subentry.appendChild(textnode)

(path, access) = val.split()
# Access is not always provided by showmount return
# If none is provided we need to assume "*"
array = val.split()
path = array[0]
access = array[1] if len(array) >= 2 else "*"
subentry = dom.createElement("Path")
entry.appendChild(subentry)
textnode = dom.createTextNode(path)
Expand Down
30 changes: 30 additions & 0 deletions tests/test_nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,33 @@ def test_validate_nfsversion_valid(self):
for thenfsversion in ['3', '4', '4.1']:
self.assertEquals(nfs.validate_nfsversion(thenfsversion),
thenfsversion)

# Can't use autospec due to http://bugs.python.org/issue17826
@mock.patch('util.pread2')
def test_scan_exports(self, pread2):
pread2.side_effect = ["/srv/nfs\n/srv/nfs2 *\n/srv/nfs3 127.0.0.1/24"]
res = nfs.scan_exports('aServer')

expected = """<?xml version="1.0" ?>
<nfs-exports>
\t<Export>
\t\t<Target>aServer</Target>
\t\t<Path>/srv/nfs</Path>
\t\t<Accesslist>*</Accesslist>
\t</Export>
\t<Export>
\t\t<Target>aServer</Target>
\t\t<Path>/srv/nfs2</Path>
\t\t<Accesslist>*</Accesslist>
\t</Export>
\t<Export>
\t\t<Target>aServer</Target>
\t\t<Path>/srv/nfs3</Path>
\t\t<Accesslist>127.0.0.1/24</Accesslist>
\t</Export>
</nfs-exports>
"""

self.assertEqual(res.toprettyxml(), expected)
self.assertEqual(len(pread2.mock_calls), 1)
pread2.assert_called_with(['/usr/sbin/showmount', '--no-headers', '-e', 'aServer'])