[PATCH libxtrans 3/3] Use fchmod() instead of chmod() when creating named pipes

Alan Coopersmith alan.coopersmith at oracle.com
Sun Nov 18 22:43:42 UTC 2018


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 Xtranslcl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Xtranslcl.c b/Xtranslcl.c
index 9eddf37..26b7f63 100644
--- a/Xtranslcl.c
+++ b/Xtranslcl.c
@@ -773,11 +773,12 @@ TRANS(NAMEDOpenPipe)(const char *server_path)
 		prmsg(1, "NAMEDOpenPipe: Can't open %s\n", server_path);
 		return(-1);
 	    }
-	    close(fd);
-	    if (chmod(server_path, (mode_t)0666) < 0) {
-		prmsg(1, "NAMEDOpenPipe: Can't open %s\n", server_path);
+	    if (fchmod(fd, (mode_t)0666) < 0) {
+		prmsg(1, "NAMEDOpenPipe: Can't chmod %s\n", server_path);
+		close(fd);
 		return(-1);
 	    }
+	    close(fd);
 	} else {
 	    prmsg(1, "NAMEDOpenPipe: stat on %s failed\n", server_path);
 	    return(-1);
-- 
2.15.2



More information about the xorg-devel mailing list