image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old June 21st, 2004, 05:33 AM
Registered User
 
Join Date: Sep 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
floris is on a distinguished road
loginhook

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://userass@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?
Reply With Quote
  #2  
Old June 23rd, 2004, 12:43 AM
TommyWillB's Avatar
Registered User
 
Join Date: Mar 2001
Location: ol' Gay San Francisco
Posts: 2,016
Thanks: 0
Thanked 0 Times in 0 Posts
TommyWillB is on a distinguished road
Can you echo "whoami"?... or will that also show "root"?
__________________
TommyWillB
Intel iMac "early 2006" core duo
TommyWillB.com hosted on Mac OS X 10.5.x / Apache 2.2.x / PHP 5.x
Reply With Quote
  #3  
Old June 23rd, 2004, 03:39 AM
Registered User
 
Join Date: Sep 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
floris is on a distinguished road
Quote:
Originally Posted by TommyWillB
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.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 08:36 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.