diff options
author | nicm <nicm> | 2018-05-24 09:42:49 +0000 |
---|---|---|
committer | nicm <nicm> | 2018-05-24 09:42:49 +0000 |
commit | b9a6162d2f9bea63c3ad421e9c3969eea2852b00 (patch) | |
tree | d944f370a3a21ea175f9fe958f9773146cdbfc1a /server-client.c | |
parent | 8f5903d7c3d75763ed5dc37ff49a39fe3b3b7831 (diff) | |
download | rtmux-b9a6162d2f9bea63c3ad421e9c3969eea2852b00.tar.gz rtmux-b9a6162d2f9bea63c3ad421e9c3969eea2852b00.tar.bz2 rtmux-b9a6162d2f9bea63c3ad421e9c3969eea2852b00.zip |
Make server_client_get_cwd used (almost) everywhere we need to work out
the cwd, and do not fall back to "." as it is pretty useless. GitHub
issue 1331.
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/server-client.c b/server-client.c index 4da9f08a..6a94bb56 100644 --- a/server-client.c +++ b/server-client.c @@ -1847,15 +1847,19 @@ server_client_add_message(struct client *c, const char *fmt, ...) /* Get client working directory. */ const char * -server_client_get_cwd(struct client *c) +server_client_get_cwd(struct client *c, struct session *s) { - struct session *s; + const char *home; if (c != NULL && c->session == NULL && c->cwd != NULL) return (c->cwd); + if (s != NULL && s->cwd != NULL) + return (s->cwd); if (c != NULL && (s = c->session) != NULL && s->cwd != NULL) return (s->cwd); - return ("."); + if ((home = find_home()) != NULL) + return (home); + return ("/"); } /* Resolve an absolute path or relative to client working directory. */ @@ -1867,7 +1871,7 @@ server_client_get_path(struct client *c, const char *file) if (*file == '/') path = xstrdup(file); else - xasprintf(&path, "%s/%s", server_client_get_cwd(c), file); + xasprintf(&path, "%s/%s", server_client_get_cwd(c, NULL), file); if (realpath(path, resolved) == NULL) return (path); free(path); |