~jimbaker/pyjuju/debug-relation-hook-context

« back to all changes in this revision

Viewing changes to juju/charm/directory.py

  • Committer: William Reade
  • Author(s): William Reade
  • Date: 2012-04-04 12:29:56 UTC
  • mfrom: (510.1.3 fix-charm-symlinks)
  • Revision ID: fwereade@gmail.com-20120404122956-ew1xusf09udwc0fm
When extracting charms, use only filetype mode bits to detect symlinkicity

We had been writing, and checking for, a magic value (in external_attr)
which happened to equal `(stat.S_IFLNK | 0755) << 16`; the charm store was
giving us one equal to `(stat.S_IFLNK | 0777) << 16`, and we weren't
considering that to be a symlink. We now just check the filetype and ignore
permissions on symlinks.

R=hazmat
CC=
https://codereview.appspot.com/5980045

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import zipfile
4
4
import tempfile
5
5
 
6
 
from juju.charm.base import CharmBase, get_revision, ZIP_SYMLINK_ATTR
 
6
from juju.charm.base import CharmBase, get_revision
7
7
from juju.charm.bundle import CharmBundle
8
8
from juju.charm.config import ConfigOptions
9
9
from juju.charm.errors import InvalidCharmFile
105
105
        info = zipfile.ZipInfo()
106
106
        info.filename = link_path
107
107
        info.create_system = 3
108
 
        info.external_attr = ZIP_SYMLINK_ATTR
 
108
        # Preserve the pre-existing voodoo mode in a slightly clearer form.
 
109
        info.external_attr = (stat.S_IFLNK | 0755) << 16
109
110
        zf.writestr(info, link_target)
110
111
 
111
112
    def _ignore(self, path):