revanced-manager icon indicating copy to clipboard operation
revanced-manager copied to clipboard

fix: Resolve EACCESS error in special cases

Open LemonatedCat opened this issue 1 year ago • 6 comments

Sometimes, when there is an attempt to patch an App, that APK is only marked as r-x and not rwx.

This can cause the patch to fail, as it cannot read the file after copying it to patcher/tmp-.../in.apk

This PR Fixes that issue (as far as i can tell; tested with brand new install of revanced manager, with and without patch. To Verify)

LemonatedCat avatar Aug 11 '24 17:08 LemonatedCat

Cause: Dart/Flutter had no built in permission management system, and the Copy operation of Dart copies the attributes of the original file, including read/write perms.

Why Missing write perms cause File(path) to fail, even when it could have been read-only, i do not know, and it would probably need to be checked in java/kotlin docs.

LemonatedCat avatar Aug 12 '24 15:08 LemonatedCat

FileReader instead of File is probably a better idea.

LemonatedCat avatar Aug 12 '24 15:08 LemonatedCat

Why is Manager copying the file and trying to write to it in the first place?

oSumAtrIX avatar Aug 12 '24 16:08 oSumAtrIX

the "in.apk" is copied to "out.apk". No reading or writing in that case. Could replace the in.apk File with a FoleReader.

Would still need to fix the perms for "out.apk" after patching is complete though

LemonatedCat avatar Aug 12 '24 16:08 LemonatedCat

Why is Manager copying the file and trying to write to it in the first place?

So to answer this, it isn't writing to it at all. Hut java.io.File seems to be unable to open a file unless that file as a write flag set

LemonatedCat avatar Aug 12 '24 16:08 LemonatedCat

Oh, actually, it seems the backtrace was not accurate due to release mode

patcherResult.applyTo(inFile)

This seems to be the culprit, it applies the patches to in.apk, then signs it and spits out out.apk

LemonatedCat avatar Aug 12 '24 16:08 LemonatedCat

pog

LemonatedCat avatar Sep 20 '24 02:09 LemonatedCat