From e537e046d184021a6a41e7580e7911879e870238 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Tue, 7 May 2013 13:20:35 +0100 Subject: [PATCH] Force the inclusion of /usr/local/bin in PATH. Sudo compiled with the --with-secure-path option enabled (default on Ubuntu, Fedora and potentially other distros) will cause sudo to ignore any changes made to the PATH variable in the user's environment (even when the -E option is used). Also, some distros might not have /usr/local/bin set in their sudoers secure_path causing the diskimage-builder to fail when building an image using such distros as host. This patch will force the inclusion of the /usr/local/bin in the PATH enviroment variable inside the chroot. Change-Id: Idb7156d8ff124bfe685cc721337d9bb21f49dc9e Fixes: bug #1175980 --- lib/img-functions | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/img-functions b/lib/img-functions index 557728ce..0edf4177 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -99,8 +99,13 @@ function mount_proc_dev_sys () { # Helper function to run a command inside the chroot function run_in_target () { - # -E to preserve http_proxy - sudo -E chroot $TMP_MOUNT_PATH "$@" + # Force the inclusion of /usr/local/bin in PATH, this is needed for some + # distros that does not include /usr/local/bin in the sudoers secure_path. + # Note that we're not expanding PATH during argument processing, the \$ + # will preserve the PATH syntax until after the sh command runs + cmd="PATH=\$PATH:/usr/local/bin ; $@" + # -E to preserve http_proxy + sudo -E chroot $TMP_MOUNT_PATH sh -c "$cmd" } # Helper function to run a directory of scripts inside the chroot