diff options
author | C. Scott Ananian <cscott@laptop.org> | 2008-09-26 04:47:35 (GMT) |
---|---|---|
committer | C. Scott Ananian <cscott@laptop.org> | 2008-09-28 18:24:46 (GMT) |
commit | 897428c794ba00a150127bec522128c507ee946c (patch) | |
tree | 161663c8db5666db112eb2fa88a35b5eb342412c /src/sugar/bundle | |
parent | 404a7b546a22b323d532aaaaad164bb36dd967a6 (diff) |
Trac #8674: sanity-check bundle root; don't delete install_root on failure.
The software updater was deleting ~/Activities when it encountered a bad
bundle. Two separate issues: we didn't sanity check the bundle root to
ensure it wasn't '.' or '..' or something crazy like that, and our "clean
up on failure" code was deleting the install_root instead of the activity
root (!). This was a regression introduced by the fix for #7733 in
commit db2d1c42e2481d6dbc15405840ac23e46eab7318 (0.82.2).
Diffstat (limited to 'src/sugar/bundle')
-rw-r--r-- | src/sugar/bundle/bundle.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py index 0319b9e..e9bd9f8 100644 --- a/src/sugar/bundle/bundle.py +++ b/src/sugar/bundle/bundle.py @@ -86,6 +86,9 @@ class Bundle: del file_names[0] self._zip_root_dir = file_names[0].split('/')[0] + if self._zip_root_dir.startswith('.'): + raise MalformedBundleException( + 'root directory starts with .') if self._unzipped_extension is not None: (name_, ext) = os.path.splitext(self._zip_root_dir) if ext != self._unzipped_extension: @@ -162,7 +165,8 @@ class Bundle: if os.spawnlp(os.P_WAIT, 'unzip', 'unzip', '-o', self._path, '-x', 'mimetype', '-d', install_dir): # clean up install dir after failure - shutil.rmtree(install_dir, ignore_errors=True) + shutil.rmtree(os.path.join(install_dir, self._zip_root_dir), + ignore_errors=True) # indicate failure. raise ZipExtractException |