This file is indexed.

/usr/share/pyshared/txaws/s3/acls.py is in python-txaws 0.2.3-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from txaws.util import XML


PERMISSIONS = ("FULL_CONTROL",
               "WRITE",
               "WRITE_ACP",
               "READ",
               "READ_ACP")


class XMLMixin(object):

    def to_xml(self):
        return "".join(self._to_xml())


class AccessControlPolicy(XMLMixin):

    def __init__(self, owner=None, access_control_list=()):
        self.owner = owner
        self.access_control_list = access_control_list

    def _to_xml(self, buffer=None):
        if buffer is None:
            buffer = []
        buffer.append("<AccessControlPolicy>\n")
        if self.owner:
            self.owner._to_xml(buffer=buffer, indent=1)
        buffer.append("  <AccessControlList>\n")
        for grant in self.access_control_list:
            grant._to_xml(buffer=buffer, indent=2)
        buffer.append("  </AccessControlList>\n"
                   "</AccessControlPolicy>")
        return buffer

    @classmethod
    def from_xml(cls, xml_bytes):
        root = XML(xml_bytes)
        owner_node = root.find("Owner")
        owner = Owner(owner_node.findtext("ID"),
                      owner_node.findtext("DisplayName"))
        acl_node = root.find("AccessControlList")
        acl = []
        for grant_node in acl_node.findall("Grant"):
            grantee_node = grant_node.find("Grantee")
            grantee = Grantee(grantee_node.findtext("ID"),
                              grantee_node.findtext("DisplayName"))
            permission = grant_node.findtext("Permission")
            acl.append(Grant(grantee, permission))
        return cls(owner, acl)


class Grant(XMLMixin):

    def __init__(self, grantee, permission=None):
        self.grantee = grantee
        self.permission = permission

    def _set_permission(self, perm):
        if perm not in PERMISSIONS:
            raise ValueError("Invalid permission '%s'. Must be one of %s" %
                             (perm, ",".join(PERMISSIONS)))
        self._permission = perm

    def _get_permission(self):
        return self._permission

    permission = property(_get_permission, _set_permission)

    def _to_xml(self, buffer=None, indent=0):
        if buffer is None:
            buffer = []
        ws = " " * (indent * 2)
        buffer.append(ws + "<Grant>\n")
        if self.grantee:
            self.grantee._to_xml(buffer, indent + 1)
        if self.permission:
            buffer.append("%s  <Permission>%s</Permission>\n" % (
                          ws, self.permission))
        buffer.append(ws + "</Grant>\n")
        return buffer


class Owner(XMLMixin):

    def __init__(self, id, display_name):
        self.id = id
        self.display_name = display_name

    def _to_xml(self, buffer=None, indent=0):
        if buffer is None:
            buffer = []
        ws = " " * (indent * 2)
        buffer.append("%s<Owner>\n"
                      "%s  <ID>%s</ID>\n"
                      "%s  <DisplayName>%s</DisplayName>\n"
                      "%s</Owner>\n" % (ws, ws, self.id, ws, self.display_name,
                                        ws))
        return buffer


class Grantee(XMLMixin):

    def __init__(self, id="", display_name="", email_address="", uri=""):
        if id or display_name:
            msg = "Both 'id' and 'display_name' must be provided."
            if not (id and display_name):
                raise ValueError(msg)
        self.id = id
        self.display_name = display_name
        self.email_address = email_address
        self.uri = uri

    def _to_xml(self, buffer=None, indent=0):
        if buffer is None:
            buffer = []
        ws = " " * (indent * 2)
        if self.id and self.display_name:
            xsi_type = "CanonicalUser"
            value = ("%s  <ID>%s</ID>\n"
                     "%s  <DisplayName>%s</DisplayName>\n" % (
                        ws, self.id, ws, self.display_name))
        elif self.email_address:
            xsi_type = "AmazonCustomerByEmail"
            value = "%s  <EmailAddress>%s</EmailAddress>\n" % (
                ws, self.email_address)
        elif self.uri:
            xsi_type = "Group"
            value = "%s  <URI>%s</URI>\n" % (ws, self.uri)
        buffer.append("%s<Grantee "
                      'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
                      ' xsi:type="%s">\n'
                      "%s%s</Grantee>\n" % (ws, xsi_type, value, ws))
        return buffer