~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/chroot.py

  • Committer: Robert Collins
  • Date: 2007-09-25 08:41:29 UTC
  • mto: This revision was merged to the branch mainline in revision 2862.
  • Revision ID: robertc@robertcollins.net-20070925084129-ca0kd25h23dmunrs
Review feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Implementation of Transport that prevents access to locations above a set
18
18
root.
33
33
 
34
34
class ChrootServer(Server):
35
35
    """User space 'chroot' facility.
36
 
 
 
36
    
37
37
    The server's get_url returns the url for a chroot transport mapped to the
38
38
    backing transport. The url is of the form chroot-xxx:/// so parent
39
39
    directories of the backing transport are not visible. The chroot url will
45
45
        self.backing_transport = backing_transport
46
46
 
47
47
    def _factory(self, url):
 
48
        assert url.startswith(self.scheme)
48
49
        return ChrootTransport(self, url)
49
50
 
50
51
    def get_url(self):
78
79
 
79
80
    def _safe_relpath(self, relpath):
80
81
        safe_relpath = self._combine_paths(self.base_path, relpath)
81
 
        if not safe_relpath.startswith('/'):
82
 
            raise ValueError(safe_relpath)
 
82
        assert safe_relpath.startswith('/')
83
83
        return safe_relpath[1:]
84
84
 
85
85
    # Transport methods
107
107
        # state and thus the base cannot simply be handed out.
108
108
        # See the base class docstring for more details and
109
109
        # possible directions. For now we return the chrooted
110
 
        # url.
 
110
        # url. 
111
111
        return self.server.backing_transport.external_url()
112
112
 
113
113
    def get(self, relpath):
116
116
    def has(self, relpath):
117
117
        return self._call('has', relpath)
118
118
 
119
 
    def is_readonly(self):
120
 
        return self.server.backing_transport.is_readonly()
121
 
 
122
119
    def iter_files_recursive(self):
123
120
        backing_transport = self.server.backing_transport.clone(
124
121
            self._safe_relpath('.'))