Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 364291 | Differences between
and this patch

Collapse All | Expand All

(-)a/source/blender/blenkernel/intern/blender.c (-1 / +2 lines)
Lines 141-147 void initglobals(void) Link Here
141
	G.charmin = 0x0000;
141
	G.charmin = 0x0000;
142
	G.charmax = 0xffff;
142
	G.charmax = 0xffff;
143
	
143
	
144
	G.f |= G_SCRIPT_AUTOEXEC;
144
	G.f &= ~G_SCRIPT_AUTOEXEC;
145
	G.f |= G_SCRIPT_OVERRIDE_PREF;  /* Disables turning G_SCRIPT_AUTOEXEC on from user prefs */
145
}
146
}
146
147
147
/***/
148
/***/
(-)a/source/blender/makesrna/intern/rna_userdef.c (-3 / +13 lines)
Lines 99-107 static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, Point Link Here
99
99
100
static void rna_userdef_script_autoexec_update(Main *bmain, Scene *scene, PointerRNA *ptr)
100
static void rna_userdef_script_autoexec_update(Main *bmain, Scene *scene, PointerRNA *ptr)
101
{
101
{
102
	UserDef *userdef = (UserDef*)ptr->data;
102
	if ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) {
103
	if (userdef->flag & USER_SCRIPT_AUTOEXEC_DISABLE)	G.f &= ~G_SCRIPT_AUTOEXEC;
103
		/* Blender run with --enable-autoexec */
104
	else												G.f |=  G_SCRIPT_AUTOEXEC;
104
		UserDef *userdef = (UserDef*)ptr->data;
105
		if (userdef->flag & USER_SCRIPT_AUTOEXEC_DISABLE)	G.f &= ~G_SCRIPT_AUTOEXEC;
106
		else												G.f |=  G_SCRIPT_AUTOEXEC;
107
	}
108
}
109
110
static int rna_userdef_script_autoexec_editable(Main *bmain, Scene *scene, PointerRNA *ptr) {
111
	/* Disable "Auto Run Python Scripts" checkbox unless Blender run with --enable-autoexec */
112
	return !(G.f & G_SCRIPT_OVERRIDE_PREF);
105
}
113
}
106
114
107
static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr)
115
static void rna_userdef_mipmap_update(Main *bmain, Scene *scene, PointerRNA *ptr)
Lines 2505-2510 static void rna_def_userdef_system(BlenderRNA *brna) Link Here
2505
	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_SCRIPT_AUTOEXEC_DISABLE);
2513
	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_SCRIPT_AUTOEXEC_DISABLE);
2506
	RNA_def_property_ui_text(prop, "Auto Run Python Scripts", "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)");
2514
	RNA_def_property_ui_text(prop, "Auto Run Python Scripts", "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)");
2507
	RNA_def_property_update(prop, 0, "rna_userdef_script_autoexec_update");
2515
	RNA_def_property_update(prop, 0, "rna_userdef_script_autoexec_update");
2516
	/* Disable "Auto Run Python Scripts" checkbox unless Blender run with --enable-autoexec */
2517
	RNA_def_property_editable_func(prop, "rna_userdef_script_autoexec_editable");
2508
2518
2509
	prop= RNA_def_property(srna, "use_tabs_as_spaces", PROP_BOOLEAN, PROP_NONE);
2519
	prop= RNA_def_property(srna, "use_tabs_as_spaces", PROP_BOOLEAN, PROP_NONE);
2510
	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_TXT_TABSTOSPACES_DISABLE);
2520
	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_TXT_TABSTOSPACES_DISABLE);
(-)a/source/blender/windowmanager/intern/wm_files.c (-1 / +6 lines)
Lines 270-280 static void wm_init_userdef(bContext *C) Link Here
270
270
271
	/* set the python auto-execute setting from user prefs */
271
	/* set the python auto-execute setting from user prefs */
272
	/* enabled by default, unless explicitly enabled in the command line which overrides */
272
	/* enabled by default, unless explicitly enabled in the command line which overrides */
273
	if((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) {
273
	if (! G.background && ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0)) {
274
		/* Blender run with --enable-autoexec */
274
		if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |=  G_SCRIPT_AUTOEXEC;
275
		if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |=  G_SCRIPT_AUTOEXEC;
275
		else											  G.f &= ~G_SCRIPT_AUTOEXEC;
276
		else											  G.f &= ~G_SCRIPT_AUTOEXEC;
276
	}
277
	}
277
	if(U.tempdir[0]) BLI_where_is_temp(btempdir, FILE_MAX, 1);
278
	if(U.tempdir[0]) BLI_where_is_temp(btempdir, FILE_MAX, 1);
279
280
	/* Workaround to fix default of "Auto Run Python Scripts" checkbox */
281
	if ((G.f & G_SCRIPT_OVERRIDE_PREF) && !(G.f & G_SCRIPT_AUTOEXEC))
282
		U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
278
}
283
}
279
284
280
void WM_read_file(bContext *C, const char *name, ReportList *reports)
285
void WM_read_file(bContext *C, const char *name, ReportList *reports)
(-)a/source/blender/windowmanager/intern/wm_operators.c (-4 / +12 lines)
Lines 1471-1482 static int wm_open_mainfile_exec(bContext *C, wmOperator *op) Link Here
1471
		G.fileflags &= ~G_FILE_NO_UI;
1471
		G.fileflags &= ~G_FILE_NO_UI;
1472
	else
1472
	else
1473
		G.fileflags |= G_FILE_NO_UI;
1473
		G.fileflags |= G_FILE_NO_UI;
1474
		
1474
1475
	if(RNA_boolean_get(op->ptr, "use_scripts"))
1475
	/* Restrict "Trusted Source" mode to Blender in --enable-autoexec mode */
1476
	if(RNA_boolean_get(op->ptr, "use_scripts") && (!(G.f & G_SCRIPT_OVERRIDE_PREF)))
1476
		G.f |= G_SCRIPT_AUTOEXEC;
1477
		G.f |= G_SCRIPT_AUTOEXEC;
1477
	else
1478
	else
1478
		G.f &= ~G_SCRIPT_AUTOEXEC;
1479
		G.f &= ~G_SCRIPT_AUTOEXEC;
1479
	
1480
1480
	// XXX wm in context is not set correctly after WM_read_file -> crash
1481
	// XXX wm in context is not set correctly after WM_read_file -> crash
1481
	// do it before for now, but is this correct with multiple windows?
1482
	// do it before for now, but is this correct with multiple windows?
1482
	WM_event_add_notifier(C, NC_WINDOW, NULL);
1483
	WM_event_add_notifier(C, NC_WINDOW, NULL);
Lines 1488-1493 static int wm_open_mainfile_exec(bContext *C, wmOperator *op) Link Here
1488
1489
1489
static void WM_OT_open_mainfile(wmOperatorType *ot)
1490
static void WM_OT_open_mainfile(wmOperatorType *ot)
1490
{
1491
{
1492
	PropertyRNA * use_scripts_checkbox = NULL;
1493
1491
	ot->name= "Open Blender File";
1494
	ot->name= "Open Blender File";
1492
	ot->idname= "WM_OT_open_mainfile";
1495
	ot->idname= "WM_OT_open_mainfile";
1493
	ot->description="Open a Blender file";
1496
	ot->description="Open a Blender file";
Lines 1499-1505 static void WM_OT_open_mainfile(wmOperatorType *ot) Link Here
1499
	WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
1502
	WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
1500
1503
1501
	RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file");
1504
	RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file");
1502
	RNA_def_boolean(ot->srna, "use_scripts", 1, "Trusted Source", "Allow blend file execute scripts automatically, default available from system preferences");
1505
	use_scripts_checkbox = RNA_def_boolean(ot->srna, "use_scripts",
1506
			!!(G.f & G_SCRIPT_AUTOEXEC), "Trusted Source",
1507
			"Allow blend file execute scripts automatically, default available from system preferences");
1508
	/* Disable "Trusted Source" checkbox unless Blender run with --enable-autoexec */
1509
	if (use_scripts_checkbox && (G.f & G_SCRIPT_OVERRIDE_PREF))
1510
		RNA_def_property_clear_flag(use_scripts_checkbox, PROP_EDITABLE);
1503
}
1511
}
1504
1512
1505
/* **************** link/append *************** */
1513
/* **************** link/append *************** */
(-)a/source/creator/creator.c (-5 / +6 lines)
Lines 278-283 static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) Link Here
278
278
279
	printf("\n");
279
	printf("\n");
280
280
281
	BLI_argsPrintArgDoc(ba, "-666");
281
	BLI_argsPrintArgDoc(ba, "--enable-autoexec");
282
	BLI_argsPrintArgDoc(ba, "--enable-autoexec");
282
	BLI_argsPrintArgDoc(ba, "--disable-autoexec");
283
	BLI_argsPrintArgDoc(ba, "--disable-autoexec");
283
284
Lines 359-372 static int end_arguments(int UNUSED(argc), const char **UNUSED(argv), void *UNUS Link Here
359
static int enable_python(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
360
static int enable_python(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
360
{
361
{
361
	G.f |= G_SCRIPT_AUTOEXEC;
362
	G.f |= G_SCRIPT_AUTOEXEC;
362
	G.f |= G_SCRIPT_OVERRIDE_PREF;
363
	G.f &= ~G_SCRIPT_OVERRIDE_PREF;  /* Enables turning G_SCRIPT_AUTOEXEC off from user prefs */
363
	return 0;
364
	return 0;
364
}
365
}
365
366
366
static int disable_python(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
367
static int disable_python(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
367
{
368
{
368
	G.f &= ~G_SCRIPT_AUTOEXEC;
369
	G.f &= ~G_SCRIPT_AUTOEXEC;
369
	G.f |= G_SCRIPT_OVERRIDE_PREF;
370
	G.f |= G_SCRIPT_OVERRIDE_PREF;  /* Disables turning G_SCRIPT_AUTOEXEC on from user prefs */
370
	return 0;
371
	return 0;
371
}
372
}
372
373
Lines 1075-1082 static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) Link Here
1075
1076
1076
	BLI_argsAdd(ba, 1, "-v", "--version", "\n\tPrint Blender version and exit", print_version, NULL);
1077
	BLI_argsAdd(ba, 1, "-v", "--version", "\n\tPrint Blender version and exit", print_version, NULL);
1077
1078
1078
	BLI_argsAdd(ba, 1, "-y", "--enable-autoexec", "\n\tEnable automatic python script execution (default)", enable_python, NULL);
1079
	BLI_argsAdd(ba, 1, NULL, "-666", "\n\tEnable automatic python script execution (port from CVE-2009-3850 patch to Blender 2.49b)", enable_python, NULL);
1079
	BLI_argsAdd(ba, 1, "-Y", "--disable-autoexec", "\n\tDisable automatic python script execution (pydrivers, pyconstraints, pynodes)", disable_python, NULL);
1080
	BLI_argsAdd(ba, 1, "-y", "--enable-autoexec", "\n\tEnable automatic python script execution", enable_python, NULL);
1081
	BLI_argsAdd(ba, 1, "-Y", "--disable-autoexec", "\n\tDisable automatic python script execution (pydrivers, pyconstraints, pynodes) (default)", disable_python, NULL);
1080
1082
1081
	BLI_argsAdd(ba, 1, "-b", "--background", "<file>\n\tLoad <file> in background (often used for UI-less rendering)", background_mode, NULL);
1083
	BLI_argsAdd(ba, 1, "-b", "--background", "<file>\n\tLoad <file> in background (often used for UI-less rendering)", background_mode, NULL);
1082
1084
1083
- 

Return to bug 364291