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