aboutsummaryrefslogtreecommitdiff
path: root/ltoptions.m4
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@gotplt.org>2020-12-07 20:48:33 +0530
committerSiddhesh Poyarekar <siddhesh@gotplt.org>2020-12-07 20:48:33 +0530
commit014cc7f849e8209623fc99264814bce7b3b6faf2 (patch)
tree890c586d1a37643dfa2aa394935748a5e6542f51 /ltoptions.m4
parent1a1c3b4cc17687091cff5a368bd6f13742bcfdf8 (diff)
downloadgdb-014cc7f849e8209623fc99264814bce7b3b6faf2.zip
gdb-014cc7f849e8209623fc99264814bce7b3b6faf2.tar.gz
gdb-014cc7f849e8209623fc99264814bce7b3b6faf2.tar.bz2
binutils: Make smart_rename safe too
smart_rename is capable of handling symlinks by copying and it also tries to preserve ownership and permissions of files when they're overwritten during the rename. This is useful in objcopy where the file properties need to be preserved. However because smart_rename does this using file names, it leaves a race window between renames and permission fixes. This change removes this race window by using file descriptors from the original BFDs that were used to manipulate these files wherever possible. The file that is to be renamed is also passed as a file descriptor so that we use fchown/fchmod on the file descriptor, thus making sure that we only modify the file we have opened to write. Further, in case the file is to be overwritten (as is the case in ar or objcopy), the permissions that need to be restored are taken from the file descriptor that was opened for input so that integrity of the file status is maintained all the way through to the rename. binutils/ * rename.c * ar.c (write_archive) [!defined (_WIN32) || defined (__CYGWIN32__)]: Initialize TARGET_STAT and OFD to pass to SMART_RENAME. * arsup.c (ar_save) [defined (_WIN32) || defined (__CYGWIN32__)]: Likewise. * bucomm.h (smart_rename): Add new arguments to declaration. * objcopy.c (strip_main)[defined (_WIN32) || defined (__CYGWIN32__)]: Initialize COPYFD and pass to SMART_RENAME. (copy_main) [defined (_WIN32) || defined (__CYGWIN32__)]: Likewise. * rename.c (try_preserve_permissions): New function. (smart_rename): Use it and add new arguments.
Diffstat (limited to 'ltoptions.m4')
0 files changed, 0 insertions, 0 deletions