mirror of
https://git.savannah.gnu.org/git/screen.git
synced 2026-04-20 18:56:50 +02:00
Fix the screen command to autofocus the new window
This commit is contained in:
57
src/screen.c
57
src/screen.c
@@ -904,6 +904,29 @@ char **av;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SET_GUID() do \
|
||||
{ \
|
||||
setgid(real_gid); \
|
||||
setuid(real_uid); \
|
||||
eff_uid = real_uid; \
|
||||
eff_gid = real_gid; \
|
||||
} while (0)
|
||||
|
||||
#define SET_TTYNAME(fatal) do \
|
||||
{ \
|
||||
if (!(attach_tty = ttyname(0))) \
|
||||
{ \
|
||||
if (fatal) \
|
||||
Panic(0, "Must be connected to a terminal."); \
|
||||
else \
|
||||
attach_tty = ""; \
|
||||
} \
|
||||
else if (stat(attach_tty, &st)) \
|
||||
Panic(errno, "Cannot access '%s'", attach_tty); \
|
||||
if (strlen(attach_tty) >= MAXPATHLEN) \
|
||||
Panic(0, "TtyName too long - sorry."); \
|
||||
} while (0)
|
||||
|
||||
if (home == 0 || *home == '\0')
|
||||
home = ppp->pw_dir;
|
||||
if (strlen(LoginName) > 20)
|
||||
@@ -923,12 +946,7 @@ char **av;
|
||||
#endif
|
||||
|
||||
/* ttyname implies isatty */
|
||||
if (!(attach_tty = ttyname(0)))
|
||||
Panic(0, "Must be connected to a terminal.");
|
||||
if (strlen(attach_tty) >= MAXPATHLEN)
|
||||
Panic(0, "TtyName too long - sorry.");
|
||||
if (stat(attach_tty, &st))
|
||||
Panic(errno, "Cannot access '%s'", attach_tty);
|
||||
SET_TTYNAME(1);
|
||||
#ifdef MULTIUSER
|
||||
tty_mode = (int)st.st_mode & 0777;
|
||||
#endif
|
||||
@@ -1095,10 +1113,7 @@ char **av;
|
||||
if (multi)
|
||||
real_uid = multi_uid;
|
||||
#endif
|
||||
setgid(real_gid);
|
||||
setuid(real_uid);
|
||||
eff_uid = real_uid;
|
||||
eff_gid = real_gid;
|
||||
SET_GUID();
|
||||
i = FindSocket((int *)NULL, &fo, &oth, SockMatch);
|
||||
if (quietflag)
|
||||
exit(8 + (fo ? ((oth || i) ? 2 : 1) : 0) + i);
|
||||
@@ -1111,16 +1126,10 @@ char **av;
|
||||
if (cmdflag)
|
||||
{
|
||||
/* attach_tty is not mandatory */
|
||||
if ((attach_tty = ttyname(0)) == 0)
|
||||
attach_tty = "";
|
||||
if (strlen(attach_tty) >= MAXPATHLEN)
|
||||
Panic(0, "TtyName too long - sorry.");
|
||||
SET_TTYNAME(0);
|
||||
if (!*av)
|
||||
Panic(0, "Please specify a command.");
|
||||
setgid(real_gid);
|
||||
setuid(real_uid);
|
||||
eff_uid = real_uid;
|
||||
eff_gid = real_gid;
|
||||
SET_GUID();
|
||||
SendCmdMessage(sty, SockMatch, av);
|
||||
exit(0);
|
||||
}
|
||||
@@ -1147,10 +1156,9 @@ char **av;
|
||||
}
|
||||
if (!SockMatch && !mflag && sty)
|
||||
{
|
||||
setgid(real_gid);
|
||||
setuid(real_uid);
|
||||
eff_uid = real_uid;
|
||||
eff_gid = real_gid;
|
||||
/* attach_tty is not mandatory */
|
||||
SET_TTYNAME(0);
|
||||
SET_GUID();
|
||||
nwin_options.args = av;
|
||||
SendCreateMsg(sty, &nwin);
|
||||
exit(0);
|
||||
@@ -1185,10 +1193,7 @@ char **av;
|
||||
socknamebuf[NAME_MAX] = 0;
|
||||
#endif
|
||||
sprintf(SockPath + strlen(SockPath), "/%s", socknamebuf);
|
||||
setgid(real_gid);
|
||||
setuid(real_uid);
|
||||
eff_uid = real_uid;
|
||||
eff_gid = real_gid;
|
||||
SET_GUID();
|
||||
Attacher();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user