loginhook

floris

Registered
situation:
Mac client authenticating using LDAP. Clients have a local Homedirectory.

I want:
I want to log user statistics, when and where users log in.
I created a loginhook:

# user is not admin -> continue
set localadmin = admin
if ( $1 != $localadmin ) then
# ------------------------------------------
# Logging information
# ------------------------------------------
if ( ! -d /private/var/tmp/stats ) then
mkdir /private/var/tmp/stats
endif
mount -t afp afp://user:pass@server/volume /private/var/tmp/stats
set LOGINNAME = `who | awk '{ print $1 }'`
set MAC = `/sbin/ifconfig en0 | /usr/bin/awk '/ether/ { gsub(":", ""); print $2 }'`
# ------------------------------------------
set RIGHTNOW = `date`
echo "login: $LOGINNAME $RIGHTNOW $MAC" >> /private/var/tmp/stats/stats/login.txt
umount -f /private/var/tmp/stats
endif

### Always exit with 0 status
exit 0



logging is OK but the part which is checking who logged in does not work; the only thing found is the user who executed the script, which is root.
So I need to know how to find the UID of the person who logged in.

can you help?
 
TommyWillB said:
Can you echo "whoami"?... or will that also show "root"?

It shows root as well. Maybe it can be done using the command "last" which indicates last logins of users. I going to try this one in a loginhook.
 
Back
Top