diff options
author | Thomas Adam <thomas@xteddy.org> | 2015-10-31 10:01:12 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2015-10-31 10:01:12 +0000 |
commit | 17f6c3be8eeb0b67d07f916026dab918795c0317 (patch) | |
tree | 08a10a780a8de977d4452c10a7a9c03db1ae1702 /server-client.c | |
parent | e8bb385d6d9d8a91b5fa78e906531afc02320b80 (diff) | |
parent | 01defc9f4965bb174e1d1295754d5a8695683054 (diff) | |
download | rtmux-17f6c3be8eeb0b67d07f916026dab918795c0317.tar.gz rtmux-17f6c3be8eeb0b67d07f916026dab918795c0317.tar.bz2 rtmux-17f6c3be8eeb0b67d07f916026dab918795c0317.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/server-client.c b/server-client.c index bf18cae7..a800a1aa 100644 --- a/server-client.c +++ b/server-client.c @@ -96,7 +96,7 @@ server_client_create(int fd) c->environ = environ_create(); c->fd = -1; - c->cwd = -1; + c->cwd = NULL; c->cmdq = cmdq_new(c); c->cmdq->client_exit = 1; @@ -192,7 +192,7 @@ server_client_lost(struct client *c) screen_free(&c->status); free(c->title); - close(c->cwd); + free((void *)c->cwd); evtimer_del(&c->repeat_timer); @@ -1107,7 +1107,7 @@ error: void server_client_dispatch_identify(struct client *c, struct imsg *imsg) { - const char *data; + const char *data, *home; size_t datalen; int flags; @@ -1140,8 +1140,12 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg) case MSG_IDENTIFY_CWD: if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_CWD string"); - if ((c->cwd = open(data, O_RDONLY)) == -1) - c->cwd = open("/", O_RDONLY); + if (access(data, X_OK) == 0) + c->cwd = xstrdup(data); + else if ((home = find_home()) != NULL) + c->cwd = xstrdup(home); + else + c->cwd = xstrdup("/"); log_debug("client %p IDENTIFY_CWD %s", c, data); break; case MSG_IDENTIFY_STDIN: |