[comp.unix.ultrix] global .login for cshrc

schemers@vela.acs.oakland.edu (Roland Schemers III) (10/31/90)

Why isn't there a .login/.cshrc which system wide? It appears
there is two ways to create one:

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
   ~/.login file would be owned by root, readable by everyone, writeable
   by no one. The /etc/csh.login would have a last line which was 
   source ~/.userlogin. That way a user could put commands they
   want in a file called .userlogin, which gets called by /etc/csh.login.

Any suggestions? This all stems from the fact that some products require
enviroment variables, we write new commands such as print queue selection
commands that must be alaises so they can set someones env variable. 

Thanx, Roland


-- 
Roland J. Schemers III                              Systems Programmer 
schemers@vela.acs.oakland.edu (Ultrix)              Oakland University 
schemers@argo.acs.oakland.edu (VMS)                 Rochester, MI 48309-4401
~Disclaimer::Disclaimer() { reboot(RB_HALT); }      (313)-370-4323

mathisen@dali.cs.montana.edu (Jaye Mathisen) (11/01/90)

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...

sahayman@iuvax.cs.indiana.edu (Steve Hayman) (11/01/90)

>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...

One way out is to have a path-setting command.  If everyone has something
like this in their .cshrc:

    setenv PATH $HOME/bin:`/bin/path`

and /bin/path is a simple script that outputs whatever you want the
default path to be:

    #!/bin/sh

    echo /usr/local/bin:/usr/bin/X11:/usr/ucb:/bin:/usr/bin


then you just need to change /bin/path when you add a new directory.
Of course it's a bit of work to get everyone to use this but
it may pay off in the long run.

You can also use a fancier scheme if you want different "kinds" of
paths - one set of paths for administrative shell scripts, etc etc.
maybe your shell scripts all begin with

    PATH=`/bin/path admscript` export PATH

you could have /bin/path output various different paths depending
on its first argument.  So users get one path, scripts get 
another, etc etc, and all you ever have to fool around with is
one file, /bin/path.

bush@evax.arl.utexas.edu (Joe Bush) (11/02/90)

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$$ <<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@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

peirce@gumby.cc.wmich.edu (Leonard Peirce) (11/03/90)

In article <1990Nov1.185247.16196@evax.arl.utexas.edu> bush@evax.arl.utexas.edu (Joe Bush) writes:
>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:
>>I too wish it had a global start up file...
>
>	Me too.

Check into tcsh.  It will source /etc/Login before ~/.cshrc and ~/.login,
is fully compatible with csh, and has all kinds of other neat features
besides (including command line editing and automatic periodic command
execution).

You can get it via anonymous ftp from bu.edu in the ~ftp/binary/tcsh/5.18
directory.
--
Leonard Peirce                  Internet:  peirce@gumby.cc.wmich.edu
Western Michigan University                peirce@gw.wmich.edu
Academic Computing Services     UUCP:      ...!uunet!sharkey!wmichgw!peirce
Kalamazoo, MI  49008            Phone:     (616) 387-5469