problem setting permisions

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

    problem setting permisions


    I'm not sure if this is a linux, apache or PHP problem but I'm using PHP
    to do it so I'll start here:

    if I do
    $myDir = '/temp/';

    mkdir($myDir,07 77);
    chmod($myDir,07 77);

    I get a directory with 777 permissions. That seems fine.
    (The chmod seems needed to undo a mask)
    The directory is created with owner & user as Apache

    However if I now do:


    if (!mkdir($myDir . 'subDir/',0777)) {
    echo('Creation error');
    }
    chmod($myDir . 'subDir/',0777);

    I've tried removing the trailing slash to no effect.

    PHP fails to create subDir/ at all AND doesn't flag up the error.
    I expect I'm missing something fundamental but can't see what.

    Can anyone help please?


  • Schraalhans Keukenmeester

    #2
    Re: problem setting permisions

    At Wed, 23 May 2007 17:22:28 +0000, harvey let his monkeys type:
    >
    I'm not sure if this is a linux, apache or PHP problem but I'm using PHP
    to do it so I'll start here:
    >
    if I do
    $myDir = '/temp/';
    >
    mkdir($myDir,07 77);
    chmod($myDir,07 77);
    >
    I get a directory with 777 permissions. That seems fine.
    (The chmod seems needed to undo a mask)
    The directory is created with owner & user as Apache
    >
    However if I now do:
    >
    >
    if (!mkdir($myDir . 'subDir/',0777)) {
    echo('Creation error');
    }
    chmod($myDir . 'subDir/',0777);
    >
    I've tried removing the trailing slash to no effect.
    >
    PHP fails to create subDir/ at all AND doesn't flag up the error.
    I expect I'm missing something fundamental but can't see what.
    >
    Can anyone help please?
    Maybe to do with the trailing '/'
    Have a look at the user comments at:


    HTH
    Sh

    Comment

    • harvey

      #3
      Re: problem setting permisions

      In article <pan.2007.05.23 .19.31.54.37377 7@invalid.spam> ,
      invalid@invalid .spam says...Thanks for that heads up -
      Surely someone has a simple solution for this that will work anywhere?
      Using FTP (as suggested) just seems absurd to me.

      After reading the above link I think I can sumarise with:


      -----------------[ CUT ]------------
      If you're on a shared *nix server, a directory created through mkdir()
      will not be assigned to you, but to the user that your host's server or
      php process is running under, usually 'nobody', 'apache' or 'httpd'.

      In practice, this means that you can create directories, even add files
      to them, but you can't delete the directory or its contents nor change
      permissions.

      -----------------[ END CUT ]------------

      It is also incomplete - it appears you cannot create sub-dirs in them
      without taking extra steps ... using umask() and sticky bits depending
      on configuration. And even then it doesn't always work nor report
      the failure.

      All this can't be right can it?





      Comment

      • Schraalhans Keukenmeester

        #4
        Re: problem setting permisions

        At Thu, 24 May 2007 10:55:45 +0000, harvey let his monkeys type:
        In article <pan.2007.05.23 .19.31.54.37377 7@invalid.spam> ,
        invalid@invalid .spam says...>
        Thanks for that heads up -
        Surely someone has a simple solution for this that will work anywhere?
        Using FTP (as suggested) just seems absurd to me.
        >
        After reading the above link I think I can sumarise with:
        >
        >
        -----------------[ CUT ]------------
        If you're on a shared *nix server, a directory created through mkdir()
        will not be assigned to you, but to the user that your host's server or
        php process is running under, usually 'nobody', 'apache' or 'httpd'.
        >
        In practice, this means that you can create directories, even add files
        to them, but you can't delete the directory or its contents nor change
        permissions.
        >
        -----------------[ END CUT ]------------
        >
        It is also incomplete - it appears you cannot create sub-dirs in them
        without taking extra steps ... using umask() and sticky bits depending
        on configuration. And even then it doesn't always work nor report
        the failure.
        >
        All this can't be right can it?
        If I am not overlooking something obvious, if apache:apache is the dir
        owner, your script should be able to make a subdir in it, since the script
        operates as apache:apache.

        However it may be a problem accessing these dirs via FTP (other user:group)

        SH

        Comment

        • harvey

          #5
          Re: problem setting permisions

          In article <pan.2007.05.24 .11.17.01.56880 7@invalid.spam> ,
          invalid@invalid .spam says...
          >
          If I am not overlooking something obvious, if apache:apache is the dir
          owner, your script should be able to make a subdir in it, since the script
          operates as apache:apache.
          >
          However it may be a problem accessing these dirs via FTP (other user:group)
          >
          SH
          >
          I suspect we are both overlooking something - I'm having great trouble
          making this work.

          Comment

          Working...