mirror of
https://github.com/ValveSoftware/Proton.git
synced 2024-12-27 07:05:46 +03:00
proton: Don't follow symlinks when merging user dirs
Link: https://github.com/ValveSoftware/Proton/issues/5102
This commit is contained in:
parent
79ddcc5568
commit
c47dfe6a0b
10
proton
10
proton
@ -99,16 +99,16 @@ def merge_user_dir(src, dst):
|
|||||||
src_file = os.path.join(src_dir, dir_)
|
src_file = os.path.join(src_dir, dir_)
|
||||||
dst_file = os.path.join(dst_dir, dir_)
|
dst_file = os.path.join(dst_dir, dir_)
|
||||||
if os.path.islink(src_file) and not os.path.exists(dst_file):
|
if os.path.islink(src_file) and not os.path.exists(dst_file):
|
||||||
try_copy(src_file, dst_file, copy_metadata=True)
|
try_copy(src_file, dst_file, copy_metadata=True, follow_symlinks=False)
|
||||||
for file_ in files:
|
for file_ in files:
|
||||||
src_file = os.path.join(src_dir, file_)
|
src_file = os.path.join(src_dir, file_)
|
||||||
dst_file = os.path.join(dst_dir, file_)
|
dst_file = os.path.join(dst_dir, file_)
|
||||||
if not os.path.exists(dst_file):
|
if not os.path.exists(dst_file):
|
||||||
try_copy(src_file, dst_file, copy_metadata=True)
|
try_copy(src_file, dst_file, copy_metadata=True, follow_symlinks=False)
|
||||||
else:
|
else:
|
||||||
extant_dirs += dst_dir
|
extant_dirs += dst_dir
|
||||||
|
|
||||||
def try_copy(src, dst, add_write_perm=True, copy_metadata=False, optional=False):
|
def try_copy(src, dst, add_write_perm=True, copy_metadata=False, optional=False, follow_symlinks=True):
|
||||||
try:
|
try:
|
||||||
if os.path.isdir(dst):
|
if os.path.isdir(dst):
|
||||||
dstfile = dst + "/" + os.path.basename(src)
|
dstfile = dst + "/" + os.path.basename(src)
|
||||||
@ -120,9 +120,9 @@ def try_copy(src, dst, add_write_perm=True, copy_metadata=False, optional=False)
|
|||||||
os.remove(dst)
|
os.remove(dst)
|
||||||
|
|
||||||
if copy_metadata:
|
if copy_metadata:
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst, follow_symlinks=follow_symlinks)
|
||||||
else:
|
else:
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst, follow_symlinks=follow_symlinks)
|
||||||
|
|
||||||
if add_write_perm:
|
if add_write_perm:
|
||||||
new_mode = os.lstat(dstfile).st_mode | stat.S_IWUSR | stat.S_IWGRP
|
new_mode = os.lstat(dstfile).st_mode | stat.S_IWUSR | stat.S_IWGRP
|
||||||
|
Loading…
Reference in New Issue
Block a user