Triggering GUI login session from daemon? And reboot.
Triggering GUI login session from daemon? And reboot.
- Subject: Triggering GUI login session from daemon? And reboot.
- From: "Mac QA" <email@hidden>
- Date: Tue, 4 Mar 2008 02:23:57 -0500
Hi,
I am writing a system daemon that runs (on a client) in the root
session as invoked by launchd, and there is also a per-user user agent
process in each login session. I communicate with this daemon from a
remote process (on a server) via Cocoa Distributed Objects and I want
to trigger certain actions on the client: reboot, invoke a GUI login
session for user x, perform a fast user switch to user y, start an app
in user y, kill app in user y, logout user y, logout user x, reboot.
This is all for the purpose of automating a test environment.
Currently I have the clients configured to auto-login on boot. So I
can send a message from my server to my system daemon, which forwards
it to a launch agent running in the already logged in user which then
launches an app, or initiates a fast user witch to another user (blank
passwords so the switch completes without human interaction). Can
anyone inform me how to overcome this currently limitation of
requiring one user auto-login on boot? I would like the system daemon
to be able to initiate the GUI login session to the desired user from
the login window without having to auto-login to one user and then
fast user switch to another.
Furthermore, if I have the auto-login scenario described above, and
have a user agent initiate a fast user switch to another user which I
then have the user agent in the second user perform a logout then I
end up back at the login window. So I can no longer send commands to
the system daemon to switch to another user to execute something
without rebooting the whole machine. (Because I can only initiate the
switch from the user agent in the context of the login session.)
Rebooting is not acceptable to me as I may still have a program
running in the remaining logged in user, and only want to initiate
another user session to launch something else. If I can initiate the
GUI login from the login window as asked about above then that will
solve this, but baring that does anyone have any other suggestions for
handling this? (Besides never logging a user out :-)
Finally, I also have some problems with rebooting. I found Apple
Technical Q&A 1134 on the topic, and it was somewhat helpful.
Specifically, I find the note at the bottom regarding running
`shutdown -r now` via an NSTask works well from the system daemon when
there are no logged in users. However, as that article indicates this
method will not work when there is a user logged in. So, my first
intent was to send commands from my system daemon to all of the user
agents to logout, and then initiate the reboot. However some apps are
preventing the logout - mainly when a human user has switched users
and launched something. This I would like to force a reboot just as if
I were at the machine, selected restart from the Apple menu, and
entered my administrator password. I can store the administrator
password in the system daemon process (this is a test environment) so
thats not a big deal, yet I can't seem to figure out how to force a
reboot from the system daemon if there is a user logged in. Any
suggestions?
Thanks!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden