summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authornicm <nicm>2015-10-31 08:13:58 +0000
committernicm <nicm>2015-10-31 08:13:58 +0000
commit01defc9f4965bb174e1d1295754d5a8695683054 (patch)
tree6f8095583d6176dffe130d6ff3b5dbc3f0e3150d /client.c
parent45f3cea263d1f99912cd6b353c91ccb872c26a71 (diff)
Because pledge(2) does not allow us to pass directory file descriptors
around, we can't use file descriptors for the working directory because we will be unable to pass it to a privileged process to tell it where to read or write files or spawn children. So move tmux back to using strings for the current working directory. We try to check it exists with access() when it is set but ultimately fall back to ~ if it fails at time of use (or / if that fails too).
Diffstat (limited to 'client.c')
-rw-r--r--client.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/client.c b/client.c
index 97382f63..008bd631 100644
--- a/client.c
+++ b/client.c
@@ -273,8 +273,10 @@ client_main(struct event_base *base, int argc, char **argv, int flags)
client_peer = proc_add_peer(client_proc, fd, client_dispatch, NULL);
/* Save these before pledge(). */
- if ((cwd = getcwd(path, sizeof path)) == NULL)
- cwd = "/";
+ if ((cwd = getcwd(path, sizeof path)) == NULL) {
+ if ((cwd = find_home()) == NULL)
+ cwd = "/";
+ }
if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
ttynam = "";