1 Author: Julien Cristau <jcristau@debian.org>
4 Author: Axel Beckert <abe@debian.org>
7 The following patch, while not all that pretty, seems to allow me to
8 attach to a screen started with either the squeeze or sid version.
9 I'm sure there's corner cases, but.
14 Index: screen/screen.h
15 ===================================================================
16 --- screen.orig/screen.h 2012-08-09 01:01:28.000000000 +0200
17 +++ screen/screen.h 2012-08-09 01:01:28.000000000 +0200
18 @@ -240,6 +240,57 @@ struct msg
24 + int protocol_revision; /* reduce harm done by incompatible messages */
26 + char m_tty[MAXPATHLEN]; /* ttyname */
34 + int hheight; /* size of scrollback buffer */
36 + char line[MAXPATHLEN];
37 + char dir[MAXPATHLEN];
38 + char screenterm[20]; /* is screen really "screen" ? */
43 + char auser[20 + 1]; /* username */
44 + int apid; /* pid of frontend */
45 + int adaptflag; /* adapt window size? */
46 + int lines, columns; /* display size */
48 + int esc; /* his new escape character unless -1 */
49 + int meta_esc; /* his new meta esc character unless -1 */
50 + char envterm[20 + 1]; /* terminal type */
51 + int encoding; /* encoding of display */
56 + char duser[20 + 1]; /* username */
57 + int dpid; /* pid of frontend */
62 + char auser[20 + 1]; /* username */
64 + char cmd[MAXPATHLEN]; /* command */
65 + int apid; /* pid of frontend */
69 + char message[MAXPATHLEN * 2];
74 * And the signals the attacher receives from the backend
76 Index: screen/socket.c
77 ===================================================================
78 --- screen.orig/socket.c 2012-08-09 01:01:28.000000000 +0200
79 +++ screen/socket.c 2012-08-09 01:01:29.000000000 +0200
80 @@ -1067,7 +1067,9 @@ ReceiveMsg()
84 - if (left != sizeof(m))
85 + if (left == sizeof(struct msg) - sizeof(struct old_msg))
86 + ;/* old format message, ignore */
87 + else if (left != sizeof(m))
88 Msg(0, "Message %d of %d bytes too small", left, (int)sizeof(m));
90 debug("No data on socket.\n");
91 Index: screen/attacher.c
92 ===================================================================
93 --- screen.orig/attacher.c 2012-08-09 01:01:28.000000000 +0200
94 +++ screen/attacher.c 2012-08-09 01:32:08.000000000 +0200
95 @@ -133,6 +133,48 @@ struct msg *m;
100 +WriteOldMessage(struct msg *m)
102 + sleep(1); /* give the server some time to reopen the pipe */
103 + if (m->type == MSG_ATTACH && (m->m.attach.detachfirst == MSG_ATTACH ||
104 + m->m.attach.detachfirst == MSG_DETACH ||
105 + m->m.attach.detachfirst == MSG_POW_DETACH))
107 + struct old_msg old_m;
109 + int r, l = sizeof(old_m);
111 + s = MakeClientSocket(0);
114 + old_m.protocol_revision = (('m'<<24) | ('s'<<16) | ('g'<<8) | 0);
115 + old_m.type = m->type;
116 + memcpy(old_m.m_tty, m->m_tty, sizeof(old_m.m_tty));
117 + memcpy(old_m.m.attach.auser, m->m.attach.auser, sizeof(old_m.m.attach.auser));
118 + old_m.m.attach.apid = m->m.attach.apid;
119 + old_m.m.attach.adaptflag = m->m.attach.adaptflag;
120 + old_m.m.attach.lines = m->m.attach.lines;
121 + old_m.m.attach.columns = m->m.attach.columns;
122 + memcpy(old_m.m.attach.preselect, m->m.attach.preselect, sizeof(old_m.m.attach.preselect));
123 + old_m.m.attach.esc = m->m.attach.esc;
124 + old_m.m.attach.meta_esc = m->m.attach.meta_esc;
125 + memcpy(old_m.m.attach.envterm, m->m.attach.envterm, sizeof(old_m.m.attach.envterm));
126 + old_m.m.attach.encoding = m->m.attach.encoding;
129 + r = write(s, (char *)&old_m + (sizeof(struct old_msg) - l), l);
130 + if (r == -1 && errno == EINTR)
132 + if (r == -1 || r == 0)
144 @@ -397,6 +439,7 @@ int how;
145 if (WriteMessage(lasts, &m))
146 Panic(errno, "WriteMessage");
148 + WriteOldMessage(&m);
149 debug1("Attach(%d): sent\n", m.type);
151 if (multi && (how == MSG_ATTACH || how == MSG_CONT))