"Allow Execution" reloads the wrong file when recovering auto-saved file #85011

Closed
opened 2021-01-24 08:47:28 +01:00 by Sam Brubaker · 16 comments

System Information
Linux 4.4.0-200-lowlatency x86_64

Blender Version
2.91.2 Stable

Short description of error
If an auto-saved file is loaded but untrusted, clicking "Allow Execution" causes Blender to reload the non-autosaved version.

Exact steps for others to reproduce the error

  • In User Prefs, disable "Auto Run Python Scripts".
  • Create a .blend file which contains a registered python script
  • Allow the file to be auto-saved by Blender
  • Recover the auto-saved file in File > Recover > Auto Save
  • Upon loading, the "automatic execution of Python scripts in this file was disabled" prompt will appear.
  • Click "Allow Execution"

This causes Blender drop the auto-saved file and reload the original non-autosaved version of the file!

**System Information** Linux 4.4.0-200-lowlatency x86_64 **Blender Version** 2.91.2 Stable **Short description of error** If an auto-saved file is loaded but untrusted, clicking "Allow Execution" causes Blender to reload the non-autosaved version. **Exact steps for others to reproduce the error** - In User Prefs, disable "Auto Run Python Scripts". - Create a .blend file which contains a registered python script - Allow the file to be auto-saved by Blender - Recover the auto-saved file in File > Recover > Auto Save - Upon loading, the "automatic execution of Python scripts in this file was disabled" prompt will appear. - Click "Allow Execution" # This causes Blender drop the auto-saved file and reload the original non-autosaved version of the file!
Author

Added subscriber: @rocketman

Added subscriber: @rocketman
Member

Added subscriber: @filedescriptor

Added subscriber: @filedescriptor
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Falk David self-assigned this 2021-01-25 11:51:47 +01:00
Member

I can confirm this issue on the latest master. Will investigate.

I can confirm this issue on the latest master. Will investigate.
Member

Added subscriber: @mont29

Added subscriber: @mont29
Member

I know why this is happening now, but not sure how to solve it.

Clicking the "Allow Execution" button will call wm_block_autorun_warning_reload_with_scripts which then will call the WM_OT_revert_mainfile operator with the use_scripts property set to true. So it just reloads the file and allows all scripts to execute. The problem is that WM_OT_revert_mainfile uses BKE_main_blendfile_path(bmain) to get the filename. The autosave saves to a specific filename (see wm_autosave_location) but does not update the bmain->name. So when the autosave is reloaded it loads the wrong file.
In fact the exact same problem can be caused by just loading an autosave via File>Recover>Auto Save... and then trying to reload the file with File>Revert.
This also means that if the original file does no longer exist, the operator will fail.

@mont29 Do you know how we could fix this?

I know why this is happening now, but not sure how to solve it. Clicking the "Allow Execution" button will call `wm_block_autorun_warning_reload_with_scripts` which then will call the `WM_OT_revert_mainfile` operator with the `use_scripts` property set to `true`. So it just reloads the file and allows all scripts to execute. The problem is that `WM_OT_revert_mainfile` uses `BKE_main_blendfile_path(bmain)` to get the filename. The autosave saves to a specific filename (see `wm_autosave_location`) but does not update the `bmain->name`. So when the autosave is reloaded it loads the wrong file. In fact the exact same problem can be caused by just loading an autosave via *File*>*Recover*>*Auto Save...* and then trying to reload the file with *File*>*Revert*. This also means that if the original file does no longer exist, the operator will fail. @mont29 Do you know how we could fix this?
Falk David removed their assignment 2021-01-25 14:36:51 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Not sure, but iirc @ideasman42 was the main dev working on this area? Would be interested to get his input here.

I guess we could forbid allow execution on files that where recovered from auto-save, until they are properly saved back into a regular file? Storing the state that we are currently in 'unsaved auto-saved recovered' status. Or modify revert_mainfile to deal with that specific case?

But I would rather not consider auto-saved recovered files as normal situation, and just prevent reloading those at all?

Not sure, but iirc @ideasman42 was the main dev working on this area? Would be interested to get his input here. I guess we could forbid `allow execution` on files that where recovered from auto-save, until they are properly saved back into a regular file? Storing the state that we are currently in 'unsaved auto-saved recovered' status. Or modify `revert_mainfile` to deal with that specific case? But I would rather not consider auto-saved recovered files as normal situation, and just prevent reloading those at all?
Campbell Barton self-assigned this 2021-01-26 00:59:34 +01:00

This issue was referenced by 7909f70f64

This issue was referenced by 7909f70f64e550633fd381b0875fc5ba21616187

This issue was referenced by d55d95b04d

This issue was referenced by d55d95b04da42f120406678fc47deb00081f7285

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'

(auto-closed when it shouldn't have).

(auto-closed when it shouldn't have).

While this is more related to the newer dialogs, I've written two fixes, but I'm not so happy with either of them.

  • P1914 - holds the action needed to revert, in case it's needed. Currently it's not freed until the window-manager is freed, which isn't so nice (although in practice it's not a much memory).
  • P1915 - uses the operator storage to check how the file was loaded, although it requires those operators to be registered.

I think a better approach would be to extend on P1914, replacing wm_test_autorun_warning with a more generic dynamic callback that runs at the end of the event loop (and removes it's self when no longer needed). Although it seems like overkill for this one-off case.

While this is more related to the newer dialogs, I've written two fixes, but I'm not so happy with either of them. - [P1914](https://archive.blender.org/developer/P1914.txt) - holds the action needed to revert, in case it's needed. Currently it's not freed until the window-manager is freed, which isn't so nice (although in practice it's not a much memory). - [P1915](https://archive.blender.org/developer/P1915.txt) - uses the operator storage to check how the file was loaded, although it requires those operators to be registered. I think a better approach would be to extend on [P1914](https://archive.blender.org/developer/P1914.txt), replacing `wm_test_autorun_warning` with a more generic dynamic callback that runs at the end of the event loop (and removes it's self when no longer needed). Although it seems like overkill for this one-off case.

This issue was referenced by 548d8a397c

This issue was referenced by 548d8a397c39f43459af404170614db6a18ebde1

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#85011
No description provided.