Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uvfs support for CET with MO2 #877

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Conversation

rfuzzo
Copy link
Contributor

@rfuzzo rfuzzo commented Oct 3, 2023

The problem

When launching the game through Mod Organizer 2, CET mods don't work
That is because

  • (1) the luaVM is started too soon (before MO2s virtual file system has started)
  • and (2) because MO2 overlays 3 different directories in its VFS: the base game dir, the virtualized mod dir, and the "overwrite" dir where runtime-created files are stored.

Any mod that creates files at runtime (that is ALL CET mods since the sandbox db gets created at runtime) will fail since the "overwrite" directory escapes the mod sandbox.

This PR

This PR does two things:

  1. It delays the luaVM init slightly so that CET mods get detected after UVFS did its thing
  2. More problematically, it allows lua paths outside the mod sandbox under certain conditions:
  • when the game is launched through MO2 (we detect usvfs_x64.dll)
  • and when the lua path originates from MO2s "overwrite" directory (we detect this by comparing relative paths)

Since GetLuaPath does more checks now, I needed to move it out of utils into sandbox.
This also incurred pulling the sandbox into more lambdas.

Pros and Cons

Pros:

  • It would allow running CET mods from a popular mod manager (MO2)

Cons:

  • We give up some sandbox security under certain conditions. Other script extenders (like Bethesda Script Extenders) seem to find this acceptable.

@rfuzzo
Copy link
Contributor Author

rfuzzo commented Oct 3, 2023

Thinking about the checks a bit more. One simple alternative to the rather complicated path checking in the PR could also be just to get the lexically_relative path between the filePath and the currentDir if uvfs is detected - and for safety we could check the input lua path for "..//".

src/CET.cpp Outdated Show resolved Hide resolved
@WSSDude
Copy link
Collaborator

WSSDude commented Oct 3, 2023

Eh, checking for .. is sketchy, they may be valid cases (like when mod from some of its subfolder does something with parent)

Dont think that is a good solution.

@WSSDude
Copy link
Collaborator

WSSDude commented Oct 3, 2023

And on top, it may appear in the middle of the path potentially and you could still escape

sth/../../yey

@WSSDude
Copy link
Collaborator

WSSDude commented Oct 3, 2023

I think this looks good apart from the few commented out stuff at least on first glance... I'd rather have a more proper look in like an hour though cause cant discern changes to the GetLuaPath as you moved + changed it in same commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants