Skip to content

Commit

Permalink
Add support for clean fakefs
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Apr 7, 2024
1 parent b659577 commit 504fa2c
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 18 deletions.
23 changes: 23 additions & 0 deletions palera1nLoader/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,29 @@
}
}
},
"Clean FakeFS" : {
"comment" : "On rootful with fakefs, remove jailbreak files without removing fakers",
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Clean FakeFS"
}
}
}
},
"Clean FakeFS Explanation" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Uninstall jailbreak files, but does not remove FakeFS. This will allow setting up a new jailbreak environment without creating FakeFS again."
}
}
}
},
"Credits" : {
"comment" : "✅ Tableview cell and section title for the credits page in the loader",
"extractionState" : "manual",
Expand Down
4 changes: 2 additions & 2 deletions palera1nLoader/Utilities/Download+Install.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ extension Go {
extension Go {

/// Remove environment
static public func restoreSystem() -> Void {
static public func restoreSystem(isCleanFakeFS: Bool) -> Void {
do {
ObliterateJailbreak()
ObliterateJailbreak(isCleanFakeFS: isCleanFakeFS)
ReloadLaunchdJailbreakEnvironment()
}

Expand Down
6 changes: 3 additions & 3 deletions palera1nLoader/View/ManagerActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ extension ViewController {
public func showRestoreAlert(sourceView: UIView) {
var actions: [UIAlertAction] = []

let message = String.localized("Restore System Explanation", arguments: device)
let restoreActionTitle = String.localized("Restore System")
let message = (paleInfo.palerain_option_ssv && paleInfo.palerain_option_rootful) ? String.localized("Clean FakeFS Explanation", arguments: device) : String.localized("Restore System Explanation", arguments: device)
let restoreActionTitle = (paleInfo.palerain_option_ssv && paleInfo.palerain_option_rootful) ? String.localized("Clean FakeFS") : String.localized("Restore System")
let restoreAction = UIAlertAction.customAction(title: restoreActionTitle, style: .destructive) { _ in
Go.restoreSystem()
Go.restoreSystem(isCleanFakeFS: (paleInfo.palerain_option_ssv && paleInfo.palerain_option_rootful))
}
actions.append(restoreAction)

Expand Down
13 changes: 9 additions & 4 deletions palera1nLoader/View/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ extension ViewController: UITableViewDataSource, UITableViewDelegate {
return tableData[section].count
}
if section == 1 {
return (strapValue == .rootless_installed
|| strapValue == .simulated
|| (!paleInfo.palerain_option_ssv && strapValue == .rootful_installed)
return (
strapValue == .rootless_installed
|| strapValue == .simulated
|| strapValue == .rootful_installed
)
? 2
: 1
Expand Down Expand Up @@ -136,7 +137,11 @@ extension ViewController: UITableViewDataSource, UITableViewDelegate {
if row == 0 {
cell.textLabel?.text = .localized("Options")
} else {
cell.textLabel?.text = .localized("Restore System")
if (paleInfo.palerain_option_ssv && paleInfo.palerain_option_rootful) {
cell.textLabel?.text = .localized("Clean FakeFS")
} else {
cell.textLabel?.text = .localized("Restore System")
}
cell.textLabel?.textColor = .systemRed
}
}
Expand Down
4 changes: 2 additions & 2 deletions palera1nLoader/XPC/Wrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func OverwriteFile(destination: String, content: String) -> (Int, String) {
return (Int(retval), result)
}

@discardableResult func ObliterateJailbreak() -> Int {
return Int(ObliterateJailbreak_impl());
@discardableResult func ObliterateJailbreak(isCleanFakeFS: Bool) -> Int {
return Int(ObliterateJailbreak_impl(isCleanFakeFS));
}

func GetPinfoKernelInfo() -> (UInt64, UInt64) {
Expand Down
8 changes: 6 additions & 2 deletions palera1nLoader/XPC/jailbreakd.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ int OverwriteFile_impl(
return retval;
}

int ObliterateJailbreak_impl(void) {
xpc_object_t xreply = jailbreak_send_jailbreakd_command_with_reply_sync(JBD_CMD_OBLITERATE_JAILBREAK);
int ObliterateJailbreak_impl(bool isCleanFakeFS) {
xpc_object_t xdict = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_uint64(xdict, "cmd", JBD_CMD_OBLITERATE_JAILBREAK);
xpc_dictionary_set_bool(xdict, "keep-fakefs", isCleanFakeFS);
xpc_object_t xreply = jailbreak_send_jailbreakd_message_with_reply_sync(xdict);
xpc_release(xdict);
if (xpc_get_type(xreply) == XPC_TYPE_ERROR) return -1;
int error = (int)xpc_dictionary_get_int64(xreply, "error");
xpc_release(xreply);
Expand Down
2 changes: 1 addition & 1 deletion palera1nLoader/XPC/jailbreakd.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int OverwriteFile_impl(
char* _Null_unspecified * _Nonnull result_description
);

int ObliterateJailbreak_impl(void);
int ObliterateJailbreak_impl(bool isCleanFakeFS);
int GetPinfoKernelInfo_impl(uint64_t* kbase, uint64_t* kslide);
int ReloadLaunchdJailbreakEnvironment_impl(void);
int ExitFailureSafeMode_impl(void);
Expand Down
2 changes: 1 addition & 1 deletion palera1nLoaderTV/Other Views/UtilitiesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UtilitiesViewController: UIViewController {
var tableView: UITableView!

var tableData = [
["UICache", "Restart Springboard", "Userspace Reboot"]
["UICache", "Restart PineBoard", "Userspace Reboot"]
]

var sectionTitles = [
Expand Down
7 changes: 4 additions & 3 deletions palera1nLoaderTV/View/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ extension ViewController: UITableViewDataSource, UITableViewDelegate {
return tableData[section].count
}
if section == 1 {
return (strapValue == .rootless_installed
|| strapValue == .simulated
|| (!paleInfo.palerain_option_ssv && strapValue == .rootful_installed)
return (
strapValue == .rootless_installed
|| strapValue == .simulated
|| strapValue == .rootful_installed
)
? 2
: 1
Expand Down

0 comments on commit 504fa2c

Please sign in to comment.