1 |
--- tmux-1.6/tmux.c.bak 2012-01-30 12:55:27.533745642 -0500 |
2 |
+++ tmux-1.6/tmux.c 2012-01-30 12:57:06.285028356 -0500 |
3 |
@@ -237,6 +237,7 @@ |
4 |
struct passwd *pw; |
5 |
char *s, *path, *label, *home, **var; |
6 |
int opt, flags, quiet, keys; |
7 |
+ u_int gid; |
8 |
|
9 |
#if defined(DEBUG) && defined(__OpenBSD__) |
10 |
malloc_options = (char *) "AFGJPX"; |
11 |
@@ -390,6 +391,12 @@ |
12 |
} |
13 |
} |
14 |
} |
15 |
+ gid = getgid(); |
16 |
+ /* drop unnecessary privileges which were needed for makesocketpath() |
17 |
+ * to create the user directory under /var/run/tmux which is only |
18 |
+ * writeable for processes that have setgid utmp. */ |
19 |
+ if (setresgid(gid, gid, gid) != 0) |
20 |
+ return (NULL); |
21 |
if (label != NULL) |
22 |
xfree(label); |
23 |
if (realpath(path, socket_path) == NULL) |