<s> from samba . dcerpc import xattr <EOL> import os <EOL> import samba . xattr_native <EOL> import shutil <EOL> def copyattrs ( frompath , topath ) : <EOL> """<STR_LIT>""" <EOL> for attr_name in ( xattr . XATTR_NTACL_NAME , "<STR_LIT>" ) : <EOL> try : <EOL> attribute = samba . xattr_native . wrap_getxattr ( frompath , <EOL> xattr . XATTR_NTACL_NAME ) <EOL> samba . xattr_native . wrap_setxattr ( topath , <EOL> xattr . XATTR_NTACL_NAME , <EOL> attribute ) <EOL> except Exception : <EOL> pass <EOL> def copytree_with_xattrs ( src , dst ) : <EOL> """<STR_LIT>""" <EOL> names = os . listdir ( src ) <EOL> os . makedirs ( dst ) <EOL> errors = [ ] <EOL> for name in names : <EOL> srcname = os . path . join ( src , name ) <EOL> dstname = os . path . join ( dst , name ) <EOL> if os . path . islink ( srcname ) : <EOL> linkto = os . readlink ( srcname ) <EOL> os . symlink ( linkto , dstname ) <EOL> elif os . path . isdir ( srcname ) : <EOL> copytree_with_xattrs ( srcname , dstname ) <EOL> else : <EOL> shutil . copy2 ( srcname , dstname ) <EOL> shutil . copystat ( src , dst ) <EOL> copyattrs ( src , dst ) </s>
