Re: File Permissions

joe_at_invalid.address
Date: 10/03/03


Date: Fri, 03 Oct 2003 13:44:08 GMT

beefstu350@hotmail.com (Stu) writes:

> I am running in the ksh and have a umask 000 and my file gets
> created with the permissions of 666.
>
> -rw-rw-rw- 1 stu developer 0 Oct 3 09:17 x
>
> Why does it get created as 666. Is this the default behavior of the
> UNIX?, KSH?.

The mode argument to open(2) or creat(2) determine the bits that the
file starts with. If the file is being created by ksh, I assume that's
the mode it uses by default. You don't say what system or version of
ksh you're using, but I ran a test on Solaris ksh:

truss ksh -c 'echo xxx > testfile'

Which shows it opening testfile with a mode of 0666:

open64("testfile", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3

> Is there a way to have the file created with permissions other than
> 666 without setting a value to umask ? If so, how ?

You'd have to control whatever program is calling open(2) or
create(2). Depending on what system you're using, there may be a
default setting in a file someplace, but I'm not aware of one, I think
it's more or less traditional.

Joe



Relevant Pages

  • Re: check for existence of environment variable
    ... >> runs under ksh on an older box but will not run under ksh on ... the code snippet looks OK. ... although that shouldn't matter in this case. ... Unix Guy Consulting, LLC ...
    (comp.sys.hp.hpux)
  • Re: ksh and +() regex
    ... >> your Unix and version of ksh but not here. ... The command works fine on ksh Version M-11/16/88i. ... as it is not doing a pattern match in a filename generation context. ...
    (comp.unix.shell)
  • Re: Installing ksh from AT&T
    ... on UNIX that uses the Korn shell, ... ksh from AT&Ts, but, being a UNIX newbie, I am not sure where to put the ...
    (comp.sys.mac.apps)
  • Re: How To Do It Faster?!?
    ... If anyone knows if that command will run also on a simple ksh, ... That depends on the unix flavor you're using -- my example was for GNU ... seriously degrade the performance of the file server. ... your script periodically over a day, maybe at times when the server is ...
    (comp.lang.python)
  • Installing ksh from AT&T
    ... on UNIX that uses the Korn shell, ... ksh from AT&Ts, but, being a UNIX newbie, I am not sure where to put the ... Can anyone humor me and post step-by-step instructions for installing ...
    (comp.sys.mac.apps)