[comp.unix.wizards] umask under 4.3 BSD

eichelbe@nadc.arpa (05/28/87)

I am running 4.3 BSD on a VAX 11/780.  Does anyone know how I could
change the system-wide "umask" so when I person does something like
echo "stuff" > x

x will have the file permission 0600 and not 0644?  I have source code
for the system.

	Thanks.
		Jon Eichelberger
		eichelbe@NADC.ARPA

jch@omnigate.clarkson.EDU (05/28/87)

	This is an automatic reply.  Feel free to send additional
mail, as only this one notice will be generated.  The following
is a prerecorded message, sent for jch


May 27, 1987

On Thursday morning I'm having some surgery on my eye muscles (to
correct a slight double vision problem).  Needless to say, I'm not
going to be reading my mail right away, probable not for a week.

Your mail has been recorded and I will read it (and hopefully respond
to it) as soon as I am able to.  If you need to contact me before that,
feel free to call me at home (315/265-4748) on or after Monday, June
1st.

Be "seeing" you.

Jeff

franco@MIKEY.BBN.COM (05/28/87)

	One way that I know of is to change the default login
umask in the login.c program.  Other than that, I don't think
there is a system wide umask.

franco%mikey.bbn.com@relay.cs.net
UUCP: thru harvard.

eichelbe@nadc.arpa (05/28/87)

Good idea!  Think I'll do that.
eichelbe@NADC.ARPA

pdb@sei.cmu.edu (Patrick Barron) (05/30/87)

In article <7554@brl-adm.ARPA> eichelbe@nadc.arpa (H. McCloskey) writes:
>I am running 4.3 BSD on a VAX 11/780.  Does anyone know how I could
>change the system-wide "umask" so when I person does something like
>echo "stuff" > x
>x will have the file permission 0600 and not 0644?  I have source code
>for the system.

In the source for /bin/login, change the line:

      umask(022);

to:

      umask(077);

Then just re-install login, and you'll have your new system-wide umask.

--Pat.

ggs@ulysses.UUCP (06/02/87)

In article <7554@brl-adm.ARPA>, eichelbe@nadc.arpa writes:
> I am running 4.3 BSD on a VAX 11/780.  Does anyone know how I could
> change the system-wide "umask" so when I person does something like
> echo "stuff" > x
> 
> x will have the file permission 0600 and not 0644?  I have source code
> for the system.
> 
> 	Thanks.
> 		Jon Eichelberger
> 		eichelbe@NADC.ARPA

Just in case you wanted a straight answer instead of a lot of philosophy:

The system-wide default for the umask is set in /sys/sys/init_main.c,
line 33, from a parameter, CMASK, that is set in /sys/h/param.h.  To
change the global value, either change the value in the header file and
re-build the kernel or use adb to patch the variable "cmask" in the
bootable kernel.  In either case, you have to re-boot to have the
change take effect.  To patch the value to 0066 with adb:

adb -w /vmunix -
cmask?W 0o066

Doing the change here has the added benefit that files created by rsh'ed
commands also get the desired umask; unfortunately, some of the daemons
do not set good defaults.  One could probably also fix the problem by
setting the default in "init".
-- 
Griff Smith	AT&T (Bell Laboratories), Murray Hill
Phone:		1-201-582-7736
UUCP:		{allegra|ihnp4}!ulysses!ggs
Internet:	ggs@ulysses.uucp

yedidya@bimacs.BITNET.UUCP (06/04/87)

The patches suggested are solving this local problem.

Let me widen the problem and interduce another solution.

Lets say I want to set a system-wide variables, aliases, execute a few
initialization commands etc. I'd like to have a system-wide .login ,
.cshrc , (.profile if someone uses sh(1)) and .logout. (The latter is
not really necessary)

Solution: change csh to source /usr/lib/.{cshrc,login}
          These files can be kept empty.

(If someone really did it, send me patches)

Now all you need to do is to put "umask 0066" in /usr/lib/.cshrc .

                                        yedidya

+---------------------------------------------------------------------+
| Israel Yedidya, Math & CS Department, Bar-Ilan U, Ramat-Gan, ISRAEL |
+---------------------------------------------------------------------+
| BITNET: yedidya@bimacs                                              |
| ARPA:   yedidya%bimacs@wiscvm.wisc.edu                              |
| CSNET:  yedidya%bimacs.bitnet%wiscvm.wisc.edu@csnet-relay           |
| UUCP:   {mcvax,seismo}!humus!bimacs!yedidya                         |
+---------------------------------------------------------------------+

franco@MIKEY.BBN.COM (06/04/87)

Hi:
	I didn't post the original question about umask, I just gave
the person who did one example that I know of.  Of course there are
many ways this can be handled, some more hackish then others, but one
of the better solutions is to change the umask call in login.c and possibly
in cron.c as well, this way you don't have to rebuild the kernel.

	Oh, by the way, I haven't checked it out yet myself, but someone
said that 4.3 login.c doesn't have a umask call in it.  What's to stop
one from adding it!

franco%mikey.bbn.com@relay.cs.net

guy@gorodish.UUCP (06/05/87)

> 	Oh, by the way, I haven't checked it out yet myself, but someone
> said that 4.3 login.c doesn't have a umask call in it.  What's to stop
> one from adding it!

Nothing stops you from adding it; it was presumably removed because
4.3BSD sets the "umask" of process 0 to 022 (or whatever CMASK was
set to when you built your system).
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com

ado@elsie.UUCP (Arthur David Olson) (06/08/87)

> > Oh, by the way, I haven't checked it out yet myself, but someone
> > said that 4.3 login.c doesn't have a umask call in it.  What's to stop
> > one from adding it!
> 
> Nothing stops you from adding it; it was presumably removed because
> 4.3BSD sets the "umask" of process 0 to 022 (or whatever CMASK was
> set to when you built your system).

And thus was a bug born.  Everything is fine if you tye control-D at the
end of a terminal session:  init starts up a new copy of getty on the line,
with init's "umask" value (as determined by CMASK) passed on to getty;
getty eventually in turn passes that value on to login.

But if you end a terminal session by using a shell's built-in

	$ login

command, then login is executed directly and inherits whatever "umask" value
happened to be in effect at the time you used the built-in.
-- 
	UUCP: ..seismo!elsie!ado	   ARPA: elsie!ado@seismo.CSS.GOV
	     Elsie and Ado are trademarks of Borden, Inc. and Ampex.

rbj@icst-cmr.arpa (Root Boy Jim) (06/10/87)

OOPS! I hit the wrong key. The original (umask(077)) is correct. Sorry.

rbj@icst-cmr.arpa (Root Boy Jim) (06/10/87)

   In article <7554@brl-adm.ARPA> eichelbe@nadc.arpa (H. McCloskey) writes:
   >I am running 4.3 BSD on a VAX 11/780.  Does anyone know how I could
   >change the system-wide "umask" so when I person does something like
   >echo "stuff" > x
   >x will have the file permission 0600 and not 0644?  I have source code
   >for the system.

   In the source for /bin/login, change the line:

	 umask(022);

   to:

	 umask(077);

   Then just re-install login, and you'll have your new system-wide umask.

   --Pat.


	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688