From 412c04347440fa5e480b69a07b20ff1399775c5b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 10 Jun 2013 00:42:16 +0000 Subject: Python script auto-execution changes: - script execution is off by default - if a blend file attempts to execute a script this shows a message in the header with the action that was suppressed (script/driver/game-autostart) and 2 buttons to either reload the file trusted, or to ignore the message. - the file selector will always default to use the trust setting in the user preferences, but reloading an open file will keep using the current setting (whatever was set before or set on the command-line). - added SCons setting WITH_BF_PYTHON_SECURITY, this sets the default state for the user prefereces not to trust blend files on load. ... this option was in CMake before, but always off, now its enabled by default for SCons and CMake, and forced on in CMake for now. --- source/blender/python/intern/bpy_interface.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/python/intern/bpy_interface.c') diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 75827ce8bbf..c39168779fd 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -398,6 +398,10 @@ void BPY_python_end(void) void BPY_python_reset(bContext *C) { + /* unrelated security stuff */ + G.f &= ~(G_SCRIPT_AUTOEXEC_FAIL | G_SCRIPT_AUTOEXEC_FAIL_QUIET); + G.autoexec_fail[0] = '\0'; + BPY_driver_reset(); BPY_app_handlers_reset(false); BPY_modules_load_user(C); @@ -725,7 +729,12 @@ void BPY_modules_load_user(bContext *C) for (text = bmain->text.first; text; text = text->id.next) { if (text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name + 2, ".py")) { if (!(G.f & G_SCRIPT_AUTOEXEC)) { - printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name + 2); + if (!(G.f & G_SCRIPT_AUTOEXEC_FAIL_QUIET)) { + G.f |= G_SCRIPT_AUTOEXEC_FAIL; + BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Register Text '%s'", text->id.name + 2); + + printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name + 2); + } } else { PyObject *module = bpy_text_import(text); -- cgit v1.2.3