修正飞牛继承ACL并保留部署中止证据

这个提交包含在:
mac 于 2026-11-13 01:22:15 +08:00 提交
1 父节点 a20f1e674f
当前提交 0f3f14522c
3 个文件已更改
+99 -1

没有与搜索条件相匹配的文件

+14 -1
查看文件
@@ -42,6 +42,16 @@ def clone(original, destination, expected):
fd=os.open(str(destination),os.O_CREAT|os.O_EXCL|os.O_WRONLY,0o600)
os.close(fd)
shutil.copy2(original,destination)
if (destination.stat().st_uid,destination.stat().st_gid)!=(expected['uid'],expected['gid']):
os.chown(destination,expected['uid'],expected['gid'])
if stat.S_IMODE(destination.stat().st_mode)!=int(expected['mode'],8):
os.chmod(destination,int(expected['mode'],8))
# fnOS creates a system.trim_acl inherited from the parent even when the
# original has none. copy2 does not remove these destination-only xattrs.
for key in set(os.listxattr(destination))-set(expected['xattrs']):
os.removexattr(destination,key)
for key,value in expected['xattrs'].items():
os.setxattr(destination,key,base64.b64decode(value))
assert metadata(destination)==expected, 'Native metadata copy mismatch'
with destination.open('rb') as f: os.fsync(f.fileno())
stamp=datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=8))).strftime('%Y%m%d%H%M')
@@ -195,7 +205,10 @@ def main():
assert outcome['ok'], json.dumps(outcome,ensure_ascii=False)
print(json.dumps(dict(deployed=len(results), files=results), ensure_ascii=False, indent=2))
finally:
shutil.rmtree(lock)
def ignore_missing(function, path, exception):
if not isinstance(exception[1], FileNotFoundError):
raise exception[1]
shutil.rmtree(lock, onerror=ignore_missing)
if __name__ == '__main__':