Ad

Launching Executable In C++

- 1 answer

I wish to launch an executable by API call, but I am not sure if one is supposed to check for executable bit using posix APIs before hand. What is best practice in this regard?

Ad

Answer

All Posix APIs you'll use to launch a process (e.g. execve() and friends) will do any and all required filesystem permissions checks in a context that is atomic and secure (and doing so in user space is neither). Best practice is to simply use the syscalls that are available.

As a side note, you can browse the source code of all kinds of tools that invoke the standard fork/exec team you're talking about. For example GNU make. I'm sure there are exceptions somewhere in the wild, but practically speaking I've never seen real software attempt to validate filesystem permissions in user space before calling exec().

Ad
source: stackoverflow.com
Ad