🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.sysadmin
4 messages
4 total messages Started by Steven T. Dunbar Thu, 19 Nov 1992 19:16
loginwindow hooks- ARGHHHH!!!!
#1882
Author: Steven T. Dunbar
Date: Thu, 19 Nov 1992 19:16
34 lines
1415 bytes
I'm trying to do some accounting of my log in time.

I wrote a login script like this:
#!/bin/csh
echo 'Login :' `/bin/date` >> ~/.worklog

and I wrote a logout script like this:
#!/bin/csh
echo 'Logout :' `/bin/date` >> ~/.worklog

I then did (as root):

dwrite loginwindow LoginHook /usr/local/bin/loginscript
dwrite loginwindow LogoutHook /usr/local/bin/logoutscript

I logged out of the console, used 'exit' to reload the 
loginwindow, logged in, and it doesn't work.

the scripts work just fine from the command line.

I rebooted the machine... still didn't work...

Anyone know why this is failing???

Thanks!!!

Steve
---
____________________________________________________________________________
Steven T. Dunbar                          sdunbar@mailbox.fwrdc.rtsg.mot.com
Development Engineer                      (817) 232-6080

Motorola GSS Cellular Infrastructure Group - Ft. Worth Research & Development
____________________________________________________________________________
Re: loginwindow hooks- ARGHHHH!!!!
#1892
Author: David Lemson
Date: Fri, 20 Nov 1992 08:02
43 lines
2262 bytes
dmm0t@rincewind.mech.Virginia.EDU (David Meyer) writes:

>In article <1992Nov19.191653.29086@schbbs.mot.com>  
>sdunbar@mailbox.fwrdc.rtsg.mot.com (Steven T. Dunbar) writes:
>> I'm trying to do some accounting of my log in time.
>> 
>> I wrote a login script like this:
>> #!/bin/csh
>> echo 'Login :' `/bin/date` >> ~/.worklog
>> 
>> and I wrote a logout script like this:
>> #!/bin/csh
>> echo 'Logout :' `/bin/date` >> ~/.worklog
>> 
>> I then did (as root):
>> 
>> dwrite loginwindow LoginHook /usr/local/bin/loginscript
>> dwrite loginwindow LogoutHook /usr/local/bin/logoutscript
>> 
>> I logged out of the console, used 'exit' to reload the 
>> loginwindow, logged in, and it doesn't work.

>loginwindow gets run by root, not by the user logging in.  Hence,
>loginscript and logoutscript also run as root, so you probably
>have /.worklog (since ~root == /) with the information you're
>looking for.

>I ran into this problem when I wanted to empty the trashcan on logout;
>I couldn't figure out how to communicate the login ID of the person
>exiting to the LogoutHook script.  FYI, I got around that by just
>emptying everybody's trashcan whenever anyone logs out.  It's an ugly
>hack.

The $1 argument to LoginHook is the userid (name) of the user who is
logging in.  I do not think that LogoutHook gets this information
passed to it as well (but would be happy to be proven wrong!  It
would make life simpler).  This is under 2.x, I haven't tried Hooks
in 3.0 yet.
-- 
David Lemson                                                (217) 244-1205
University of Illinois NeXT Campus Consultant / CCSO NeXT Lab System Admin
Internet : lemson@uiuc.edu                UUCP :...!uiucuxc!uiucux1!lemson 
NeXTMail accepted                                  BITNET : LEMSON@UIUCVMD
Re: loginwindow hooks- ARGHHHH!!!!
#1896
Author: Apostolos Lytras
Date: Fri, 20 Nov 1992 13:43
23 lines
1561 bytes
Argghhh.... root runs shellscripts!! DON'T DON'T DON'T! A shellscript
that is run by root *is* a threat to the security of your system and 
possibly of many other systems as well. Especially when it is supposed
to run inattendedly.

Besides, your programs look like a lot of redundancy to me. Every Login
and Logout gets logged (with time, connecting host etc.) in
/usr/adm/wtmp. There is also information about shutdowns, reboots and
crashes in that file. 

You get at least two unix programs to evaluate that file: last, ac. For
details let Librarian.app show you the according man pages.

You can also search the archives (with archie) for a little piece of C
code called 'rdwtmp.c' which gives you yet another view of the login
data in /usr/adm/wtmp.

Cheers
- A.
-- 
	 lytras@ifi.unizh.ch   		|   Apostolos Lytras
	 lytras@avalon.physik.unizh.ch	|   Informatik Club der Uni
	 lytras@amiga.physik.unizh.ch  	|   Zuerich, SysAdmin
Re: loginwindow hooks- ARGHHHH!!!!
#1904
Author: Wade Blomgren
Date: Fri, 20 Nov 1992 21:42
24 lines
1669 bytes
In an article, lemson@ux1.cso.uiuc.edu (David Lemson) writes:
> 
> The $1 argument to LoginHook is the userid (name) of the user who is
> logging in.  I do not think that LogoutHook gets this information
> passed to it as well (but would be happy to be proven wrong!  It
> would make life simpler).  This is under 2.x, I haven't tried Hooks
> in 3.0 yet.

In 2.2, LogoutHook does get the user name passed as $1 (argv[1]).  Further,
the LogoutHook _is_ run as the user...if you want to use it to write
a privileged file, the program will have to be setuid.  Another
poster says that these hooks are not needed since logins are automatically
put in /usr/adm/wtmp.  This is NOT true for console logins (at least in
2.2), so you do need to write your own hooks to handle it.  As stated, 
though, shell scripts are probably not the best idea (but that argument is 
usually directed against _setuid_ shell scripts, not just ordinary shell 
scripts - there are tons of ordinary shell scripts routinely run unattended 
by root.)

I can post the tiny LoginHook and LogoutHook C programs I use to handle
wtmp if anyone cares...

Wade Blomgren
wade@hobbes.ucsd.edu
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads