User uploading files to load balanced server cluster

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

    User uploading files to load balanced server cluster

    Hi All!

    This really is a file permissions problem ... although I'm not sure how
    to solve it. Any assistance would be greatly appreciated.

    I have a series of load balanced servers. Each of the servers is
    arranged exactly the same and handles file uploads from users as
    follows:

    1) User submits file to www1 server
    2) www1 server saves file with permissions showing user "www" is the
    owner, dir owner is the group for the file ("sg" in this case).
    3) cron script on www1 scp's the file to www2 server.

    All of this works great up until the following happens ...

    4) User resubmits the file to www2 server
    5) www2 attempts to update file located on www2 server with new
    version, but cannot modify file (attempting to overwrite a file owned
    by sg/sg with a file to be owned by www/sg).
    6) User continues to see old image, new image is not replicated

    Where am I going wrong here? Any assistance would be appreciated.

    Stephen

  • Stephen

    #2
    Re: User uploading files to load balanced server cluster

    Forgot to point out how the cron job (actually a PHP script) runs ...

    3a) cron executes scp -p origfile sg@www2:destfil e
    3b) destfile appears on www2 with ownership sg/sg, same permissions as
    origfile

    Comment

    • noone

      #3
      Re: User uploading files to load balanced server cluster

      Stephen wrote:[color=blue]
      > Hi All!
      >
      > This really is a file permissions problem ... although I'm not sure how
      > to solve it. Any assistance would be greatly appreciated.
      >
      > I have a series of load balanced servers. Each of the servers is
      > arranged exactly the same and handles file uploads from users as
      > follows:
      >
      > 1) User submits file to www1 server
      > 2) www1 server saves file with permissions showing user "www" is the
      > owner, dir owner is the group for the file ("sg" in this case).
      > 3) cron script on www1 scp's the file to www2 server.
      >
      > All of this works great up until the following happens ...
      >
      > 4) User resubmits the file to www2 server
      > 5) www2 attempts to update file located on www2 server with new
      > version, but cannot modify file (attempting to overwrite a file owned
      > by sg/sg with a file to be owned by www/sg).
      > 6) User continues to see old image, new image is not replicated
      >
      > Where am I going wrong here? Any assistance would be appreciated.
      >
      > Stephen
      >[/color]

      what webserver/platform?

      Comment

      • Stephen

        #4
        Re: User uploading files to load balanced server cluster

        FreeBSD 5/Apache 1.3

        Comment

        • David Haynes

          #5
          Re: User uploading files to load balanced server cluster

          Stephen wrote:[color=blue]
          > Hi All!
          >
          > This really is a file permissions problem ... although I'm not sure how
          > to solve it. Any assistance would be greatly appreciated.
          >
          > I have a series of load balanced servers. Each of the servers is
          > arranged exactly the same and handles file uploads from users as
          > follows:
          >
          > 1) User submits file to www1 server
          > 2) www1 server saves file with permissions showing user "www" is the
          > owner, dir owner is the group for the file ("sg" in this case).
          > 3) cron script on www1 scp's the file to www2 server.
          >
          > All of this works great up until the following happens ...
          >
          > 4) User resubmits the file to www2 server
          > 5) www2 attempts to update file located on www2 server with new
          > version, but cannot modify file (attempting to overwrite a file owned
          > by sg/sg with a file to be owned by www/sg).
          > 6) User continues to see old image, new image is not replicated
          >
          > Where am I going wrong here? Any assistance would be appreciated.
          >
          > Stephen
          >[/color]
          In summary, www2 has a file owned by www with group sg in a directory
          owned by sg with group sg and user www with group sg wants to write to it.

          So, the directory needs to have group write and (probably) execute on
          it. (eg. chmod 750 or 770) That way any group sg account may write files
          to the directory (as well as delete). Execute may not me necessary, but
          I think its needed for the delete operation. Its an easy to test to find
          the minimum permission set that does what you want.

          I probably would have just set up the shared files as an NFS mount and
          have any of the front-end servers read/write to it but you may have good
          reasons for doing it the way you did.

          -david-

          Comment

          • Stephen

            #6
            Re: User uploading files to load balanced server cluster

            Hey David,

            Thanks for your reply. Actually the files would look like this after
            step 3:

            www1: www/sg
            www2: sg/sg

            and so the user www (apache) cannot modify, delete or update file on
            www2. I can't scp the file from www1 to www2 using the "www" user
            because www is essentialy "nobody" ...

            Stephen

            Comment

            • Andy Jeffries

              #7
              Re: User uploading files to load balanced server cluster

              On Wed, 22 Feb 2006 18:07:24 -0800, Stephen wrote:[color=blue]
              > Forgot to point out how the cron job (actually a PHP script) runs ...
              >
              > 3a) cron executes scp -p origfile sg@www2:destfil e 3b) destfile appears on
              > www2 with ownership sg/sg, same permissions as origfile[/color]

              So can't you chown the origfile to nobody/www (i.e. nobody:sg or
              www:sg, depending on which you use) after scping with cron? That way it
              will be owned by nobody/www and the web server will be able to overwrite
              it.

              Cheers,


              Andy

              --
              Andy Jeffries | gPHPEdit Lead Developer
              http://www.gphpedit.org | PHP editor for Gnome 2
              http://www.andyjeffries.co.uk | Personal site and photos

              Comment

              Working...