Skip to content

Commit

Permalink
path stuff (im going to bed)
Browse files Browse the repository at this point in the history
  • Loading branch information
Constantin Clerc committed Dec 22, 2023
1 parent b069ccf commit 805d9c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Geranium/DaemonMan/DaemonDisabler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ func daemonManagement(key: String, value: Bool, plistPath: String) {
result = RootHelper.move(from: URL(fileURLWithPath :"/var/mobile/Documents/disabled.plist"), to: URL(fileURLWithPath: plistPath))
print(result)
}

func getDaemonBundleFromPath(path: String) -> String {
return "hey"
}
8 changes: 6 additions & 2 deletions Geranium/DaemonMan/DaemonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct ProcessItem: Identifiable {
let id = UUID()
let pid: String
let procName: String
let procPath: String
}

struct DaemonView: View {
Expand All @@ -19,6 +20,7 @@ struct DaemonView: View {
@State private var timer: Timer?
@State private var toDisable: [String] = []
@State private var manageSheet: Bool = false
@State private var processBundle: String = ""
@AppStorage("isDaemonFirstRun") var isDaemonFirstRun: Bool = true

var filteredProcesses: [ProcessItem] {
Expand Down Expand Up @@ -54,7 +56,7 @@ struct DaemonView: View {
.onDelete { indexSet in
guard let index = indexSet.first else { return }
let process = processes[index]
toDisable.append(process.procName)
toDisable.append(process.procPath)
updateProcesses()
}
}
Expand All @@ -68,6 +70,7 @@ struct DaemonView: View {
Button(action: {
//MARK: Probably the WORST EVER WAY to define a daemon's bundle ID. I'll try over objc s0n
for process in toDisable {
processBundle = getDaemonBundleFromPath(path: process)
UIApplication.shared.confirmAlert(title: "Are you sure you want to disable \(process) ?", body: "You can undo this action before you reboot by going to the manager icon.", onOK: {
daemonManagement(key: "com.apple.\(process)", value: true, plistPath: "/var/db/com.apple.xpc.launchd/disabled.plist")
}, noCancel: false)
Expand Down Expand Up @@ -135,10 +138,11 @@ struct DaemonView: View {
self.processes = rawProcesses?.compactMap { rawProcess in
guard let dict = rawProcess as? NSDictionary,
let pid = dict["pid"] as? String,
let procPath = dict["proc_path"] as? String,
let procName = dict["proc_name"] as? String else {
return nil
}
return ProcessItem(pid: pid, procName: procName)
return ProcessItem(pid: pid, procName: procName, procPath: procPath)
} ?? []
}
}
Expand Down
1 change: 1 addition & 0 deletions Geranium/Libs/SwiftProcessViewer/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <sys/sysctl.h>
#import <mach-o/dyld_images.h>
#import <libgen.h>
#import "delecture.h"

#define PROC_PIDPATHINFO 11
#define PROC_PIDPATHINFO_SIZE (MAXPATHLEN)
Expand Down

0 comments on commit 805d9c0

Please sign in to comment.