Currently the existence of mount.nfs is checked by executing
the relative binary 'mount.nfs' with a non-root user,
in this case cinder. This results, for example on SUSE, in the error:
NfsException: mount.nfs is not installed
Because mount.nfs is located under /sbin, unprivileged users
do not have /sbin in their PATH to search for executables.
The change runs the mount.nfs check by using the absolute binary
path /sbin/mount.nfs. This seems to be common for most distributions
(SUSE, RedHat, CentOS, Ubuntu, Debian). The check can still be executed
as non privileged user, by not relying on correctly set PATH variable
and using the absolute path.
Change-Id: I3c1ecfdadd9ea492d58d69cbdf33045b002668c7
Closes-Bug: #
1510150
errno.ENOENT, 'No such file or directory.')
with self.assertRaisesRegex(exception.NfsException,
- 'mount.nfs is not installed'):
+ '/sbin/mount.nfs is not installed'):
drv.do_setup(self.context)
mock_os_path_exists.assert_has_calls(
[mock.call(self.configuration.nfs_shares_config)])
mock_execute.assert_has_calls(
- [mock.call('mount.nfs',
+ [mock.call('/sbin/mount.nfs',
check_exit_code=False,
run_as_root=False)])
mock_os_path_exists.assert_has_calls(
[mock.call(self.configuration.nfs_shares_config)])
mock_execute.assert_has_calls(
- [mock.call('mount.nfs',
+ [mock.call('/sbin/mount.nfs',
check_exit_code=False,
run_as_root=False)])
self.shares = {} # address : options
- # Check if mount.nfs is installed on this system; note that we don't
- # need to be root to see if the package is installed.
- package = 'mount.nfs'
+ # Check if /sbin/mount.nfs is installed on this system;
+ # note that we don't need to be root, to see if the package
+ # is installed.
+ # We rely on the absolute path /sbin/mount.nfs; this seems to be
+ # common on most distributions (SUSE, RedHat, CentOS, Ubuntu, Debian)
+ # and it does not depend on correct PATH of the executing user,
+ # when trying to find the relative binary.
+ package = '/sbin/mount.nfs'
try:
self._execute(package, check_exit_code=False,
run_as_root=False)