]> git.pld-linux.org Git - packages/screen.git/blame - 60-644788-screen-4.1.0-4.0.3-interoperability.patch
- updated to 4.5.1
[packages/screen.git] / 60-644788-screen-4.1.0-4.0.3-interoperability.patch
CommitLineData
86ec8038
AM
1Author: Julien Cristau <jcristau@debian.org>
2Debian-Bug: #644788
3
4Author: Axel Beckert <abe@debian.org>
5Debian-Bug: #684342
6
7The following patch, while not all that pretty, seems to allow me to
8attach to a screen started with either the squeeze or sid version.
9I'm sure there's corner cases, but.
10
11Cheers,
12Julien
13
14Index: 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
19 } m;
20 };
21
22+struct old_msg
23+{
24+ int protocol_revision; /* reduce harm done by incompatible messages */
25+ int type;
26+ char m_tty[MAXPATHLEN]; /* ttyname */
27+ union
28+ {
29+ struct
30+ {
31+ int lflag;
32+ int aflag;
33+ int flowflag;
34+ int hheight; /* size of scrollback buffer */
35+ int nargs;
36+ char line[MAXPATHLEN];
37+ char dir[MAXPATHLEN];
38+ char screenterm[20]; /* is screen really "screen" ? */
39+ }
40+ create;
41+ struct
42+ {
43+ char auser[20 + 1]; /* username */
44+ int apid; /* pid of frontend */
45+ int adaptflag; /* adapt window size? */
46+ int lines, columns; /* display size */
47+ char preselect[20];
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 */
52+ }
53+ attach;
54+ struct
55+ {
56+ char duser[20 + 1]; /* username */
57+ int dpid; /* pid of frontend */
58+ }
59+ detach;
60+ struct
61+ {
62+ char auser[20 + 1]; /* username */
63+ int nargs;
64+ char cmd[MAXPATHLEN]; /* command */
65+ int apid; /* pid of frontend */
66+ char preselect[20];
67+ }
68+ command;
69+ char message[MAXPATHLEN * 2];
70+ } m;
71+};
72+
73 /*
74 * And the signals the attacher receives from the backend
75 */
76Index: 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()
81 }
82 if (left > 0)
83 {
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));
89 else
90 debug("No data on socket.\n");
91Index: 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;
96 return 0;
97 }
98
99+int
100+WriteOldMessage(struct msg *m)
101+{
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))
106+ {
107+ struct old_msg old_m;
108+ int s;
109+ int r, l = sizeof(old_m);
110+
111+ s = MakeClientSocket(0);
112+ if (s < 0)
113+ return 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;
127+ while(l > 0)
128+ {
129+ r = write(s, (char *)&old_m + (sizeof(struct old_msg) - l), l);
130+ if (r == -1 && errno == EINTR)
131+ continue;
132+ if (r == -1 || r == 0)
133+ return -1;
134+ l -= r;
135+ }
136+ close(s);
137+ }
138+ return 0;
139+}
140+
141
142 int
143 Attach(how)
144@@ -397,6 +439,7 @@ int how;
145 if (WriteMessage(lasts, &m))
146 Panic(errno, "WriteMessage");
147 close(lasts);
148+ WriteOldMessage(&m);
149 debug1("Attach(%d): sent\n", m.type);
150 #ifdef MULTIUSER
151 if (multi && (how == MSG_ATTACH || how == MSG_CONT))
This page took 0.092618 seconds and 4 git commands to generate.