Skip to content

Commit

Permalink
Relax ProcessMonitor checks for execute bits
Browse files Browse the repository at this point in the history
This is part one of addressing issue #2714. We avoid
breaking compatibility with the API in this change.

We should rely on the system to do these checks properly.
Since we don't currently have a clean way to signal failure
of execv, we'll assert that the path is a proper file
first.
  • Loading branch information
Brian Mitchell authored and SeanTAllen committed May 26, 2018
1 parent f3a2d9a commit c65534f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
16 changes: 3 additions & 13 deletions packages/process/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,18 @@ class iso _TestNonExecutablePathResultsInExecveError is UnitTest

fun apply(h: TestHelper) =>
try
let path = _setup_file(h)?
let auth = h.env.root as AmbientAuth
let path = FilePath.mkdtemp(auth, "pony_execve_test")?
let args: Array[String] iso = recover Array[String](1) end
let vars: Array[String] iso = recover Array[String](2) end

let auth = h.env.root as AmbientAuth
let notifier = _setup_notifier(h, path)
let pm: ProcessMonitor = ProcessMonitor(auth, auth, consume notifier,
path, consume args, consume vars)
h.dispose_when_done(pm)
h.long_test(30_000_000_000)
else
h.fail("Could not create FilePath!")
h.fail("Could not create temporary FilePath!")
end

fun timed_out(h: TestHelper) =>
Expand Down Expand Up @@ -178,16 +178,6 @@ class iso _TestNonExecutablePathResultsInExecveError is UnitTest
_path.remove()
end end

fun _setup_file(h: TestHelper): FilePath ? =>
let tmp_dir = FilePath(h.env.root as AmbientAuth, "/tmp/")?
let path =
FilePath(h.env.root as AmbientAuth, tmp_dir.path + "/" + Path.random(32))?
let tmp_file = CreateFile(path) as File
let mode = FileMode
mode.any_exec = false
tmp_file.path.chmod(consume mode)
path

class iso _TestExpect is UnitTest
fun name(): String =>
"process/Expect"
Expand Down
5 changes: 3 additions & 2 deletions packages/process/process_monitor.pony
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,13 @@ actor ProcessMonitor
end

let ok = try
FileInfo(filepath)?.mode.any_exec
FileInfo(filepath)?.file
else
false
end
if not ok then
// path is to a non-executable file or that file doesn't exist
// unable to stat the file path given so it may not exist
// or may be a directory.
_notifier.failed(this, ExecveError)
return
end
Expand Down

0 comments on commit c65534f

Please sign in to comment.