[comp.unix.questions] Pre-set file permissions

ebertran@anselm.UUCP (Erik S. Bertrand) (02/18/91)

I would like to know if there is such a way to preset (say, in a .login file)
file permissions so that each time a file is saved, it's permissions will be
those of the preset ones.  Thank you in advance for your reply.

-Erik

+-----------------------------------------------------------------------------+
           "To be the rich man, is the end."  -- Ralph Waldo Emerson
+-----------------------------------------+-----------------------------------+
| Erik Bertrand                           |   .  .  :  /\ . : .  )  /\ .   .  |
| St. Anselm College                      | .   . /\ ./  \  ./\ .  /  \  .    |
| 87 St. Anselm Drive #3                  |  .   /  \/    \ /  \  /    \   .  |
| Manchester, N.H., U.S.A.  03102-1310    |     /    \     /    \/      \     |
+-----------------------------------------+-----------------------------------+
|   UUNET: ..!harvard!dartvax!anselm!ebertran    UUCP: ebertran@anselm.UUCP   |
+-----------------------------------------------------------------------------+ 

rauscher@remus.rutgers.edu (Trott ++) (02/18/91)

>I would like to know if there is such a way to preset (say, in a .login file)
>file permissions so that each time a file is saved, it's permissions will be
>those of the preset ones.  Thank you in advance for your reply.

Try adding the 'umask' command to your .cshrc.  (remember this is a
mask, the negation of the mode of protection).

Ie: umask 011 would result in a default protection of: 766.


>-Erik
-Rich
-- 
-------------
rauscher@rutgers.edu                RPO 5997 PO 5063, New Brunswick, NJ 08903
rauscher@PISCES                          Shakespeare learns Discrete Math:
{backbone site}!rutgers!rauscher                (2B | not (2B)) <=> TRUE

mike (02/19/91)

In an article, anselm.UUCP!ebertran (Erik S. Bertrand) writes:
>I would like to know if there is such a way to preset (say, in a .login file)
>file permissions so that each time a file is saved, it's permissions will be
>those of the preset ones.  Thank you in advance for your reply.

Set the umask to the permission bits that you want turned _off_ when a
file is created; a common umask is 022.  To set the umask, simply use
the umask(1) command, such as ``umask 022''.

Whenever you create a file, the creat() call gets your file creation
mask from your U area, and does something like this:

	creat(path,mode)
	char *path;
	int mode;
	{
	struct user	*u;
		...
		mode &= ~(u->u_cmask);
		...
	}

Cheers,
-- 
Michael Stefanik, MGI Inc., Los Angeles| Opinions stated are not even my own.
Title of the week: Systems Engineer    | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
Remember folks: If you can't flame MS-DOS, then what _can_ you flame?