Skip to content

Commit cfd8e39

Browse files
authored
Merge pull request #542 from jkloetzke/fix-path-handling
Fix some path handling
2 parents 8f7a9eb + e9cf324 commit cfd8e39

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎pym/bob/invoker.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,16 @@ async def executeStep(self, mode, clean=False, keepSandbox=False):
364364

365365
# Command follows. Stop parsing options.
366366
cmdArgs.append("--")
367+
368+
# Hard override of PATH. The sandbox helper is found by an absolute path!
369+
env = { "PATH" : ":".join(self.__spec.sandboxPaths) }
367370
else:
368371
cmdArgs = []
372+
env = None
369373
cmdArgs.extend(callArgs)
370374

371375
if mode == InvocationMode.SHELL:
372-
ret = await self.callCommand(cmdArgs, specEnv=False)
376+
ret = await self.callCommand(cmdArgs, env=env, specEnv=False)
373377
elif mode in (InvocationMode.CALL, InvocationMode.UPDATE):
374378
for scm in self.__spec.preRunCmds:
375379
scm = getScm(scm)
@@ -384,7 +388,7 @@ async def executeStep(self, mode, clean=False, keepSandbox=False):
384388
except Exception:
385389
self.error(scm.getSource(), "failed")
386390
raise
387-
await self.checkCommand(cmdArgs, specEnv=False)
391+
await self.checkCommand(cmdArgs, env=env, specEnv=False)
388392
for a in self.__spec.postRunCmds:
389393
a = CheckoutAssert(a)
390394
try:

‎pym/bob/languages.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ def __formatProlog(spec, keepEnv):
258258
env.update({
259259
"PATH": ":".join(
260260
[quote(BashLanguage.__munge(os.path.abspath(p))) for p in spec.paths] +
261-
(["$PATH"] if not spec.hasSandbox else
262-
[quote(p) for p in spec.sandboxPaths])
261+
["$PATH"]
263262
),
264263
"LD_LIBRARY_PATH": ":".join(
265264
quote(BashLanguage.__munge(os.path.abspath(p))) for p in spec.libraryPaths
@@ -342,7 +341,7 @@ def __formatScript(spec, script):
342341
}
343342
declare -A _BOB_SOURCES=( [0]="Bob prolog" )
344343
trap 'bob_handle_error $? >&2 ; exit 99' ERR
345-
trap 'for i in "${_BOB_TMP_CLEANUP[@]-}" ; do /bin/rm -f "$i" ; done' EXIT
344+
trap 'for i in "${_BOB_TMP_CLEANUP[@]-}" ; do command rm -f "$i" ; done' EXIT
346345
set -o errtrace -o nounset -o pipefail
347346
"""),
348347
BashLanguage.__formatSetup(spec),
@@ -495,8 +494,7 @@ def __formatProlog(spec):
495494
env.update({
496495
"PATH": pathSep.join(
497496
[escapePwsh(PwshLanguage.__munge(os.path.abspath(p))) for p in spec.paths] +
498-
(["$Env:PATH"] if not spec.hasSandbox else
499-
[escapePwsh(p) for p in spec.sandboxPaths])
497+
["$Env:PATH"]
500498
),
501499
"LD_LIBRARY_PATH": pathSep.join(
502500
escapePwsh(PwshLanguage.__munge(os.path.abspath(p))) for p in spec.libraryPaths

‎test/black-box/sandbox/recipes/sandbox.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Empty sandbox that mounts the whole host
22
provideSandbox:
3-
paths: []
3+
paths: ["/usr/local/bin", "/usr/local/sbin", "/usr/bin", "/usr/sbin",
4+
"/bin", "/sbin"]
45
mount:
56
- /bin
67
- /etc

‎test/black-box/sandbox/run.sh‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/bin/bash -e
22
. ../../test-lib.sh 2>/dev/null || { echo "Must run in script directory!" ; exit 1 ; }
33

4-
# Run a simple sandbox that mounts the full host. Just see if exeuction works
5-
# even if $PATH is empty in the sandbox.
4+
# Run a simple sandbox that mounts the full host. Just see if exeuction works.
65

76
cleanup
87

0 commit comments

Comments
 (0)