version 1.16, 2001/03/18 12:07:52 |
version 1.16.2.2, 2002/03/09 00:20:43 |
|
|
#include "channels.h" |
#include "channels.h" |
#include "auth-options.h" |
#include "auth-options.h" |
#include "servconf.h" |
#include "servconf.h" |
|
#include "misc.h" |
|
|
/* Flags set authorized_keys flags */ |
/* Flags set authorized_keys flags */ |
int no_port_forwarding_flag = 0; |
int no_port_forwarding_flag = 0; |
|
|
} |
} |
cp = "from=\""; |
cp = "from=\""; |
if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
int mname, mip; |
|
const char *remote_ip = get_remote_ipaddr(); |
const char *remote_ip = get_remote_ipaddr(); |
const char *remote_host = get_canonical_hostname( |
const char *remote_host = get_canonical_hostname( |
options.reverse_mapping_check); |
options.verify_reverse_mapping); |
char *patterns = xmalloc(strlen(opts) + 1); |
char *patterns = xmalloc(strlen(opts) + 1); |
|
|
opts += strlen(cp); |
opts += strlen(cp); |
|
|
} |
} |
patterns[i] = 0; |
patterns[i] = 0; |
opts++; |
opts++; |
/* |
if (match_host_and_ip(remote_host, remote_ip, |
* Deny access if we get a negative |
patterns) != 1) { |
* match for the hostname or the ip |
xfree(patterns); |
* or if we get not match at all |
|
*/ |
|
mname = match_hostname(remote_host, patterns, |
|
strlen(patterns)); |
|
mip = match_hostname(remote_ip, patterns, |
|
strlen(patterns)); |
|
xfree(patterns); |
|
if (mname == -1 || mip == -1 || |
|
(mname != 1 && mip != 1)) { |
|
log("Authentication tried for %.100s with " |
log("Authentication tried for %.100s with " |
"correct key but not from a permitted " |
"correct key but not from a permitted " |
"host (host=%.200s, ip=%.200s).", |
"host (host=%.200s, ip=%.200s).", |
|
|
/* deny access */ |
/* deny access */ |
return 0; |
return 0; |
} |
} |
|
xfree(patterns); |
/* Host name matches. */ |
/* Host name matches. */ |
goto next_option; |
goto next_option; |
} |
} |
cp = "permitopen=\""; |
cp = "permitopen=\""; |
if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
|
char host[256], sport[6]; |
u_short port; |
u_short port; |
char *c, *ep; |
|
char *patterns = xmalloc(strlen(opts) + 1); |
char *patterns = xmalloc(strlen(opts) + 1); |
|
|
opts += strlen(cp); |
opts += strlen(cp); |
|
|
} |
} |
patterns[i] = 0; |
patterns[i] = 0; |
opts++; |
opts++; |
c = strchr(patterns, ':'); |
if (sscanf(patterns, "%255[^:]:%5[0-9]", host, sport) != 2 && |
if (c == NULL) { |
sscanf(patterns, "%255[^/]/%5[0-9]", host, sport) != 2) { |
debug("%.100s, line %lu: permitopen: missing colon <%.100s>", |
debug("%.100s, line %lu: Bad permitopen specification " |
file, linenum, patterns); |
"<%.100s>", file, linenum, patterns); |
packet_send_debug("%.100s, line %lu: missing colon", |
packet_send_debug("%.100s, line %lu: " |
file, linenum); |
"Bad permitopen specification", file, linenum); |
xfree(patterns); |
xfree(patterns); |
goto bad_option; |
goto bad_option; |
} |
} |
*c = 0; |
if ((port = a2port(sport)) == 0) { |
c++; |
debug("%.100s, line %lu: Bad permitopen port <%.100s>", |
port = strtol(c, &ep, 0); |
file, linenum, sport); |
if (c == ep) { |
packet_send_debug("%.100s, line %lu: " |
debug("%.100s, line %lu: permitopen: missing port <%.100s>", |
"Bad permitopen port", file, linenum); |
file, linenum, patterns); |
|
packet_send_debug("%.100s, line %lu: missing port", |
|
file, linenum); |
|
xfree(patterns); |
xfree(patterns); |
goto bad_option; |
goto bad_option; |
} |
} |
if (options.allow_tcp_forwarding) |
if (options.allow_tcp_forwarding) |
channel_add_permitted_opens(patterns, port); |
channel_add_permitted_opens(host, port); |
xfree(patterns); |
xfree(patterns); |
goto next_option; |
goto next_option; |
} |
} |