diff options
author | Adam Jackson <ajax@redhat.com> | 2019-06-18 12:03:33 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2019-06-20 10:10:36 -0400 |
commit | 0932418d9b47e8240160bcbacbdc38b9bc9870d3 (patch) | |
tree | 70ba9af66679bb337bed181becb3524152f53791 | |
parent | 42239054b088dcdfc637880a8edf39b841c5ea51 (diff) | |
download | xorg-app-xauth-0932418d9b47e8240160bcbacbdc38b9bc9870d3.tar.gz |
process: Close a window where no authority file would exist
unlink()ing the old auth file before link()ing the temp to the new is
just silly. rename() is atomic and will happily clobber the destination,
and the only thing link() can give you here is the ability to fail on
filesystems that don't support hardlinks.
Fixes: xorg/app/xauth#2
-rw-r--r-- | process.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -890,19 +890,11 @@ auth_finalize(void) "%s: unable to write authority file %s\n", ProgramName, temp_name); } else { - (void) unlink (xauth_filename); -#if defined(WIN32) || defined(__UNIXOS2__) - if (rename(temp_name, xauth_filename) == -1) -#else - /* Attempt to rename() if link() fails, since this may be on a FS that does not support hard links */ - if (link (temp_name, xauth_filename) == -1 && rename(temp_name, xauth_filename) == -1) -#endif - { + if (rename(temp_name, xauth_filename) == -1) { fprintf (stderr, - "%s: unable to link authority file %s, use %s\n", + "%s: unable to rename authority file %s, use %s\n", ProgramName, xauth_filename, temp_name); - } else { - (void) unlink (temp_name); + unlink(temp_name); } } } |