|
|
Login Programmatically on OS X
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2009
Location: Malta
Status:
Offline
|
|
Hi,
I am new to this forum. I am trying to create a daemon which will send user credentials to the OS X login window. I know that this is possible by means of an AppleScript, but this is giving trouble when logging in for the first time after the MAC is booted. Is there any other way to do this?
Thanks
Alan J. Caruana
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status:
Offline
|
|
I didn't know this was possible with a "Mac". Wouldn't it be a security problem on a "Mac" if you could script the "Mac's" login credentials. There is already an option to auto-login after booting your "Mac".
P.S. Your computer is not a MAC. It's a Mac, which is short for Macintosh.
|
|
|
|
|
|
|
|
|
Moderator
Join Date: Jun 2000
Location: inside 128, north of 90
Status:
Offline
|
|
you mean like remote access?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
AppleScript is pretty useless for working at the loginwindow starting in 10.5, so that method is probably out (could be that interface scripting still works there, but most things crash when they try to access the WindowServer, this is by design).
But I was thinking this over a while ago, and think I came up with a method of doing it, but have never tested it out:
1) Write the appropriate value to /Library/Preferences/com.apple.loginwindow.plist : autoLoginUser
2) Move the appropriately obfuscated password for the user to /private/etc/kcpassword with the correct permissions.
3) Kill the /var/run/com.apple.loginwindow.didRunThisBoot file.
4) Kill the loginwindow process (the one owned by root) and let launchd autostart a new one.
Like I said, I have never tested this, but my thinking is that this will run through the normal process that the loginwindow goes through, and should auto-login the user. Most of this is just good guesswork, but I did have my hands into the API that the loginwindow uses for a project or two, so it is a well educated guess.
If killing that file does not do it, then you might have to setup something to watch the loginwindow process better while it is doing an autologin (there are ways of setting this up with Instruments/dtrace, but I don't know them).
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2009
Location: Malta
Status:
Offline
|
|
you mean like remote access?
Just like a Remote Desktop Session. Similar to VNC, but I need to use a different protocol.
I didn't know this was possible with a "Mac". Wouldn't it be a security problem on a "Mac" if you could script the "Mac's" login credentials. There is already an option to auto-login after booting your "Mac".
Arguably, yes it could be a security problem, but if there is no API, I need to find a way to do it, and I do not know which user wants to login until the user actually connects to the daemon and sends his/her credentials.
AppleScript is pretty useless for working at the loginwindow starting in 10.5....
That's strange, as the only time this method does not work for me is when the Mac has just booted and nobody has logged in, otherwise it works, however thanks for the suggestion. I will try it out and let you know the outcome.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2009
Location: Malta
Status:
Offline
|
|
(
Last edited by ajcaruana; Nov 18, 2009 at 04:53 AM.
Reason: Emptied double entry which occurred because of timeout)
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2009
Location: Malta
Status:
Offline
|
|
larkost,
I tried out your suggestion, but it did not work. Here is what I did:
1. enable auto-login, and reboot. This way I was sure that auto-login was being performed, and the obfuscated password is correct, and in the correct place.
2. killed the file /var/run/com.apple.loginwindow.didRunThisBoot
3. killed the only loginwindown process that was running.
The Mac turned to the loginwindow and did not login again. I also tried logging out before step 2, connecting via SSH to the Mac, and performing steps 2 & 3 via SSH, but the results did not change.
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jul 2002
Status:
Offline
|
|
Originally Posted by ajcaruana
Hi,
I am new to this forum. I am trying to create a daemon which will send user credentials to the OS X login window. I know that this is possible by means of an AppleScript, but this is giving trouble when logging in for the first time after the MAC is booted. Is there any other way to do this?
Thanks
Alan J. Caruana
Can I see the AppleScript you were attempting to use that was giving you problem? I use AppleScript just fine to log in to an entire lab of computers from time to time. Haven't had any problems with it. Here's what I use via ARD's Send Unix Command (as user root):
Code:
osascript -e '
set login to ""
set passwd to ""
tell application "System Events"
keystroke login
delay 1
key down return
delay 1
keystroke passwd
delay 0.5
key down return
end tell'
Change the first instance of "key down return" to "keystroke tab" if you're using the login/passsword prompt instead of the list of users. And of course, insert username and password into the script.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
Originally Posted by ajcaruana
larkost, I tried out your suggestion, but it did not work. Here is what I did:
Like I said, I have never actually implemented this, so I am not too surprised. But that is probably a start of what you have to do to get this going.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|