[comp.sys.sgi] cron and logins

S090726@UMRVMA.UMR.EDU ("Bob B. Funchess") (11/25/89)

I want to set up a system on our 4D/20 where certain users can only login
at certain times, such as non-prime hours.  The only way I can think of to
do this is to have cron swap /etc/passwd in and out at these times, and
frankly this frightens me a little :).  Does anyone have such a setup?
Will you share your secrets?  You can mail me direct at the address below...


                             < Bob  S090726@UMRVMA.UMR.EDU  Funchess >

mds@mds.sgi.com (Mark D. Stadler) (11/28/89)

In article <8911242042.aa26144@SMOKE.BRL.MIL> S090726@UMRVMA.UMR.EDU ("Bob B. Funchess") writes:
>I want to set up a system on our 4D/20 where certain users can only login
>at certain times, such as non-prime hours.  The only way I can think of to
>do this is to have cron swap /etc/passwd in and out at these times, and
>frankly this frightens me a little :).  Does anyone have such a setup?
>Will you share your secrets?  You can mail me direct at the address below...
>
>
>                             < Bob  S090726@UMRVMA.UMR.EDU  Funchess >

the last field in the /etc/passwd file is the program to exec upon logging
in.  usually this is /bin/sh, /bin/ksh etc...  you could write your own
program that validates users according to the time and kick off the
appropriate shell from there.  (put your validation program name in the
/etc/passwd file with an argument of what to invoke if restrictions don't
inhibit anything further)  it means you have to write your own validation
program, but you can get exactly what you want without hacking too much.

-- mds	[aka Mark D Stadler  mds@sgi.com  ...!uunet!sgi!mds  (415)335-1327]

wiltse@oceana.esd.sgi.com (Wiltse Carpenter) (11/28/89)

In article <8911242042.aa26144@SMOKE.BRL.MIL> S090726@UMRVMA.UMR.EDU ("Bob B. Funchess") writes:
>I want to set up a system on our 4D/20 where certain users can only login
>at certain times, such as non-prime hours.  The only way I can think of to
>do this is to have cron swap /etc/passwd in and out at these times, and
>frankly this frightens me a little :).  Does anyone have such a setup?
>Will you share your secrets?  You can mail me direct at the address below...
>
>
>                             < Bob  S090726@UMRVMA.UMR.EDU  Funchess >

Some of the solutions suggested here could have ill effects if the
user was logged in at the time change.  A solution that doesn't
require and funny cron entries would be to write a program that
performs the time checking and use it as a predicate in the /etc/profile
and /etc/cshrc files.  For instance, in /etc/profile do something
like:

if check_login_time
then
	echo "This is not a good time to log in.  Try again later."
	sleep 20
	exit 0
fi

The /etc/profile and /etc/cshrc are shell scripts that are executed
by /bin/sh and /bin/csh whenever a user first logs in (or does an
su - user).  This is a better place to put this sort of thing than
changing /etc/passwd on the fly (which has many, many potential
pitfalls).

	-Wiltse Carpenter