|
|
@ -16,6 +16,7 @@
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import distutils.spawn
|
|
|
|
import traceback
|
|
|
|
import traceback
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import pipes
|
|
|
|
import pipes
|
|
|
@ -45,6 +46,10 @@ class Connection(object):
|
|
|
|
if not utils.is_executable(chrootsh):
|
|
|
|
if not utils.is_executable(chrootsh):
|
|
|
|
raise errors.AnsibleError("%s does not look like a chrootable dir (/bin/sh missing)" % self.chroot)
|
|
|
|
raise errors.AnsibleError("%s does not look like a chrootable dir (/bin/sh missing)" % self.chroot)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.chroot_cmd = distutils.spawn.find_executable('chroot')
|
|
|
|
|
|
|
|
if not self.chroot_cmd:
|
|
|
|
|
|
|
|
raise errors.AnsibleError("chroot command not found in PATH")
|
|
|
|
|
|
|
|
|
|
|
|
self.runner = runner
|
|
|
|
self.runner = runner
|
|
|
|
self.host = host
|
|
|
|
self.host = host
|
|
|
|
# port is unused, since this is local
|
|
|
|
# port is unused, since this is local
|
|
|
@ -62,12 +67,10 @@ class Connection(object):
|
|
|
|
|
|
|
|
|
|
|
|
# We enter chroot as root so sudo stuff can be ignored
|
|
|
|
# We enter chroot as root so sudo stuff can be ignored
|
|
|
|
|
|
|
|
|
|
|
|
chroot_cmd = '/usr/sbin/chroot'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if executable:
|
|
|
|
if executable:
|
|
|
|
local_cmd = [chroot_cmd, self.chroot, executable, '-c', cmd]
|
|
|
|
local_cmd = [self.chroot_cmd, self.chroot, executable, '-c', cmd]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
local_cmd = '%s "%s" %s' % (chroot_cmd, self.chroot, cmd)
|
|
|
|
local_cmd = '%s "%s" %s' % (self.chroot_cmd, self.chroot, cmd)
|
|
|
|
|
|
|
|
|
|
|
|
vvv("EXEC %s" % (local_cmd), host=self.chroot)
|
|
|
|
vvv("EXEC %s" % (local_cmd), host=self.chroot)
|
|
|
|
p = subprocess.Popen(local_cmd, shell=isinstance(local_cmd, basestring),
|
|
|
|
p = subprocess.Popen(local_cmd, shell=isinstance(local_cmd, basestring),
|
|
|
|