FTPTransport.stat sees mode 000

Bug #326543 reported by Andrea Bolognani
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Medium
Unassigned
Breezy
Won't Fix
Low
Unassigned

Bug Description

Hi there.

I've just created a shared repository via FTP, and I can access it just fine over FTP, but I get an error when trying to access it over HTTP. The problem lies in the fact that the .bzr/repository directory ends up with 600 permissions, which causes the web server to return a 404 error on access.

Checking ~/.bzr.log, it reports to have set permissions 448 for the directory, which of course doesn't make any sense. Other files get absurd permissions: .bzr/README, for example, is reported to have been chmod 384.

Once I manually fix the permissions on files and directories, HTTP access works flawlessy.

Tags: ftp

Related branches

Revision history for this message
Andrea Bolognani (kiyuko) wrote :

Attached ~/.bzr.log, with personal information edited out. Bazaar version is 1.11.

Revision history for this message
Piotr Kalinowski (pitkali) wrote :

Hi,

I would like to confirm that issue is still not resolved as of bzr 1.14.1.

.bzr and .bzr/branch directories, and .bzr/branch-format file for my branches (in shared repo, no trees) have x00 permissions, which makes them quite unusable through transports different than FTP with the very same username that created the branch. They should be world-readable instead (that is, 755 for directories, 644 for file.)

What did change is that according to my .bzr.log bazaar has explicitly set those inappropriate permissions (so no more weird permission bits logged.)

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 326543] Re: Broken permissions over FTP for .bzr/repository (and others)

Can you reproduce this locally or over sftp?
--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Piotr Kalinowski (pitkali) wrote : Re: Broken permissions over FTP for .bzr/repository (and others)

No. If I create a shared repository and push into it locally, or over sftp, permissions are correct.

Revision history for this message
Wouter van Heyst (larstiq) wrote :

Milo on irc also suffers from this problem with vsftpd. .bzr/repository is fine, but .bzr/ itself has wrong permissions. He's using bzr 1.14.1

Revision history for this message
Wouter van Heyst (larstiq) wrote :

Milo also tested 1.9 through 1.13.2, they have the additional problem of giving the subfolders of .bzr/ the wrong permissions, that much at least 1.14.1 gets right. The umask is 0022

Vincent Ladeuil (vila)
Changed in bzr:
importance: Undecided → Medium
milestone: none → 2.0
status: New → Confirmed
tags: added: ftp
Revision history for this message
Martin Pool (mbp) wrote :

I'd like to fix this, but it's not strictly needed for 2.0 therefore I'm untargeting it.

I would guess that what's happening here is that bzr's trying to read the existing permissions from the repository and to then set the permissions on newly created files consistently, but for some reason it's reading them back wrongly. Perhaps it has to parse ls output and is getting it wrong.

Could you try running the equivalent of these commands, with appropriate URLs:

mbp@grace% python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bzrlib.transport import get_transport
>>> t = get_transport('sftp://localhost/home/mbp')
>>> t.stat('.')
<SFTPAttributes: [ size=16384 uid=1000 gid=1000 mode=040711 atime=1246340838 mtime=1246341088 ]>
>>> '%o' % t.stat('.').st_mode
'40711'
>>>

Changed in bzr:
milestone: 2.0 → none
Revision history for this message
Martin Pool (mbp) wrote :

I'd also add, perhaps we should have a configuration option to set permissions, rather than reading what's already there. That would be useful in general and would let you escape from this case.

Revision history for this message
Andrea Bolognani (kiyuko) wrote :

Here's what I get (personal information edited out):

$ python
Python 2.5.4 (r254:67916, Feb 17 2009, 20:16:45)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bzrlib.transport import get_transport
>>> t = get_transport('ftp://<username>:<password>@<ftphost>/<directory>');
>>> t.stat('.');
<bzrlib.transport.ftp.FtpStatResult object at 0x9bb39ec>
>>> '%o' % t.stat('.').st_mode
'40000'
>>>

I think it's worth noting you are using SFTP while I'm hitting the bug with plain FTP.

Revision history for this message
Andrea Bolognani (kiyuko) wrote :

Permissions for the tested directory are 0755 BTW.

Revision history for this message
Martin Pool (mbp) wrote :

Thanks Andrea.

I meant to use sftp as I don't have an ftp server handy. It was just an example. The bug is probably sftp-specific.

I filed bug 394559 requesting an option but for now this is probably simply a bug in the ftp transport, or rather a failure to workaround server behaviour.

What permission do you see if you use a regular ftp client to connect to this server and list the directory?

summary: - Broken permissions over FTP for .bzr/repository (and others)
+ FTPTransport.stat sees mode 000
Revision history for this message
Andrea Bolognani (kiyuko) wrote :

As I reported in my previous comment, the directory is reported to have 0755 permission.

Revision history for this message
Lukáš Zapletal (lzap) wrote :

Hello,

we have discussed my very similar situation on the list months ago. There is still no solution for this.

https://lists.ubuntu.com/archives/bazaar/2009q1/thread.html#54075

I thing here we do have bad design - Bazaar is trying to FTP CHMOD uploaded files according to their permissions on the client box. On the other side Bazaar does not store permissions (with the exception of executable bit). Here we do have a little inconsistency.

But the really big problem is when the client box is running MS Windows. On these systems you do not have UNIX-like file permissions and therefore you are unable to uplad a repository over FTP with other permissions than default ones - which are 700 for directories and 600 for files. This setting is the most secure but pretty unusable for those who needs to publish their branches over web server (e.g. Apache) which runs different user usually.

I recommend to come up with some settings like default_chmod or default_umask or something to allow Windows users to use FTP properly (and UNIX users to override their settings - for example in my HOME dir I keep files with 600 but I need to upload it with 666 onto the FTP server).

Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
Jelmer Vernooij (jelmer)
tags: removed: check-for-breezy
Changed in brz:
status: New → Triaged
importance: Undecided → Low
Jelmer Vernooij (jelmer)
Changed in brz:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.