My original question was:
>Here is a real simple question. I have been unable to find anything in the
>manuals about this, so here is my question.
>We use the /bin/csh for our shell. Our network consists of several workstations
>running 4.1.3 and a single workstation running Solaris 2.3. We use NIS and
>have a home directory on one of the 4.1.3 machines that is mounted to all of
>the other workstations. There is a local entry in all of the
>/etc/passwd files for the root userid.
>On our 4.1.3 systems, if I login under my personal userid and then do a
>"su" to get into the root userid, the /.cshrc file is executed. My understanding
>is that this is how it is supposed to work.
>On our Solaris 2.3 system, when I do this, the /.cshrc does not get executed.
>I end up with a path that only has /usr/sbin and /usr/bin. I've checked and
>this doesn't come from the /etc/profile file. I don't know how
>I get this. Is it a default or is there a .cshrc file somewhere else on my
>system that is getting executed? I cannot use the printenv command, but the
>env command shows that I am using the /bin/csh. At this point I can "source
>/.cshrc" and get the environment that I want.
>My /etc/passwd entry for root on our Solaris 2.3 machine is as follows:
> root:x:0:1:0000-Admin(0000):/:/bin/csh
>I have checked that root owns the root directory and the .cshrc and .login
>files there.
The most common response to my query was to use
su -
This causes the .cshrc _and_ .login files for root to be executed. I was hoping
to duplicate the way it works in 4.1.3 where only the .cshrc file is executed.
But, as anderson@neon.mitre.org pointed out, using su - also causes the current
directory to be changed to /.
Several pointed out that there is a file called /etc/defaults/su which
has default parameters in it, one called SUPATH which sets the path
for users invoking su to root. This was indeed part of my problem
and this file is documented in the man pages under su. I made the
mistake of thinking I could find what I needed to know from the
answerbook and forgot all about the trusty man pages :< I made
the chage to the SUPATH here and it worked immediately, giving me
the PATH that I wanted.
If you really want to completely duplicate the way it works under
SunOS 4.1.3, Stuart Pearlman had the answer. He writes:
------------------------------------------
From: stuart@TO.Mobil.COM (Stuart Pearlman - RDR)
> /bin/csh uses the HOME environment variable to find the .cshrc file to
>source. Under SunOS 4.x, su resets HOME. Under Solaris, the su command
>does not reset home, so /bin/csh is looking at your .cshrc, not /.cshrc.
>Things are complicated by the fact that csh refuses to source the .cshrc
>file if it is owned by someone else. When you su to root under Solaris,
>csh looks at your .cshrc file and sees that it is owned by you, not root,
>so it ignores it. You end up with a default path.
>Try: setenv HOME / before you su to root, and see if this fixes the problem.
>If it does, you might want to set up an alias like:
> alias suroot "setenv HOME / ; su"
>and use that to su to root.
------------------------------------------
This will get the .cshrc file sourced without the .login file. You can
set the path in the .cshrc file if you like.
I also found out why the printenv command was not working. It is in
/usr/ucb, which was not in my path.
Some respondents mentioned that root should not be using /bin/csh.
I think that this is definitely a valid concern. I am including two
responses which made suggestions for dealing with this problem.
----------------------------
From: Zuercher.Werner@ch.swissbank.com (Werner Zuercher)
Try this in /.profile, and you have to use 'su -' in solaris. If
you find a better solution, pls post.
|_________________________________________________________________|
#!/sbin/sh
# /.profile ROOT's startup file
#
PATH=/usr/bin:/usr/ucb:/usr/sbin
export PATH
# In solaris 2.x the csh cannot be set as the default shell
# for rootbecause it uses shared libs and if /usr wasn't
# mounted, this would mean trouble.
#
# Thus: We use the bourne shell to start & switch to
# the C-shell if it is there.
#
if [ -x /usr/bin/csh -a -x /usr/lib/libc.so.1 ] ; then
SHELL=/usr/bin/csh ; export SHELL
exec /usr/bin/csh
fi
----------------------------
From: Eckhard.Rueggeberg@ts.go.dlr.de (Eckhard Rueggeberg)
This is extremely dangerous. /bin is a symlink to /usr/bin, and if /usr can't
get mounted for some reason (e.g. typo in /etc/vfstab), you sit here without
a root shell, so you can't do ANYTHING except booting from a CD. cp'ing csh
to /sbin doesn't help, if you don't have a statically linked csh.
What I did was to create an ADDITIONAL account
croot:x:0:1:0000-Admin(0000):/:/bin/csh
and create an "alias sur su - croot"
----------------------------
Thanks to the following. I hope I have not left anyone out.
stuart@TO.Mobil.COM (Stuart Pearlman - RDR)
worsham@aer.com (Robert D. Worsham)
gturner@aer.com (G. Turner)
peter.allan@aea.orgn.uk (Peter Allan)
coez@tet.uni-hannover.de (Cengiz Oezcan-Barlach)
anderson@neon.mitre.org (Mark S. Anderson)
lcollera@amgen.com (Lori Colleran)
markus@mpim-bonn.mpg.de (Markus Auferkorte)
rnapholz@PICA.ARMY.MIL
gml4410@ggr.co.uk
jgarb@erim.org (Joe Garbarino)
joshia@cranium.com.msu.edu (Amaresh R. Joshi)
hoogs@SynOptics.COM (Tim Hoogasian)
chris@New.Paramax.COM (Chris Hines)
x092306@hyperion.LANL.GOV (Jerry Weber C-8/IS-5)
Paul Cowle <paulc@alex.state.COM.AU>
seanw@amgen.com (Sean Ward)
kevin@pass.bt.co.uk
tog@berlioz.nsc.com (Systems Administrator - Todd Glassey)
Ric Anderson <ric@cs.arizona.edu>
maneesh@vis.caltech.edu (Maneesh Sahani)
df5slsn@bagate.BELL-ATL.COM (Hermida)
"Quinlan, Grant W." <gquinlan@mmpc.ssd.lmsc.lockheed.com>
Mike Raffety <mike_raffety@il.us.swissbank.com>
nino@well.ox.ac.uk (Nino Margetic)
Zuercher.Werner@ch.swissbank.com (Werner Zuercher)
Eckhard.Rueggeberg@ts.go.dlr.de (Eckhard Rueggeberg)
whiteg@panther.acc1912.af.mil (Gary A White)
===============================================================================
= Maureen Kemp =
= __@ Teale Data Center =
= _'\<,_ GIS Technology Center =
- __(*)/ (*)___ mkemp@gislab.teale.ca.gov =
===============================================================================
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:09:00 CDT