char *platform_default_s(const char *name)
{
if (!strcmp(name, "X11Display"))
- return getenv("DISPLAY");
+ return dupstr(getenv("DISPLAY"));
if (!strcmp(name, "TermType"))
- return getenv("TERM");
- if (!strcmp(name, "UserName")) {
- /*
- * Remote login username will default to the local username.
- */
- struct passwd *p;
- uid_t uid = getuid();
- char *user, *ret = NULL;
-
- /*
- * First, find who we think we are using getlogin. If this
- * agrees with our uid, we'll go along with it. This should
- * allow sharing of uids between several login names whilst
- * coping correctly with people who have su'ed.
- */
- user = getlogin();
- setpwent();
- if (user)
- p = getpwnam(user);
- else
- p = NULL;
- if (p && p->pw_uid == uid) {
- /*
- * The result of getlogin() really does correspond to
- * our uid. Fine.
- */
- ret = user;
- } else {
- /*
- * If that didn't work, for whatever reason, we'll do
- * the simpler version: look up our uid in the password
- * file and map it straight to a name.
- */
- p = getpwuid(uid);
- ret = p->pw_name;
- }
- endpwent();
-
- return ret;
- }
+ return dupstr(getenv("TERM"));
+ if (!strcmp(name, "UserName"))
+ return get_username();
return NULL;
}
{
int osize, esize;
- assert(len > 0);
-
if (is_stderr) {
bufchain_add(&stderr_data, data, len);
try_output(1);
printf(" -1 -2 force use of particular protocol version\n");
printf(" -C enable compression\n");
printf(" -i key private key file for authentication\n");
+ printf(" -s remote command is an SSH subsystem (SSH-2 only)\n");
exit(1);
}
int connopen;
int exitcode;
int errors;
+ int use_subsystem = 0;
void *ldisc, *logctx;
ssh_get_line = console_get_line;
continue;
} else if (!strcmp(p, "-batch")) {
console_batch_mode = 1;
+ } else if (!strcmp(p, "-s")) {
+ /* Save status to write to cfg later. */
+ use_subsystem = 1;
} else if (!strcmp(p, "-o")) {
if (argc <= 1) {
fprintf(stderr,
cmdline_run_saved(&cfg);
/*
+ * Apply subsystem status.
+ */
+ if (use_subsystem)
+ cfg.ssh_subsys = TRUE;
+
+ /*
* Trim a colon suffix off the hostname if it's there.
*/
cfg.host[strcspn(cfg.host, ":")] = '\0';