Is it possible to run a launch agent as a user with sudo permissions?

خرید بک لینک

I have an executable that needs to run every time a user logs in. It needs to run in the context of that user, but with root permissions, as if the user had run it with sudo.

I have looked through Apple's documentation as well as the website launchd.info for a way to do this, but haven't been able to find anything.

If I create a Launch Agent (in ~/Library/LaunchAgents or /Library/LaunchAgents), or a Launch Daemon with the UserName property set, it runs as the user (as desired), but I cannot do anything that requires elevated privileges.

If I create a Launch Daemon (in /Library/LaunchDaemons) it runs as root (with the desired privileges), but without any user context. If I use su <useame> -c "<command>" or sudo -u <useame> <command> from the Launch Daemon, I can then run a command as the user, but it runs without sudo privileges.

Is there a way to run a launch agent with sudo permissions?

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 291 تاريخ: سه شنبه 12 مرداد 1395 ساعت: 2:19

صفحه بندی