Comment 4 for bug 282983

Revision history for this message
Vincent Ladeuil (vila) wrote : Re: [Bug 282983] [NEW] file upload should not assume 0664 permissions

>>>>> "James" == James Ellis writes:

    James> Public bug reported:
    James> Hi

    James> I've noticed that on upload, the file permissions are
    James> being set as group writable e.g -rw-rw-r-- (0664). I
    James> tracked down this ( I think) in __init__.py, line 119
    James> (note directories are also given rwx permissions for
    James> group).

    James> The problem is that I'm dealing with a dumb server
    James> (out of my control) that is set up to disallow running
    James> of PHP files that are group writable.

Haaa, thanks, this helps determine the relevant use cases.

    James> I have to log in and update the permissions of each
    James> file that is uploaded, post bzr upload, which is a
    James> pain if I upload 100's of files :(

Sorry :(

    James> <pre>
    James> def upload_file(self, relpath, id, mode=None):
    James> if mode is None:
    James> if self.tree.is_executable(id):
    James> mode = 0775
    James> else:
    James> mode = 0664
    James> if not self.quiet:
    James> self.outf.write('Uploading %s\n' % relpath)
    James> self.to_transport.put_bytes(relpath, self.tree.get_file_text(id), mode)
    James> </pre>

<snip/>

    James> I notice that there is a mode arg, defaulting to None,
    James> which looks to be the default for the upload from
    James> where i can see this method being called. There is no
    James> mode help in "bzr help upload" so I'm not sure who to
    James> force the mode I want.

This place should be fine, this was the starting point to
implement user-controlled chmod bits handling, which get
interrupted for various reasons, the main one being that I wanted
to be able to test easily against several ftp servers.

    James> This seems to be a recent change as the upload was
    James> working ok before the last couple of pulls I did to
    James> get the latest code.

Both bzr and bzr-upload have changed, in the good direction,
sorry that you get trapped mid-way :-/

    James> A solution would be to set the same permissions as the local file. e.g
    James> if my local file is -rw-r--r-- then set "mode = 0644"

    James> Here is what I did (on a currently bzr-upload enabled
    James> directory)

Buggy as specified so far :-/

<snip/>

    James> I manually changed 0664 to 0644 at line 119 and it
    James> worked as I expect (but that's obviously not the
    James> solution for every case).

If it works for you, keep it like that. I'll make sure to have a
transition path for you when the chmod bits handling is
implemented.

The idea being to replicate the chmod bits on the current working
tree (but since bzr-upload uses a revision tree, care should be
taken to avoid mismatches). An intermediate solution will be to
use configuration variables for default values (so that you could
have specified the relevant values instead of patching the code).

Status: confirmed
Importance: high