mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Path from $TMUX does not need to be global anymore.
This commit is contained in:
parent
c6e9160c67
commit
6a539c00df
26
tmux.c
26
tmux.c
@ -46,7 +46,6 @@ char *shell_cmd;
|
|||||||
int debug_level;
|
int debug_level;
|
||||||
time_t start_time;
|
time_t start_time;
|
||||||
char socket_path[PATH_MAX];
|
char socket_path[PATH_MAX];
|
||||||
char *environ_path;
|
|
||||||
|
|
||||||
__dead void usage(void);
|
__dead void usage(void);
|
||||||
char *makesocketpath(const char *);
|
char *makesocketpath(const char *);
|
||||||
@ -191,10 +190,8 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *s, *path, *label, **var, tmp[PATH_MAX];
|
char *s, *path, *label, **var, tmp[PATH_MAX];
|
||||||
char in[256];
|
|
||||||
const char *home;
|
const char *home;
|
||||||
long long pid;
|
int opt, flags, keys;
|
||||||
int opt, flags, keys, session;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
malloc_options = (char *) "AFGJPX";
|
malloc_options = (char *) "AFGJPX";
|
||||||
@ -321,11 +318,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get path from environment. */
|
|
||||||
s = getenv("TMUX");
|
|
||||||
if (s != NULL && sscanf(s, "%255[^,],%lld,%d", in, &pid, &session) == 3)
|
|
||||||
environ_path = xstrdup(in);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out the socket path. If specified on the command-line with -S
|
* Figure out the socket path. If specified on the command-line with -S
|
||||||
* or -L, use it, otherwise try $TMUX or assume -L default.
|
* or -L, use it, otherwise try $TMUX or assume -L default.
|
||||||
@ -333,8 +325,15 @@ main(int argc, char **argv)
|
|||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
/* If no -L, use the environment. */
|
/* If no -L, use the environment. */
|
||||||
if (label == NULL) {
|
if (label == NULL) {
|
||||||
if (environ_path != NULL)
|
s = getenv("TMUX");
|
||||||
path = xstrdup(environ_path);
|
if (s != NULL) {
|
||||||
|
path = xstrdup(s);
|
||||||
|
path[strcspn (path, ",")] = '\0';
|
||||||
|
if (*path == '\0') {
|
||||||
|
free(path);
|
||||||
|
label = xstrdup("default");
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
label = xstrdup("default");
|
label = xstrdup("default");
|
||||||
}
|
}
|
||||||
@ -343,14 +342,15 @@ main(int argc, char **argv)
|
|||||||
if (label != NULL) {
|
if (label != NULL) {
|
||||||
if ((path = makesocketpath(label)) == NULL) {
|
if ((path = makesocketpath(label)) == NULL) {
|
||||||
fprintf(stderr, "can't create socket: %s\n",
|
fprintf(stderr, "can't create socket: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(label);
|
free(label);
|
||||||
|
|
||||||
if (strlcpy(socket_path, path, sizeof socket_path) >= sizeof socket_path) {
|
if (strlcpy(socket_path, path, sizeof socket_path) >=
|
||||||
|
sizeof socket_path) {
|
||||||
fprintf(stderr, "socket path too long: %s\n", path);
|
fprintf(stderr, "socket path too long: %s\n", path);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
1
tmux.h
1
tmux.h
@ -1412,7 +1412,6 @@ extern char *shell_cmd;
|
|||||||
extern int debug_level;
|
extern int debug_level;
|
||||||
extern time_t start_time;
|
extern time_t start_time;
|
||||||
extern char socket_path[PATH_MAX];
|
extern char socket_path[PATH_MAX];
|
||||||
extern char *environ_path;
|
|
||||||
void logfile(const char *);
|
void logfile(const char *);
|
||||||
const char *getshell(void);
|
const char *getshell(void);
|
||||||
int checkshell(const char *);
|
int checkshell(const char *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user