libxau: use rename(2) instead of symlink(2) when locking

This commit is contained in:
Leonid Pliushch 2018-10-02 15:44:51 +03:00 committed by Yaksh Bariya
parent 3faa2eeb0c
commit a840313ee9
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
2 changed files with 35 additions and 10 deletions

View File

@ -3,7 +3,7 @@ TERMUX_PKG_MAINTAINER="Leonid Plyushch <leonid.plyushch@gmail.com> @xeffyr"
TERMUX_PKG_HOMEPAGE=https://xorg.freedesktop.org/
TERMUX_PKG_DESCRIPTION="X11 authorisation library"
TERMUX_PKG_VERSION=1.0.8
TERMUX_PKG_REVISION=4
TERMUX_PKG_REVISION=5
TERMUX_PKG_SRCURL=https://xorg.freedesktop.org/releases/individual/lib/libXau-${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_SHA256=fdd477320aeb5cdd67272838722d6b7d544887dfe7de46e1e7cc0c27c2bea4f2
TERMUX_PKG_BUILD_DEPENDS="xorgproto"

View File

@ -1,12 +1,37 @@
diff -uNr libXau-1.0.8/AuLock.c libXau-1.0.8.mod/AuLock.c
--- libXau-1.0.8/AuLock.c 2013-05-25 01:04:09.000000000 +0300
+++ libXau-1.0.8.mod/AuLock.c 2017-11-23 14:08:52.004479977 +0200
@@ -91,7 +91,7 @@
} else
#endif
{
+++ libXau-1.0.8.mod/AuLock.c 2018-10-02 15:43:48.634507315 +0300
@@ -79,27 +79,12 @@
(void) close (creat_fd);
}
if (creat_fd != -1) {
-#ifdef HAVE_PATHCONF
- /* The file system may not support hard links, and pathconf should tell us that. */
- if (1 == pathconf(creat_name, _PC_LINK_MAX)) {
- if (-1 == rename(creat_name, link_name)) {
- /* Is this good enough? Perhaps we should retry. TEST */
- return LOCK_ERROR;
- } else {
- return LOCK_SUCCESS;
- }
- } else
-#endif
- {
- if (link (creat_name, link_name) != -1)
+ if (symlink (creat_name, link_name) != -1)
return LOCK_SUCCESS;
if (errno == ENOENT) {
creat_fd = -1; /* force re-creat next time around */
- return LOCK_SUCCESS;
- if (errno == ENOENT) {
- creat_fd = -1; /* force re-creat next time around */
- continue;
- }
- if (errno != EEXIST)
- return LOCK_ERROR;
- }
+ // Android disallows link(2), so forcing rename(2) here.
+ if (rename(creat_name, link_name) != -1) {
+ return LOCK_SUCCESS;
+ } else {
+ return LOCK_ERROR;
+ }
}
(void) sleep ((unsigned) timeout);
--retries;