Skip to content

Commit

Permalink
disable Sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
LEOYoon-Tsaw committed May 19, 2024
1 parent d094852 commit 7532eb7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
2 changes: 2 additions & 0 deletions Squirrel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = resources/Squirrel.entitlements;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.0.0;
Expand Down Expand Up @@ -645,6 +646,7 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = resources/Squirrel.entitlements;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.0.0;
DEAD_CODE_STRIPPING = YES;
Expand Down
25 changes: 2 additions & 23 deletions resources/Squirrel.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.temporary-exception.shared-preference.read-write</key>
<true/>
<key>com.apple.security.temporary-exception.files.absolute-path.read-write</key>
<array>
<string>/Library/Input Methods/Squirrel.app</string>
</array>
<key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>
<array>
<string>/usr/bin/say</string>
</array>
<key>com.apple.security.temporary-exception.files.home-relative-path.read-write</key>
<array>
<string>/Library/Rime/</string>
</array>
<key>com.apple.security.files.bookmarks.app-scope</key>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<false/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spks</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spki</string>
</array>
</dict>
</plist>
21 changes: 0 additions & 21 deletions sources/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,32 +125,11 @@ struct SquirrelApp {
// finally run everything
app.run()
print("Squirrel is quitting...")
cleanupOldFiles(olderThan: 5)
rimeAPI.finalize()
}
return
}

static func cleanupOldFiles(olderThan days: Int) {
let fileManager = FileManager.default
let currentDate = Date()
let calendar = Calendar.current

do {
let fileURLs = try fileManager.contentsOfDirectory(at: fileManager.temporaryDirectory, includingPropertiesForKeys: [.creationDateKey], options: .skipsHiddenFiles)
for fileURL in fileURLs {
if let creationDate = try fileURL.resourceValues(forKeys: [.creationDateKey]).creationDate {
if let daysDifference = calendar.dateComponents([.day], from: creationDate, to: currentDate).day, daysDifference > days {
try fileManager.removeItem(at: fileURL)
// print("Deleted: \(fileURL.path)")
}
}
}
} catch {
print("Error: \(error.localizedDescription)")
}
}

static let helpDoc = """
Supported arguments:
Perform actions:
Expand Down

0 comments on commit 7532eb7

Please sign in to comment.