version 1.20, 2001/03/05 15:37:27 |
version 1.21, 2001/03/06 01:06:03 |
|
|
void |
void |
congreet(int s) |
congreet(int s) |
{ |
{ |
char buf[80]; |
char buf[80], *cp; |
|
size_t bufsiz; |
int n; |
int n; |
con *c = &fdcon[s]; |
con *c = &fdcon[s]; |
|
|
n = read(s, buf, sizeof(buf)); |
bufsiz = sizeof(buf); |
|
cp = buf; |
|
while (bufsiz-- && (n = read(s, cp, 1)) == 1 && *cp != '\n' && *cp != '\r') |
|
cp++; |
if (n < 0) { |
if (n < 0) { |
if (errno != ECONNREFUSED) |
if (errno != ECONNREFUSED) |
error("read (%s): %s", c->c_name, strerror(errno)); |
error("read (%s): %s", c->c_name, strerror(errno)); |
conrecycle(s); |
conrecycle(s); |
return; |
return; |
} |
} |
if (buf[n - 1] != '\n') { |
if (*cp != '\n' && *cp != '\r') { |
error("%s: bad greeting", c->c_name); |
error("%s: bad greeting", c->c_name); |
confree(s); |
confree(s); |
return; |
return; |
} |
} |
buf[n - 1] = '\0'; |
*cp = '\0'; |
fprintf(stderr, "# %s %s\n", c->c_name, buf); |
fprintf(stderr, "# %s %s\n", c->c_name, buf); |
n = snprintf(buf, sizeof buf, "SSH-1.5-OpenSSH-keyscan\r\n"); |
n = snprintf(buf, sizeof buf, "SSH-1.5-OpenSSH-keyscan\r\n"); |
if (atomicio(write, s, buf, n) != n) { |
if (atomicio(write, s, buf, n) != n) { |