[comp.sys.sgi] rsh

bill@contex.UUCP (Bill Phillips) (08/29/90)

I just discovered an apparently undocumented feature of the remote
shell rsh (not to be confused with the restricted shell of the same
name).  rsh imposes a umask of 022 on all programs run through it.
This caused us much consternation and confusion, and led to many
man-days of fruitless and unnecessary debugging.  As far as I have
been able to determine after considerable research, this is entirely
undocumented.

We are running SGI IRIX 3.2 and 3.3 on a number of Personal Irises.

Questions:

    - has anyone ever run into this before (I don't recall having
    seen discussions of it, but I could have missed it -- if
    anyone has articles or pointers, I'd like to see them)?

    - might this be under the control of some configuration file?
    I have definitely determined that neither ~/.profile nor
    /etc/profile was responsible.

    - if this is a known "feature", is there some flag for rsh,
    or some other way of turning it off (other than prepending
    "umask 0;" to every command line sent through rsh)?

We'll be turning off the umask from within the programs run by rsh
now, but that only applies to our own software, of course.

Thanks,
bill
-- 
William F Phillips,  Sr. Engr.,  Development Systems Development Group,
    Xyvision Design Systems  +  101 Edgewater Drive  +  Wakefield, MA, USA
        uunet!contex!bill                     (formerly wfp@well & wfp@dasys1)

schuman@sgi.com (Aaron Schuman) (08/29/90)

I just looked over the source for rshd, and I didn't see it setting
umask anywhere.  It isn't set in rcmd(3) either.  Doing a setuid
system call doesn't source the rc files belonging to the new user,
so umask isn't getting set that way.

The umask shell variable is inherited by child processes.  My guess
is that on your system rshd's parent (inetd) has a umask of 022,
and so does rshd's grandparent (init).

meyer@gorgo.ifi.unizh.ch (Urs Meyer) (08/29/90)

In article <1406@contex.UUCP> bill@contex.UUCP (Bill Phillips) writes:
>
>I just discovered an apparently undocumented feature of the remote
>shell rsh (not to be confused with the restricted shell of the same
>name).  rsh imposes a umask of 022 on all programs run through it.
>
[...]
>Questions:
[...]
>    - might this be under the control of some configuration file?
>    I have definitely determined that neither ~/.profile nor
>    /etc/profile was responsible.

umask 22 is set in /etc/profile and /etc/cshrc.

>    - if this is a known "feature", is there some flag for rsh,
>    or some other way of turning it off (other than prepending
>    "umask 0;" to every command line sent through rsh)?

Probably not.

>We'll be turning off the umask from within the programs run by rsh
>now, but that only applies to our own software, of course.

Try if changing /etc/{cshrc,profile} helps before changing your software.

>Thanks,
>bill
>-- 
>William F Phillips,  Sr. Engr.,  Development Systems Development Group,
>    Xyvision Design Systems  +  101 Edgewater Drive  +  Wakefield, MA, USA
>        uunet!contex!bill                     (formerly wfp@well & wfp@dasys1)

Urs Meyer ---------- meyer@ifi.unizh.ch, {uunet,...}!mcsun!cernvax!unizh!meyer
University of Zurich, Dept of Computer Science, Multimedia Lab, CH-8057 Zurich

fsfacca@AVELON.LERC.NASA.GOV (Tony Facca) (08/29/90)

In article <1406@contex.UUCP> bill@contex.UUCP (Bill Phillips) writes:
>
>I just discovered an apparently undocumented feature of the remote
>shell rsh (not to be confused with the restricted shell of the same
>name).  rsh imposes a umask of 022 on all programs run through it.

This is not necessarily true.  The Berkeley rsh command imposes whatever
umask is imposed by the remote machine.  When you issue the rsh command
it assumes the environment of the remote host.  

>Questions:
>
>    - might this be under the control of some configuration file?
>    I have definitely determined that neither ~/.profile nor
>    /etc/profile was responsible.
>

I don't use the Bourne Shell so I don't know if this works for sh or not.  If
your default shell is the C Shell (check the /etc/passwd file, last field) on
the remote machine,  then rsh commands will invoke the .cshrc file in your
home directory.  If you set a umask in this file, it will be the umask used 
by the command which is executed.  

>    - if this is a known "feature", is there some flag for rsh,
>    or some other way of turning it off (other than prepending
>    "umask 0;" to every command line sent through rsh)?
>

As you have determined, since the .cshrc file is executed by rsh each time
you pass a command to the remote machine, you must either change it in the
.cshrc file or keep doing the 'umask 0' each time.  You can, of course string
multiple commands together in an rsh:

	rsh remote_host 'echo who ; who ; echo date ; date'

To test the umask do this:

	rsh remote_host 'umask ; umask 0 ; who ; date ; umask'

When you do the last umask, it should report 0.  Therefore, the 'who' and 
'date' commands run with a umask of 0.

Hope this helps some.
--
-----------------------------------------------------------------------------
Tony Facca   |   fsfacca@avelon.lerc.nasa.gov      |     phone: 216-433-8318
-----------------------------------------------------------------------------
      You are at Witt's end.  Passages lead off in *all* directions.