mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
Uppity: configurable cwd for session.
All my instincts expect the shell subprocesses to start off in ~, so it's confusing if they start off in some random PuTTY checkout directory. So now we default to $HOME, and if I really do want the latter, I can use the new config option to reselect '.'.
This commit is contained in:
parent
e93d9ff305
commit
d5199e473f
@ -297,7 +297,8 @@ static void sesschan_start_backend(sesschan *sess, const char *cmd)
|
|||||||
|
|
||||||
sess->backend = pty_backend_create(
|
sess->backend = pty_backend_create(
|
||||||
&sess->seat, sess->child_logctx, sess->conf, NULL, cmd,
|
&sess->seat, sess->child_logctx, sess->conf, NULL, cmd,
|
||||||
sess->ttymodes, !sess->want_pty, env_to_unset);
|
sess->ttymodes, !sess->want_pty, sess->ssc->session_starting_dir,
|
||||||
|
env_to_unset);
|
||||||
backend_size(sess->backend, sess->wc, sess->hc);
|
backend_size(sess->backend, sess->wc, sess->hc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
typedef struct AuthPolicy AuthPolicy;
|
typedef struct AuthPolicy AuthPolicy;
|
||||||
|
|
||||||
struct SshServerConfig {
|
struct SshServerConfig {
|
||||||
|
const char *session_starting_dir;
|
||||||
|
|
||||||
RSAKey *rsa_kex_key;
|
RSAKey *rsa_kex_key;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -102,7 +104,7 @@ Channel *sesschan_new(SshChannel *c, LogContext *logctx,
|
|||||||
|
|
||||||
Backend *pty_backend_create(
|
Backend *pty_backend_create(
|
||||||
Seat *seat, LogContext *logctx, Conf *conf, char **argv, const char *cmd,
|
Seat *seat, LogContext *logctx, Conf *conf, char **argv, const char *cmd,
|
||||||
struct ssh_ttymodes ttymodes, bool pipes_instead_of_pty,
|
struct ssh_ttymodes ttymodes, bool pipes_instead_of_pty, const char *dir,
|
||||||
const char *const *env_vars_to_unset);
|
const char *const *env_vars_to_unset);
|
||||||
int pty_backend_exit_signum(Backend *be);
|
int pty_backend_exit_signum(Backend *be);
|
||||||
ptrlen pty_backend_exit_signame(Backend *be, char **aux_msg);
|
ptrlen pty_backend_exit_signame(Backend *be, char **aux_msg);
|
||||||
|
@ -857,7 +857,7 @@ static void copy_ttymodes_into_termios(
|
|||||||
*/
|
*/
|
||||||
Backend *pty_backend_create(
|
Backend *pty_backend_create(
|
||||||
Seat *seat, LogContext *logctx, Conf *conf, char **argv, const char *cmd,
|
Seat *seat, LogContext *logctx, Conf *conf, char **argv, const char *cmd,
|
||||||
struct ssh_ttymodes ttymodes, bool pipes_instead,
|
struct ssh_ttymodes ttymodes, bool pipes_instead, const char *dir,
|
||||||
const char *const *env_vars_to_unset)
|
const char *const *env_vars_to_unset)
|
||||||
{
|
{
|
||||||
int slavefd;
|
int slavefd;
|
||||||
@ -1145,6 +1145,9 @@ Backend *pty_backend_create(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dir)
|
||||||
|
chdir(dir);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIGINT, SIGQUIT and SIGPIPE may have been set to ignored by
|
* SIGINT, SIGQUIT and SIGPIPE may have been set to ignored by
|
||||||
* our parent, particularly by things like sh -c 'pterm &' and
|
* our parent, particularly by things like sh -c 'pterm &' and
|
||||||
@ -1274,7 +1277,7 @@ static const char *pty_init(Seat *seat, Backend **backend_handle,
|
|||||||
cmd = pty_argv[0];
|
cmd = pty_argv[0];
|
||||||
|
|
||||||
*backend_handle= pty_backend_create(
|
*backend_handle= pty_backend_create(
|
||||||
seat, logctx, conf, pty_argv, cmd, modes, false, NULL);
|
seat, logctx, conf, pty_argv, cmd, modes, false, NULL, NULL);
|
||||||
*realhost = dupstr("");
|
*realhost = dupstr("");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -312,6 +312,7 @@ static void show_help(FILE *fp)
|
|||||||
"(in SSH-1 format)\n"
|
"(in SSH-1 format)\n"
|
||||||
" --userkey KEY public key"
|
" --userkey KEY public key"
|
||||||
" acceptable for user authentication\n"
|
" acceptable for user authentication\n"
|
||||||
|
" --sessiondir DIR cwd for session subprocess (default $HOME)\n"
|
||||||
" --bannertext TEXT send TEXT as SSH-2 auth banner\n"
|
" --bannertext TEXT send TEXT as SSH-2 auth banner\n"
|
||||||
" --bannerfile FILE send contents of FILE as SSH-2 auth "
|
" --bannerfile FILE send contents of FILE as SSH-2 auth "
|
||||||
"banner\n"
|
"banner\n"
|
||||||
@ -527,6 +528,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
memset(&ssc, 0, sizeof(ssc));
|
memset(&ssc, 0, sizeof(ssc));
|
||||||
|
|
||||||
|
ssc.session_starting_dir = getenv("HOME");
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
/*
|
/*
|
||||||
* We're going to terminate with an error message below,
|
* We're going to terminate with an error message below,
|
||||||
@ -710,6 +713,8 @@ int main(int argc, char **argv)
|
|||||||
ssc.banner = ptrlen_from_strbuf(sb);
|
ssc.banner = ptrlen_from_strbuf(sb);
|
||||||
} else if (longoptarg(arg, "--bannertext", &val, &argc, &argv)) {
|
} else if (longoptarg(arg, "--bannertext", &val, &argc, &argv)) {
|
||||||
ssc.banner = ptrlen_from_asciz(val);
|
ssc.banner = ptrlen_from_asciz(val);
|
||||||
|
} else if (longoptarg(arg, "--sessiondir", &val, &argc, &argv)) {
|
||||||
|
ssc.session_starting_dir = val;
|
||||||
} else if (longoptarg(arg, "--kexinit-kex", &val, &argc, &argv)) {
|
} else if (longoptarg(arg, "--kexinit-kex", &val, &argc, &argv)) {
|
||||||
ssc.kex_override[KEXLIST_KEX] = ptrlen_from_asciz(val);
|
ssc.kex_override[KEXLIST_KEX] = ptrlen_from_asciz(val);
|
||||||
} else if (longoptarg(arg, "--kexinit-hostkey", &val, &argc, &argv)) {
|
} else if (longoptarg(arg, "--kexinit-hostkey", &val, &argc, &argv)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user