global .login for cshrc
Joe Bush
bush at evax.arl.utexas.edu
Fri Nov 2 05:52:47 AEST 1990
In article <2800 at dali> mathisen at dali.cs.montana.edu (Jaye Mathisen) writes:
>In article <3579 at vela.acs.oakland.edu> schemers at vela.acs.oakland.edu (Roland Schemers III) writes:
>>1. Have every user be honest and keep a source /etc/csh.login line in their
>> ~/.login. This has the disadvantage that they could remove this line.
>>
>>2. Make everyones ~/.login a symbolic link to /etc/csh.login. The
>
>
>Still has the same problem as 1. A user could remove the .login file, and
>create a new one...
>
>
>
>I too wish it had a global start up file... Many's the time I'd like to
>add a new directory to everybody's path, and other things like that, and
>it's a pain to notify everybody that the should manually add lines...
Me too. I was surprised that the login program does not
provide the system administrator with such a hook. I suspect that
the problem lies in the fact that the login program execs the
shell program, requiring the "hook" to be called from the shell
program which *could* cause nasty side-effects in shell invocations
not intended as interactive.
By coincedence, I was required to make a change in all the
student .logins on my system. I coded up the following shell script to
minimize the pain. It demonstrates one rather simple approach.
- Joe Bush
bush at evax.arl.utexas.edu Vax Systems Manager
(817) 273 - 3333 CSE Dept. UT-Arlington
Office Rm 221 EB2 403 South Cooper
P.O. Box 19015 Arlington, Texas 76019
----------------------------------------------------------------------------
#!/bin/sh
#
# This program demonstrates a method of interating across a set of
# .login file and optionally modifing the defintion of the path variable in
# each file. Much of it is site specific but should illustrate the
# approach. It adds the path /foo/bar/junk to all the .login files
# found in student directories.
# Note the new path is hardcoded in the "here doc." Note that the
# selection of the subset of user accounts is done w/"egerp" at the top
# of the for loop. It works since all student accounts have a home
# directory path of the form /usr/student/.../USERNAME.
#
# - Joe Bush (01-nov-1990)
#
for i in `cat /etc/passwd | cut -d: -f1,6 | egrep "student"`
do
username=`echo $i | cut -d: -f1`
userpath=`echo $i | cut -d: -f2`
echo "--------------------------------------------------------"
echo "Searching for $userpath/.login"
if [ -f $userpath/.login ]
then
if grep -i path $userpath/.login >> /dev/null
then
echo -n "Want to fix this one? [n] "
answer=`line`
if test $answer = "y"
then
echo "Patching $userpath/.login"
cp $userpath/.login $userpath/.login-old
chown $username $userpath/.login-old
cp $userpath/.login /tmp/login-fix$$
#
# add "/foo/bar/junk" to path definition
#
ed - /tmp/login-fix$$ <<EOF 1>/dev/null 2>/dev/null
/^set path/
s/)/ \/foo\/bar\/junk )/
w
q
EOF
cp /tmp/login-fix$$ /$userpath/.login
rm /tmp/login-fix$$
fi
else
echo "User ${username} does not have a .login file."
fi
fi
done
--
bush at evax.arl.utexas.edu Vax Systems Manager
(817) 273 - 3333 CSE Dept. UT-Arlington
Office Rm 221 EB2 403 South Cooper
P.O. Box 19015 Arlington, Texas 76019
More information about the Comp.unix.ultrix
mailing list