Sure looks good can you apply this thanks

-------- Original message --------
From: Thomas <tho...@xteddy.org> 
Date: 26/09/2013  12:06  (GMT+00:00) 
To: tmux-us...@lists.sf.net 
Cc: Thomas <tho...@xteddy.org> 
Subject: [PATCH] Don't treat TMUX_TMPDIR as a potential file 
 
The point of setting TMUX_TMPDIR is to then make any labels from -L go to
that directory.  In the case of makesocketpath() with no TMUX_TMPDIR set,
would set both the path and the default socket to a file.  The checking of
the permissions on the file worked fine in that case, but when TMUX_TMPDIR
is set, won't work on a directory.

This fixes the problem by ensuring the check on the permissions is performed
on directories only.
---
tmux.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tmux.c b/tmux.c
index 606c574..9c81cff 100644
--- a/tmux.c
+++ b/tmux.c
@@ -184,7 +184,8 @@ makesocketpath(const char *label)
errno = ENOTDIR;
return (NULL);
}
-       if (sb.st_uid != uid || (sb.st_mode & (S_IRWXG|S_IRWXO)) != 0) {
+       if (sb.st_uid != uid || (!S_ISDIR(sb.st_mode) &&
+        sb.st_mode & (S_IRWXG|S_IRWXO)) != 0) {
errno = EACCES;
return (NULL);
}
@@ -387,7 +388,8 @@ main(int argc, char **argv)
/* -L or default set. */
if (label != NULL) {
if ((path = makesocketpath(label)) == NULL) {
-        fprintf(stderr, "can't create socket\n");
+        fprintf(stderr, "can't create socket: %s\n",
+        strerror(errno));
exit(1);
}
}
-- 
1.8.4.rc1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to