30 |
import base64, errno, re |
import base64, errno, re |
31 |
try: import posix1e |
try: import posix1e |
32 |
except ImportError: pass |
except ImportError: pass |
33 |
import static, Globals, metadata, connection, rorpiter, log, C, \ |
import static, Globals, eas_acls, connection, metadata, rorpiter, log, C, \ |
34 |
rpath, user_group |
rpath, user_group |
35 |
|
|
36 |
# When an ACL gets dropped, put name in dropped_acl_names. This is |
# When an ACL gets dropped, put name in dropped_acl_names. This is |
170 |
_extractor = EAExtractor |
_extractor = EAExtractor |
171 |
_object_to_record = staticmethod(EA2Record) |
_object_to_record = staticmethod(EA2Record) |
172 |
|
|
173 |
def join(cls, rorp_iter, rbdir, time, restrict_index): |
def join_ea_iter(rorp_iter, ea_iter): |
174 |
"""Add extended attribute information to existing rorp_iter""" |
"""Update a rorp iter by adding the information from ea_iter""" |
175 |
def helper(rorp_iter, ea_iter): |
for rorp, ea in rorpiter.CollateIterators(rorp_iter, ea_iter): |
176 |
"""Add EA information in ea_iter to rorp_iter""" |
assert rorp, "Missing rorp for index %s" % (ea.index,) |
177 |
collated = rorpiter.CollateIterators(rorp_iter, ea_iter) |
if not ea: ea = ExtendedAttributes(rorp.index) |
178 |
for rorp, ea in collated: |
rorp.set_ea(ea) |
179 |
assert rorp, (rorp, (ea.index, ea.attr_dict), time) |
yield rorp |
|
if not ea: ea = ExtendedAttributes(rorp.index) |
|
|
rorp.set_ea(ea) |
|
|
yield rorp |
|
|
|
|
|
ea_iter = cls.get_objects_at_time(rbdir, time, restrict_index) |
|
|
if not ea_iter: |
|
|
log.Log("Warning: Extended attributes file not found", 2) |
|
|
ea_iter = iter([]) |
|
|
return helper(rorp_iter, ea_iter) |
|
|
|
|
|
static.MakeClass(ExtendedAttributesFile) |
|
180 |
|
|
181 |
|
|
182 |
class AccessControlLists: |
class AccessControlLists: |
510 |
_extractor = ACLExtractor |
_extractor = ACLExtractor |
511 |
_object_to_record = staticmethod(ACL2Record) |
_object_to_record = staticmethod(ACL2Record) |
512 |
|
|
513 |
def join(cls, rorp_iter, rbdir, time, restrict_index): |
def join_acl_iter(rorp_iter, acl_iter): |
514 |
"""Add access control list information to existing rorp_iter""" |
"""Update a rorp iter by adding the information from acl_iter""" |
515 |
def helper(rorp_iter, acl_iter): |
for rorp, acl in rorpiter.CollateIterators(rorp_iter, acl_iter): |
516 |
"""Add ACL information in acl_iter to rorp_iter""" |
assert rorp, "Missing rorp for index %s" % (acl.index,) |
517 |
collated = rorpiter.CollateIterators(rorp_iter, acl_iter) |
if not acl: acl = AccessControlLists(rorp.index) |
518 |
for rorp, acl in collated: |
rorp.set_acl(acl) |
519 |
assert rorp, "Missing rorp for index %s" % (acl.index,) |
yield rorp |
520 |
if not acl: acl = AccessControlLists(rorp.index) |
|
|
rorp.set_acl(acl) |
|
|
yield rorp |
|
|
|
|
|
acl_iter = cls.get_objects_at_time(rbdir, time, restrict_index) |
|
|
if not acl_iter: |
|
|
log.Log("Warning: Access Control List file not found", 2) |
|
|
acl_iter = iter([]) |
|
|
return helper(rorp_iter, acl_iter) |
|
|
|
|
|
static.MakeClass(AccessControlListFile) |
|
|
|
|
|
|
|
|
def GetCombinedMetadataIter(rbdir, time, restrict_index = None, |
|
|
acls = None, eas = None): |
|
|
"""Return iterator of rorps from metadata and related files |
|
|
|
|
|
None will be returned if the metadata file is absent. If acls or |
|
|
eas is true, access control list or extended attribute information |
|
|
will be added. |
|
|
|
|
|
""" |
|
|
metadata_iter = metadata.MetadataFile.get_objects_at_time( |
|
|
rbdir, time, restrict_index) |
|
|
if not metadata_iter: |
|
|
log.Log("Warning, metadata file not found.\n" |
|
|
"Metadata will be read from filesystem.", 2) |
|
|
return None |
|
|
if eas: |
|
|
metadata_iter = ExtendedAttributesFile.join( |
|
|
metadata_iter, rbdir, time, restrict_index) |
|
|
if acls: |
|
|
metadata_iter = AccessControlListFile.join( |
|
|
metadata_iter, rbdir, time, restrict_index) |
|
|
return metadata_iter |
|
|
|
|
521 |
|
|
522 |
def rpath_acl_get(rp): |
def rpath_acl_get(rp): |
523 |
"""Get acls of given rpath rp. |
"""Get acls of given rpath rp. |