Skip to content

Commit a4b1e2f

Browse files
committed
Update filesystem access to specifically target /private/var and restrict navigation above this directory
1 parent 8b3ec6f commit a4b1e2f

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

lara/pe/fileutils.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,16 @@ + (BOOL)enableSandboxAccess:(NSString *)path {
209209
}
210210

211211
+ (BOOL)initializeFilesystemAccess {
212-
NSLog(@"FILE-UTILS: Initializing filesystem access...");
212+
NSLog(@"FILE-UTILS: Initializing filesystem access for /private/var...");
213213

214-
// Enable access to root directory
215-
// On-demand access will be enabled for each path as it's accessed
216-
if (![self enableSandboxAccessCached:@"/"]) {
217-
NSLog(@"FILE-UTILS: Failed to enable root access");
214+
// Enable access to /private/var specifically with sandbox token
215+
// This grants access to the target directory through sandbox extensions
216+
if (![self enableSandboxAccessCached:@"/private/var"]) {
217+
NSLog(@"FILE-UTILS: Failed to enable /private/var access");
218218
return NO;
219219
}
220220

221-
NSLog(@"FILE-UTILS: Filesystem access initialized (on-demand mode)");
221+
NSLog(@"FILE-UTILS: Filesystem access initialized for /private/var");
222222
return YES;
223223
}
224224

lara/views/FileManagerView.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import SwiftUI
22

33
struct FileManagerView: View {
4-
@State private var currentPath: String = "/"
4+
@State private var currentPath: String = "/private/var"
55
@State private var contents: [FileItem] = []
66
@State private var isLoading: Bool = false
77
@State private var errorMessage: String = ""
@@ -41,7 +41,7 @@ struct FileManagerView: View {
4141
// File list
4242
if !isLoading {
4343
List {
44-
if currentPath != "/" {
44+
if currentPath != "/private/var" {
4545
HStack {
4646
Image(systemName: "arrow.up")
4747
.foregroundColor(.accentColor)
@@ -124,15 +124,23 @@ struct FileManagerView: View {
124124
}
125125

126126
private func goUp() {
127+
// Don't go above /private/var
128+
if currentPath == "/private/var" {
129+
return
130+
}
131+
127132
let components = currentPath.split(separator: "/")
128133
if components.isEmpty {
129134
return
130135
}
131136

132-
if components.count == 1 {
133-
currentPath = "/"
137+
let newPath = "/" + components.dropLast().joined(separator: "/")
138+
139+
// Don't allow going above /private/var
140+
if newPath == "/" {
141+
currentPath = "/private/var"
134142
} else {
135-
currentPath = "/" + components.dropLast().joined(separator: "/")
143+
currentPath = newPath
136144
}
137145

138146
refreshContents()

0 commit comments

Comments
 (0)