find_command() is similar to os_dep.command(), but instead of searching $PATH, it searches a few hard coded locations. The problem with searching $PATH is that different users may have different $PATHs. For example, autotest can be executed by a non-root user, or using sudo, and in some OSes this will result in /sbin not being included in $PATH. Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> --- client/tests/kvm/kvm_utils.py | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 0372565..a57a334 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -322,6 +322,15 @@ def env_unregister_vm(env, name): # Utility functions for dealing with external processes +def find_command(cmd): + for dir in ["/usr/local/sbin", "/usr/local/bin", + "/usr/sbin", "/usr/bin", "/sbin", "/bin"]: + file = os.path.join(dir, cmd) + if os.path.exists(file): + return file + raise ValueError('Missing command: %s' % cmd) + + def pid_exists(pid): """ Return True if a given PID exists. -- 1.5.4.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html