Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Improved solution - a login hook' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Improved solution - a login hook
Authored by: Jason209 on May 26, '08 04:46:00PM
As stated prevously, the login items can be bypassed by holding the Shift key. Because of this I have written a login hook based on Joe Mullin's Two factor authentication script. http://techgoesboom.com/archives/2004/09/29/two_factor_authentication_in_os_x.php

! Note: But it doesnt work with filevault.


#!/bin/bash
#
# LoginScreen.sh Log-in hook. Lock the screen during user log-in.
# Requires fast user switching + automatic login - no filevault. Tested on 10.5 Leopard.
#
# Note: The only thing the user sees is a blue screen, interrupted
# by the F.U.S. cube transition effect (blue screen -> blue screen).
#
# To diable the transition (all users) it is necessary to have 2 or more
# user accounts, and set differently the display settings on/for
# one of the accounts. (Either resolution or color depth).
#
# Installation
#
# To install type at the command line:
# sudo defaults write com.apple.loginwindow LoginHook "/path/to/LoginScreen.sh"
#
# To remove: (hold down 's' for single user mode)
# sudo defaults delete com.apple.loginwindow LoginHook 
# sudo rm -rf "/path/to/LoginScreen.sh"
#

thisuser="$1"
lastuser=`defaults read /Library/Preferences/com.apple.loginwindow lastUser`
autologinuser=`defaults read /Library/Preferences/com.apple.loginwindow autoLoginUser`

# Do this to see the state of the loginwindow settings during login
cp /Library/Preferences/com.apple.loginwindow.plist /var/tmp/loginwindow.plist_$thisuser_`date "+%Y-%m-%d--%H:%M:%S"`.plist

if [ "$lastuser" == "loggedIn" ]; 
then
	logger -isf /dev/null "$thisuser $lastuser. First log-in since reboot";
	exit 0;
fi

# if this is the first time
if [ "$lastuser" == "Restart" ]; 
then
	
	if [ "$thisuser" == "$autologinuser" ]; 
	then
	
		# Continue automatic login, but also immediately go to to the "Fast-User Switching" Screen / login screen
		/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend > /dev/null;
		exit 0;
	
	fi
	
else
	logger -isf /dev/null "Already logged-in since reboot";
	exit 0;
fi




Please bear in mind that useing login hooks can render your machine un-usable. To safeguard against such events its recommended to write down the restoration command on a piece of paper. Login hooks are run as root, they can be disabled from single-user mode (press 's' on startup).

This above script is nice under normal circumstances because you dont really notice it and no "second wait" while user account is still loaded.

[ Reply to This | # ]
Improved solution - a login hook
Authored by: janpittner on Dec 01, '09 07:04:48AM

jason209 - nice script, however under Snow Leopard this causes the system to just display a blue screen after you click the 'Already Logged In User' and enter your password (logging into another account, such as the Guest Account, works fine).

Any ideas how to get this working with Snow Leopard?



[ Reply to This | # ]