SFTP server should give human-friendly errors for name restrictions

Bug #33223 reported by Andrew Bennetts
6
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Medium
Andrew Bennetts

Bug Description

https://wiki.launchpad.canonical.com/SupermirrorFilesystemHierarchy specifies that the virtual filesystem presented over SFTP for push branches should have various restrictions. For example, ~user/product/branch directories can only be created if the logged in user is a member of user, product is the name of a product registered in Launchpad, and branch is valid (but unregistered for this user/product pair) branch name.

We want to return sensible errors to the user when they hit one of these restrictions. Ideally, the user experience would look something like:

% bzr push sftp://bazaar.launchpad.net/cool-features
bzr: error creating directory cool-features. Server said:
     branches must be inside a person or team directory

% bzr push sftp://bazaar.launchpad.net/~mbp/cool-features
bzr: error creating directory ~mbp/cool-features. Server said:
     branches must be inside a valid product name, or "+junk"

% bzr push sftp://bazaar.launchpad.net/~linux-kernel/v2.6/cool-features
bzr: error creating directory ~linux-kernel/v2.6/cool-features. Server said:
     you are not a member of the "linux-kernel" team

Currently, the SFTP server just sends generic permission denied errors. We need to determine if we can send more useful error messages via SFTP, and then make sure bzr reports them.

Tags: lp-code
Dafydd Harries (daf)
Changed in launchpad:
status: Unconfirmed → Confirmed
David Allouche (ddaa)
Changed in launchpad:
assignee: nobody → spiv
Revision history for this message
Andrew Bennetts (spiv) wrote :

From skimming the relevant code in the server, and in bzr and paramiko, this looks like it's close to working (if it doesn't already). I think it just needs a newer Twisted in the SFTP server.

We should write some tests that this works with the bzr client talking to our SFTP server.

David Allouche (ddaa)
Changed in launchpad-bazaar:
status: Confirmed → Fix Committed
Revision history for this message
Andrew Bennetts (spiv) wrote :

Fixed. Here's what it does now:

$ bzr push --create-prefix sftp://bazaar.launchpad.net/fdsjkfsdk
Please rename ~/.bazaar/branches.conf to ~/.bazaar/locations.conf
bzr: ERROR: Permission denied: u'fdsjkfsdk': [Errno 13] Branches must be inside a person or team directory.

$ bzr push --create-prefix sftp://bazaar.launchpad.net/~spiv/fdsjlfdjklfdsjkl/fdsjkfsdk
Please rename ~/.bazaar/branches.conf to ~/.bazaar/locations.conf

$ bzr push --create-prefix sftp://bazaar.launchpad.net/~fdsjkfsdk/ffdsjkfds/fkjdkd
Please rename ~/.bazaar/branches.conf to ~/.bazaar/locations.conf
bzr: ERROR: Permission denied: u'~fdsjkfsdk': [Errno 13] Branches must be inside a person or team directory.

There's maybe room for improvement (maybe it would be nice if bzr reported which specific operation was denied permission), but certainly the server is doing the right thing.

Changed in launchpad-bazaar:
status: Fix Committed → Fix Released
Revision history for this message
Andrew Bennetts (spiv) wrote :

I mis-pasted the second example of the new behaviour. Here's what it actually does:

$ bzr push --create-prefix sftp://bazaar.launchpad.net/~spiv/fdsjlfdjklfdsjkl/fdsjkfsdk
bzr: ERROR: Permission denied: '/~spiv/fdsjlfdjklfdsjkl': [Errno 13] Directories directly under a user directory must be named after a product name registered in Launchpad <https://launchpad.net/>.

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

When pushing to other people, I just get:
bzr: ERROR: Parent directory of sftp://bazaar.launchpad.net/~ubuntu-marketing/cool-features does not exist.

Which is not strictly true, but I'm not a member so it doesn't show up in sftp. Can this be improved?

Revision history for this message
Andrew Bennetts (spiv) wrote :

It is strictly true, for appropriate definitions of "exist" :)

In effect, every user will see a filesystem unique to them when they login to sftp://bazaar.launchpad.net. In your filesystem, it's "correct" to say that directories for teams you aren't a member of don't exist.

That said, it would be possible to change the message issued when a client tries to mkdir /~something to be "You are not a member of the 'something' team." But that's a out of scope for this bug -- please file a seperate bug for that (and for other improvements you'd like to see).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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