Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!evax!bush From: bush@evax.arl.utexas.edu (Joe Bush) Newsgroups: comp.unix.ultrix Subject: Re: global .login for cshrc Keywords: /etc/csh.login Message-ID: <1990Nov1.185247.16196@evax.arl.utexas.edu> Date: 1 Nov 90 18:52:47 GMT References: <3579@vela.acs.oakland.edu> <2800@dali> Organization: Computer Science Engineering Univ. of Texas at Arlington Lines: 95 In article <2800@dali> mathisen@dali.cs.montana.edu (Jaye Mathisen) writes: >In article <3579@vela.acs.oakland.edu> schemers@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@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$$ </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@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