Excute script only from another file
Steven D'Aprano
steve at pearwood.info
Mon Nov 25 22:09:54 EST 2013
On Mon, 25 Nov 2013 18:28:42 -0800, Rick Johnson wrote:
> On Monday, November 25, 2013 4:52:46 AM UTC-6, Himanshu Garg wrote:
>
>> My motive is "I will give scripts to somebody else and he should not
>> run the script directly without running the parent script".
>
> The only sure fire method to prevent a file containing Python code from
> executing on a machine with Python installed is to
[snip bad advice]
... is to delete Python from the system, or the Python code. Or both.
If Python can read a file, it can exec it.
I suppose you could use file permissions and ACLs to prevent Python from
reading the file, rather than delete it, but given the possibility of
privilege-escalation security vulnerabilities, even that's not sure-fire.
--
Steven
More information about the Python-list
mailing list