Last active
May 14, 2025 06:19
-
-
Save opa334/b14fa4a593bbb79f025cda6113e8b81b to your computer and use it in GitHub Desktop.
Macros to support rootless jailbreaks in your packages (OUTDATED / DEPRECATED)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#include <unistd.h> | |
// Use for NSString literals or variables | |
#define ROOT_PATH_NS(path)([[NSFileManager defaultManager] fileExistsAtPath:path] ? path : [@"/var/jb" stringByAppendingPathComponent:path]) | |
// Use for C string literals | |
#define ROOT_PATH_C(cPath) (access(cPath, F_OK) == 0) ? cPath : "/var/jb" cPath | |
// Use for C string variables | |
// The string returned by this will get freed when your function exits | |
// If you want to keep it, use strdup | |
#define ROOT_PATH_C_VAR(cPath)(ROOT_PATH_NS([NSString stringWithUTF8String:cPath]).fileSystemRepresentation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DO NOT USE THESE MACROS ANYMORE, THEY ARE NOT ONLY THE IMPROPER WAY OF DOING ROOTLESS SUPPORT, THEY CAN ALSO BE COMPLETELY BROKEN IN SOME RARE EDGE CASES.
Use libroot! For this update theos,
#include <libroot.h>
, then use theJBROOT_PATH
macro for all paths (NSString *
,char *
)!!!