Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when try to write into /Library/LaunchAgents #6

Open
trinhtran-markany opened this issue Feb 28, 2023 · 2 comments
Open

Error when try to write into /Library/LaunchAgents #6

trinhtran-markany opened this issue Feb 28, 2023 · 2 comments

Comments

@trinhtran-markany
Copy link

trinhtran-markany commented Feb 28, 2023

Hi,

I tried to save plist file in global agent by changing userDomainMask -> localDomainMask
let library = try FileManager.default.url(for: .libraryDirectory, in: .localDomainMask, appropriateFor: nil, create: false)

then i got error in macOS Ventura 13.2.1

Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “com.test.plist” in the folder “LaunchAgents”." UserInfo={NSFilePath=/Library/LaunchAgents/com.test.plist, NSUnderlyingError=0x600000d4b870 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}

***Note that my application built with sandbox is off.

Do you have any idea?
Thanks

@rami3l
Copy link

rami3l commented Jul 3, 2023

@trinhtran-markany
I'm just coming by, but I don't think you have the permission to write to /Library as a normal user (you might need sudo or something like that). Hope this helps!

@emorydunn
Copy link
Owner

Hi @trinhtran-markany, I somehow missed when you originally opened the issue, but as mentioned even without being sandboxed you can't write to system directories. I believe you need to create a helper tool which actually writes the data that then gets called with elevated privileges.

There's more information in the Authorization Services docs, but the examples are all Obj-C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants