move_uploaded_file, fileowner, chown etc.

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

    move_uploaded_file, fileowner, chown etc.

    I have a form handler script that creates a new folder for the files sent in
    the form. Move_uploaded_f ile transfers then puts those files there.

    But problem is that apache becomes automaticly owner of folder and files, so
    later I cannot delete/rename/transfer those files trough winscp. Only load
    them if permissions are set ok.

    Chown doesn't work, because only superuser can change file's owner. What can
    I do? Make 24 h agreement with superuser? Become superuser? Now i fell more
    like superloser. I create files but i cannot delete them.

    --
    Perttu Pulkkinen





  • Alvaro G Vicario

    #2
    Re: move_uploaded_f ile, fileowner, chown etc.

    *** Perttu Pulkkinen wrote/escribió (Thu, 02 Jun 2005 09:08:02 GMT):[color=blue]
    > Chown doesn't work, because only superuser can change file's owner. What can
    > I do?[/color]

    Try changing the group with chgrp() and giving rights to the group. In many
    Linux distros user's main group is a group named after the username that is
    created automatically. That's it, user john belongs to group john.


    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • Perttu Pulkkinen

      #3
      Re: move_uploaded_f ile, fileowner, chown etc.

      "Alvaro G Vicario" wrote:[color=blue]
      > *** Perttu Pulkkinen wrote/escribió (Thu, 02 Jun 2005 09:08:02 GMT):[color=green]
      > > Chown doesn't work, because only superuser can change file's owner.[/color][/color]
      [color=blue]
      > Try changing the group with chgrp() and giving rights to the group. In[/color]
      many[color=blue]
      > Linux distros user's main group is a group named after the username that[/color]
      is[color=blue]
      > created automatically. That's it, user john belongs to group john.[/color]

      Chgrp doesn't work either, because only superuser can change file's group.


      Comment

      • Kenneth Downs

        #4
        Re: move_uploaded_f ile, fileowner, chown etc.

        Perttu Pulkkinen wrote:
        [color=blue]
        > "Alvaro G Vicario" wrote:[color=green]
        >> *** Perttu Pulkkinen wrote/escribió (Thu, 02 Jun 2005 09:08:02 GMT):[color=darkred]
        >> > Chown doesn't work, because only superuser can change file's owner.[/color][/color]
        >[color=green]
        >> Try changing the group with chgrp() and giving rights to the group. In[/color]
        > many[color=green]
        >> Linux distros user's main group is a group named after the username that[/color]
        > is[color=green]
        >> created automatically. That's it, user john belongs to group john.[/color]
        >
        > Chgrp doesn't work either, because only superuser can change file's group.[/color]

        It does work. The apache user must be in the group.

        So if user John is in group "John", and you want John to be able to
        manipulate files uploaded by apache, then put apache into that group also.
        Then apache will be able to chgrp its own files to group John.

        --
        Kenneth Downs
        Secure Data Software, Inc.
        (Ken)nneth@(Sec )ure(Dat)a(.com )

        Comment

        • Marcos Gutierrez

          #5
          Re: move_uploaded_f ile, fileowner, chown etc.

          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA1


          Try using FTP

          Something like...

          $id_con = ftp_connect("lo calhost");
          $resultado_logi n =
          ftp_login($id_c on, "ftp_user", "ftp_pass") ;
          if ((!$id_con) || (!$resultado_lo gin)) return 0;

          if(!file_exists ("my_folder" ))
          ftp_mkdir($id_c on,"/_other_/_ftp_folders/my_folder");
          $carga = ftp_put($id_con ,
          /_other_/_ftp_folders/my_folder/myfile,
          $_FILES["myfile"]['tmp_name'], FTP_BINARY);
          if(!$carga) return 0;
          else return 1;
          ftp_close($id_c on);

          This is what I do to avoid the problem ^^

          Greets.
          -----BEGIN PGP SIGNATURE-----
          Version: GnuPG v1.4.1 (MingW32)

          iD8DBQFCn1YDlrI 0xkZFpzMRAlA3AK CuNDZdmOnAuEOIx 4K33hWvEmJDhACf dUje
          wgPpTlbeLoyMD8I WVHlmRo4=
          =TrhR
          -----END PGP SIGNATURE-----

          Comment

          Working...