~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/chroot.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-08-09 15:19:06 UTC
  • mfrom: (2681.1.7 send-bundle)
  • Revision ID: pqm@pqm.ubuntu.com-20070809151906-hdn9oyslf2qib2op
Allow omitting -o for bundle, add --format

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
89
89
    def append_file(self, relpath, f, mode=None):
90
90
        return self._call('append_file', relpath, f, mode)
91
91
 
92
 
    def _can_roundtrip_unix_modebits(self):
93
 
        return self.server.backing_transport._can_roundtrip_unix_modebits()
94
 
 
95
92
    def clone(self, relpath):
96
93
        return ChrootTransport(self.server, self.abspath(relpath))
97
94
 
107
104
        # state and thus the base cannot simply be handed out.
108
105
        # See the base class docstring for more details and
109
106
        # possible directions. For now we return the chrooted
110
 
        # url.
 
107
        # url. 
111
108
        return self.server.backing_transport.external_url()
112
109
 
113
110
    def get(self, relpath):
116
113
    def has(self, relpath):
117
114
        return self._call('has', relpath)
118
115
 
119
 
    def is_readonly(self):
120
 
        return self.server.backing_transport.is_readonly()
121
 
 
122
116
    def iter_files_recursive(self):
123
117
        backing_transport = self.server.backing_transport.clone(
124
118
            self._safe_relpath('.'))
139
133
    def mkdir(self, relpath, mode=None):
140
134
        return self._call('mkdir', relpath, mode)
141
135
 
142
 
    def open_write_stream(self, relpath, mode=None):
143
 
        return self._call('open_write_stream', relpath, mode)
144
 
 
145
136
    def put_file(self, relpath, f, mode=None):
146
137
        return self._call('put_file', relpath, f, mode)
147
138