permissions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fire Juggler

    #1

    permissions

    Hi Guys,
    I currently have this code:
    mkdir("/usr/local/psa/home/vhosts/x-tractband.co.uk/httpdocs/x-tract/photos/
    ".$tab, 0777);

    wen the directory is created it only has the permissons 755, any ideas why
    this is this case?
    Thanks

    --
    Kathryn (Fire Juggler)




  • SOR

    #2
    Re: permissions

    <comp.lang.ph p , Fire Juggler , firejuggler@fir ejugglers.34sp. com>
    <daotqu$1ic$1@n ews8.svr.pol.co .uk>
    <Sat, 9 Jul 2005 17:26:06 +0100>
    [color=blue]
    > Hi Guys,
    > I currently have this code:
    > mkdir("/usr/local/psa/home/vhosts/x-tractband.co.uk/httpdocs/x-tract/photos/
    > ".$tab, 0777);
    >
    > wen the directory is created it only has the permissons 755, any ideas why
    > this is this case?
    >[/color]

    I seem to recall somebody from 34sp saying its only the first 7 thats
    important .

    Try 0766

    Comment

    • Bert Melis

      #3
      Re: permissions

      Fire Juggler wrote:[color=blue]
      > Hi Guys,
      > I currently have this code:
      > mkdir("/usr/local/psa/home/vhosts/x-tractband.co.uk/httpdocs/x-tract/photos/
      > ".$tab, 0777);
      >
      > wen the directory is created it only has the permissons 755, any ideas why
      > this is this case?
      > Thanks
      >[/color]
      I thought it was a bug.

      just chmod to 0777 after making the dir.

      function makedir($dir,$m ode=0777){
      mkdir($dir,$per mission);
      return chmod($dir,$per mission);
      }

      Comment

      • Bert Melis

        #4
        Re: permissions

        Fire Juggler wrote:[color=blue]
        > Hi Guys,
        > I currently have this code:
        > mkdir("/usr/local/psa/home/vhosts/x-tractband.co.uk/httpdocs/x-tract/photos/
        > ".$tab, 0777);
        >
        > wen the directory is created it only has the permissons 755, any ideas why
        > this is this case?
        > Thanks
        >[/color]
        At the PHP documentation you'll find this:

        You might notice that when you create a new directory using this code:

        mkdir($dir, 0777);

        The created folder actually has permissions of 0755, instead of the
        specified
        0777. Why is this you ask? Because of umask(): http://www.php.net/umask

        The default value of umask, at least on my setup, is 18. Which is 22
        octal, or
        0022. This means that when you use mkdir() to CHMOD the created folder
        to 0777,
        PHP takes 0777 and substracts the current value of umask, in our case
        0022, so
        the result is 0755 - which is not what you wanted, probably.

        The "fix" for this is simple, include this line:

        $old_umask = umask(0);

        Right before creating a folder with mkdir() to have the actual value you
        put be
        used as the CHMOD. If you would like to return umask to its original
        value when
        you're done, use this:

        umask($old_umas k);

        Comment

        Working...