1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
|
Description: Selected protocol refinement.
Let the manual pages express NEW-ENVIRON as the only
supported environment mechanism.
.
Let the diagnostic printout correctly identify the observed
modi of local flow control.
.
Let the server in debug mode correctly decode only the suboption
part of a status response, by ignoring the initial `IAC SB'.
.
Let the server and client decode suboptions containing also ENV_USERVAR
in addition to the already known ENV_VAR.
.
Make the command `status' be as verbose as in other clients.
.
Several calls to printsub() were missing in `telnet.cc', thus failing
to display options that the client sends to the server. Instead only
the received responses were display in some few negotiations, namely
TELOPT_TTYPE, TELOPT_TSPEED, TELOPT_XDISPLOC and TELOPT_LINEMODE
Author: Mats Erik Andersson <debian@gisladisker.se>
Forwarded: no
Last-Update: 2015-03-09
--- a/telnet/telnet.1
+++ b/telnet/telnet.1
@@ -98,7 +98,7 @@
.Ev USER
variable
of the
-.Ev ENVIRON
+.Ev NEW-ENVIRON
option if supported by the remote system. The username is retrieved
via
.Xr getlogin 3 .
@@ -139,7 +139,7 @@
sending the specified name as the
.Dv USER
environment variable, so it requires that the remote system support the
-.Ev TELNET ENVIRON
+.Ev TELNET NEW-ENVIRON
option. This option implies the
.Fl a
option, and may also be used with the
@@ -382,7 +382,7 @@
command is used to propagate environment variables across the
.Nm telnet
link using the
-.Dv TELNET ENVIRON
+.Dv TELNET NEW-ENVIRON
protocol option.
All variables exported from the shell are defined, but only the
.Ev DISPLAY
@@ -1109,7 +1109,7 @@
attempts to use it to perform automatic authentication. If the
.Dv TELNET AUTHENTICATION
option is not supported, the user's login name is propagated using the
-.Dv TELNET ENVIRON
+.Dv TELNET NEW-ENVIRON
option.
Setting this flag is the same as specifying the
.Ar a
@@ -1319,7 +1319,7 @@
environment variables.
Other environment variables may be propagated
to the other side via the
-.Dv TELNET ENVIRON
+.Dv TELNET NEW-ENVIRON
option.
.Sh FILES
.Bl -tag -width /etc/telnetrc -compact
--- a/telnetd/telnetd.8
+++ b/telnetd/telnetd.8
@@ -304,7 +304,6 @@
DO TSPEED
DO XDISPLOC
DO NEW-ENVIRON
-DO ENVIRON
WILL SUPPRESS GO AHEAD
DO ECHO
DO LINEMODE
@@ -426,9 +425,6 @@
.It "DO NEW-ENVIRON"
Indicates a desire to be able to request environment
variable information, as described in RFC 1572.
-.It "DO ENVIRON"
-Indicates a desire to be able to request environment
-variable information, as described in RFC 1408.
.It "DO LINEMODE"
Only sent if
.Nm telnetd
--- a/telnet/utilities.cc
+++ b/telnet/utilities.cc
@@ -339,10 +339,14 @@
break;
}
switch (pointer[1]) {
- case 0:
+ case LFLOW_OFF:
fprintf(NetTrace, " OFF"); break;
- case 1:
+ case LFLOW_ON:
fprintf(NetTrace, " ON"); break;
+ case LFLOW_RESTART_ANY:
+ fprintf(NetTrace, " RESTART-ANY"); break;
+ case LFLOW_RESTART_XON:
+ fprintf(NetTrace, " RESTART-XON"); break;
default:
fprintf(NetTrace, " %d (unknown)", pointer[1]);
}
@@ -525,7 +529,7 @@
pointer[2]&MODE_SOFT_TAB ? "|SOFT_TAB" : "",
pointer[2]&MODE_LIT_ECHO ? "|LIT_ECHO" : "",
pointer[2]&MODE_ACK ? "|ACK" : "");
- fprintf(NetTrace, "%s", tbuf[1] ? &tbuf[1] : "0");
+ fprintf(NetTrace, "%s", tbuf[0] ? &tbuf[1] : "0");
}
if (pointer[2]&~(MODE_MASK))
fprintf(NetTrace, " (0x%x)", pointer[2]);
@@ -651,10 +655,14 @@
register int noquote = 2;
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
+ case ENV_USERVAR:
case ENV_VAR:
if (pointer[1] == TELQUAL_SEND)
goto def_case;
- fprintf(NetTrace, "%s", "\" VAR " + noquote);
+ if (pointer[i] == ENV_VAR)
+ fprintf(NetTrace, "%s", "\" VAR " + noquote);
+ else
+ fprintf(NetTrace, "%s", "\" USERVAR " + noquote);
noquote = 2;
break;
@@ -695,7 +703,7 @@
if (TELOPT_OK(pointer[0]))
fprintf(NetTrace, "%s (unknown)", TELOPT(pointer[0]));
else
- fprintf(NetTrace, "%d (unknown)", pointer[i]);
+ fprintf(NetTrace, "%d (unknown)", pointer[0]);
for (i = 1; i < length; i++)
fprintf(NetTrace, " %d", pointer[i]);
break;
--- a/telnetd/utility.c
+++ b/telnetd/utility.c
@@ -728,10 +728,14 @@
break;
}
switch (pointer[1]) {
- case 0:
+ case LFLOW_OFF:
netoprintf(" OFF"); break;
- case 1:
+ case LFLOW_ON:
netoprintf(" ON"); break;
+ case LFLOW_RESTART_ANY:
+ netoprintf(" RESTART-ANY"); break;
+ case LFLOW_RESTART_XON:
+ netoprintf(" RESTART-XON"); break;
default:
netoprintf(" %d (unknown)", pointer[1]);
}
@@ -877,15 +881,6 @@
netoprintf("STATUS");
switch (pointer[1]) {
- default:
- if (pointer[1] == TELQUAL_SEND)
- netoprintf(" SEND");
- else
- netoprintf(" %d (unknown)", pointer[1]);
- for (i = 2; i < length; i++) {
- netoprintf(" ?%d?", pointer[i]);
- }
- break;
case TELQUAL_IS:
netoprintf(" IS\r\n");
@@ -937,6 +932,15 @@
}
}
break;
+ default:
+ if (pointer[1] == TELQUAL_SEND)
+ netoprintf(" SEND");
+ else
+ netoprintf(" %d (unknown)", pointer[1]);
+ for (i = 2; i < length; i++) {
+ netoprintf(" ?%d?", pointer[i]);
+ }
+ break;
}
break;
}
@@ -972,10 +976,14 @@
register int noquote = 2;
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
+ case ENV_USERVAR:
case ENV_VAR:
if (pointer[1] == TELQUAL_SEND)
goto def_case;
- netoprintf("%s", "\" VAR " + noquote);
+ if (pointer[i] == ENV_VAR)
+ netoprintf("%s", "\" VAR " + noquote);
+ else
+ netoprintf("%s", "\" USERVAR " + noquote);
noquote = 2;
break;
@@ -1165,7 +1173,7 @@
if (TELOPT_OK(pointer[0]))
netoprintf("%s (unknown)", TELOPT(pointer[0]));
else
- netoprintf("%d (unknown)", pointer[i]);
+ netoprintf("%d (unknown)", pointer[0]);
for (i = 1; i < length; i++) {
netoprintf(" %d", pointer[i]);
}
--- a/telnet/commands.cc
+++ b/telnet/commands.cc
@@ -1706,7 +1706,7 @@
}
static int status(void) {
- int notmuch = 1;
+ int notmuch = 0;
return dostatus(notmuch);
}
--- a/telnet/telnet.cc
+++ b/telnet/telnet.cc
@@ -744,6 +744,15 @@
name = gettermname();
netoring.xprintf("%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE,
TELQUAL_IS, name, IAC, SE);
+ {
+ unsigned char tbuf[7 + 20]; /* 20 chars for terminal name. */
+ int len;
+
+ len = snprintf((char *) tbuf, sizeof(tbuf), "%c%c%c%c%s%c%c",
+ IAC, SB, TELOPT_TTYPE, TELQUAL_IS, name, IAC, SE);
+ if (len > 6 && len < sizeof(tbuf))
+ printsub('>', &tbuf[2], len - 2);
+ }
}
break;
case TELOPT_TSPEED:
@@ -756,6 +765,16 @@
TerminalSpeeds(&iispeed, &oospeed);
netoring.xprintf("%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED,
TELQUAL_IS, oospeed, iispeed, IAC, SE);
+ {
+ unsigned char tbuf[8 + 20]; /* 20 characters for two speeds. */
+ int len;
+
+ len = snprintf((char *) tbuf, sizeof(tbuf), "%c%c%c%c%ld,%ld%c%c",
+ IAC, SB, TELOPT_TSPEED, TELQUAL_IS,
+ oospeed, iispeed, IAC, SE);
+ if (len > 7 && len < sizeof(tbuf))
+ printsub('>', &tbuf[2], len - 2);
+ }
}
break;
case TELOPT_LFLOW:
@@ -843,6 +862,15 @@
}
netoring.xprintf("%c%c%c%c%s%c%c", IAC, SB, TELOPT_XDISPLOC,
TELQUAL_IS, dp, IAC, SE);
+ {
+ unsigned char tbuf[7 + 30]; /* 30 chars for display name. */
+ int len;
+
+ len = snprintf((char *) tbuf, sizeof(tbuf), "%c%c%c%c%s%c%c",
+ IAC, SB, TELOPT_XDISPLOC, TELQUAL_IS, dp, IAC, SE);
+ if (len > 6 && len < sizeof(tbuf))
+ printsub('>', &tbuf[2], len - 2);
+ }
}
break;
@@ -898,6 +926,14 @@
netoring.xprintf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE,
DONT, cmd[0], IAC, SE);
+ {
+ unsigned char tbuf[8];
+ int len;
+
+ len = snprintf((char *) tbuf, sizeof(tbuf), "%c%c%c%c%c%c%c",
+ IAC, SB, TELOPT_LINEMODE, DONT, cmd[0], IAC, SE);
+ printsub('>', &tbuf[2], len - 2);
+ }
}
void lm_wont(unsigned char * /*cmd*/, int len) {
@@ -915,6 +951,14 @@
}
netoring.xprintf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE,
WONT, cmd[0], IAC, SE);
+ {
+ unsigned char tbuf[8];
+ int len;
+
+ len = snprintf((char *) tbuf, sizeof(tbuf), "%c%c%c%c%c%c%c",
+ IAC, SB, TELOPT_LINEMODE, WONT, cmd[0], IAC, SE);
+ printsub('>', &tbuf[2], len - 2);
+ }
}
void lm_dont(unsigned char * /*cmd*/, int len) {
@@ -938,6 +982,14 @@
netoring.xprintf("%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE, LM_MODE,
k, IAC, SE);
+ {
+ unsigned char tbuf[8];
+ int len;
+
+ len = snprintf((char *) tbuf, sizeof(tbuf), "%c%c%c%c%c%c%c",
+ IAC, SB, TELOPT_LINEMODE, LM_MODE, k, IAC, SE);
+ printsub('>', &tbuf[2], len - 2);
+ }
setconnmode(0); /* set changed mode */
}
@@ -1030,14 +1082,23 @@
}
void slc_import(int def) {
+ unsigned char cmd, tbuf[10];
+ int len;
+
if (def) {
+ cmd = SLC_DEFAULT;
netoring.xprintf("%c%c%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE,
LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE);
}
else {
+ cmd = SLC_VARIABLE;
netoring.xprintf("%c%c%c%c%c%c%c%c%c", IAC, SB, TELOPT_LINEMODE,
LM_SLC, 0, SLC_VARIABLE, 0, IAC, SE);
}
+
+ len = snprintf((char *) tbuf, sizeof(tbuf), "%c%c%c%c%c%c%c%c%c",
+ IAC, SB, TELOPT_LINEMODE, LM_SLC, 0, cmd, 0, IAC, SE);
+ printsub('>', &tbuf[2], len - 2);
}
void slc_export(void) {
|