I am currently working on a Mac Application where I need to delete files(potentially malicious) from /Library/LaunchDaemons directory and other similar directories where I would need administrator privileges. Using the FileManager.default.removeItem was not fruitful. I have come across articles pointing me towards EvenBetterAuthorizationSample and SMJobBless and I find the documentation to be rather confusing. Am I on the right track and if so, how should I proceed?
Deleting files using Swift that require admin privileges
327 views Asked by SaudiSheep At
2
There are 2 answers
0
Joshua Kaplan
On
The documentation for SMJobBless is indeed confusing. I've put together the SwiftAuthorizationSample along with a pretty extensive README. So even if the sample isn't quite what you're looking for, hopefully the README will be of some help.
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in ADMIN
- How to install an app with default admin privileges via Inno Tool (or some other setup tool)?
- execute cmd commands as admin with java code
- Change an exe file's compatibility settings with C#
- All of a sudden not working, using linked server to source getting "Communication link failure"
- login and registration page not jump to the dashboard after registration and login proces
- Use sidebar on specific pages
- Set Device Owner
- For versions of solr9 or later, the admin UI cannot be displayed
- How to get the mailbox statistics data for more than 70,000 shared mailboxes in bulk
- Creating a model through the admin panel inside the test
- Oops, looks like the page is lost. This is not a fault, just an accident that was not intentional
- Disable add of related record in Django admin
- Do Shell Script From Apple Script Requires Terminal To Have Full Disk Access - But It Already Has Full Disk Access
- Change programmatically the email for new order, cancelled order and failed order WooCommerce notifications
- How can I find out when the computer shuts down after executing the shutdown command?
Related Questions in DELETE-FILE
- How to swipe and delete
- How to delete files based on timestamp embedded in file name
- Making file manager app in Android Studio and can't write to storage
- Unable to copy file to designated path before its deletion through RecursiveFileObserver
- How can I ask the JVM if a file has been marked for deletion via File.deleteOnExit()?
- GDAL : The process cannot access the file because it is being used by another process
- Problem with recursive deletion of folders with Delphi
- Cannot delete node_modules created via npx create-react-app
- How to delete all subdirectories except a few?
- How to delete camelLock files
- Is it safe to delete an image after creating it with gs and displaying it this way in php?
- AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;
- Xcode delete the photos saved on the document app folder
- Files deleted from VSCode
- Delete files from workspace databricks with Python
Related Questions in NSFILEMANAGER
- swiftui photopicker video is not accessible after rerunning the application
- When .fileImporter is presented the Xcode console shows: "Unknown client: App Name"
- Zip files of a Directory without any root folder
- Downloading from iCloud, files truncated, fine from other sources
- iOS: how to determine if a file is a bundle resource (included in IPA)
- When we try to export CapturedRoom getting cannotCreateNode(path: "/9EE71ED0F8D6415496A7B9F0C3671DB0321") in
- How to create model in Swift?
- What does SearchPathDomainMask mean in Swift?
- How to create a temporary file container, file system, or custom file stream for intercepting clipboard access to temporary files on macOS?
- I cannot access a file I have just saved to my documents directory
- Why is NSFileManager.fileExists(atPath:) Always Returning False?
- How to save data in document directory without replacing previous one
- Swift relativePath property that FileManager.default.enumerator outputs is full path
- Copy image to temp folder but failed to read
- Logging to a file in shared container iOS
Related Questions in SMJOBBLESS
- SMJobBless.py script doesn't work on M1 Macs
- Deleting files using Swift that require admin privileges
- How to embed info.plist in privileged helper for SMJobBless?
- Understanding Priviledged Helper Tools in OSX
- Uninstalling items installed by an .app when user deletes it, including SMJobBless helpers
- Cannot invalidate launchd kextcache from helper executable
- SMJobBless Apple sample code keep asking password
- Gain administration privileges with swift for a Mac Application
- SMJobKit (SMJobBless) BadBundleCodeSigning
- OS X - Truly 'On Demand' Privileged Helper Tool
- Sandboxed app with Helper app
- Apple's SMJobBless() doesn't work under sandbox
- SMJobBless failed with CFErrorDomainLaunchd Code 9
- SMJobBless gives error CFErrorDomainLaunchd Code=8
- Asking for admin privileges for only standard accounts
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
One idea is to look at the
init(authorization:)method of the FileManager. It is available since 10.14. I think it is the easiest way to perform the operation.https://developer.apple.com/documentation/foundation/filemanager/3025773-init
Also, it worth checking if the directories you want to delete are not protected by SIP. In this case on SIP-enabled machines there is no way to remove them.
Good luck!