|
Lines 129-140
static ForwardPermission *permitted_opens = NULL;
Link Here
|
| 129 |
/* List of all permitted host/port pairs to connect by the admin. */ |
129 |
/* List of all permitted host/port pairs to connect by the admin. */ |
| 130 |
static ForwardPermission *permitted_adm_opens = NULL; |
130 |
static ForwardPermission *permitted_adm_opens = NULL; |
| 131 |
|
131 |
|
|
|
132 |
/* List of all permitted remote host/port pairs to connect by the user. */ |
| 133 |
static ForwardPermission *permitted_listens = NULL; |
| 134 |
|
| 132 |
/* Number of permitted host/port pairs in the array permitted by the user. */ |
135 |
/* Number of permitted host/port pairs in the array permitted by the user. */ |
| 133 |
static int num_permitted_opens = 0; |
136 |
static int num_permitted_opens = 0; |
| 134 |
|
137 |
|
| 135 |
/* Number of permitted host/port pair in the array permitted by the admin. */ |
138 |
/* Number of permitted host/port pair in the array permitted by the admin. */ |
| 136 |
static int num_adm_permitted_opens = 0; |
139 |
static int num_adm_permitted_opens = 0; |
| 137 |
|
140 |
|
|
|
141 |
/* Number of permitted remote host/port pairs. */ |
| 142 |
static int num_permitted_listens = 0; |
| 143 |
|
| 138 |
/* special-case port number meaning allow any port */ |
144 |
/* special-case port number meaning allow any port */ |
| 139 |
#define FWD_PERMIT_ANY_PORT 0 |
145 |
#define FWD_PERMIT_ANY_PORT 0 |
| 140 |
|
146 |
|
|
Lines 148-153
static int num_adm_permitted_opens = 0;
Link Here
|
| 148 |
*/ |
154 |
*/ |
| 149 |
static int all_opens_permitted = 0; |
155 |
static int all_opens_permitted = 0; |
| 150 |
|
156 |
|
|
|
157 |
/** |
| 158 |
* If this is true, all remote opens are permitted. |
| 159 |
*/ |
| 160 |
static int all_listens_permitted = 0; |
| 151 |
|
161 |
|
| 152 |
/* -- X11 forwarding */ |
162 |
/* -- X11 forwarding */ |
| 153 |
|
163 |
|
|
Lines 3503-3508
channel_add_permitted_opens(char *host, int port)
Link Here
|
| 3503 |
all_opens_permitted = 0; |
3513 |
all_opens_permitted = 0; |
| 3504 |
} |
3514 |
} |
| 3505 |
|
3515 |
|
|
|
3516 |
void |
| 3517 |
channel_add_permitted_listens(char *host, int port) |
| 3518 |
{ |
| 3519 |
debug("allow remote port forwarding to host %s port %d", host, port); |
| 3520 |
|
| 3521 |
permitted_listens = xreallocarray(permitted_listens, |
| 3522 |
num_permitted_listens + 1, sizeof(*permitted_listens)); |
| 3523 |
permitted_listens[num_permitted_listens].host_to_connect = xstrdup(host); |
| 3524 |
permitted_listens[num_permitted_listens].port_to_connect = port; |
| 3525 |
permitted_listens[num_permitted_listens].listen_host = NULL; |
| 3526 |
permitted_listens[num_permitted_listens].listen_path = NULL; |
| 3527 |
permitted_listens[num_permitted_listens].listen_port = 0; |
| 3528 |
num_permitted_listens++; |
| 3529 |
|
| 3530 |
all_listens_permitted = 0; |
| 3531 |
} |
| 3532 |
|
| 3506 |
/* |
3533 |
/* |
| 3507 |
* Update the listen port for a dynamic remote forward, after |
3534 |
* Update the listen port for a dynamic remote forward, after |
| 3508 |
* the actual 'newport' has been allocated. If 'newport' < 0 is |
3535 |
* the actual 'newport' has been allocated. If 'newport' < 0 is |
|
Lines 3592-3597
channel_clear_adm_permitted_opens(void)
Link Here
|
| 3592 |
} |
3619 |
} |
| 3593 |
|
3620 |
|
| 3594 |
void |
3621 |
void |
|
|
3622 |
channel_clear_permitted_listens(void) |
| 3623 |
{ |
| 3624 |
int i; |
| 3625 |
|
| 3626 |
for (i = 0; i < num_permitted_listens; i++) { |
| 3627 |
free(permitted_listens[i].host_to_connect); |
| 3628 |
free(permitted_listens[i].listen_host); |
| 3629 |
free(permitted_listens[i].listen_path); |
| 3630 |
} |
| 3631 |
free(permitted_listens); |
| 3632 |
permitted_listens = NULL; |
| 3633 |
num_permitted_listens = 0; |
| 3634 |
} |
| 3635 |
|
| 3636 |
void |
| 3595 |
channel_print_adm_permitted_opens(void) |
3637 |
channel_print_adm_permitted_opens(void) |
| 3596 |
{ |
3638 |
{ |
| 3597 |
int i; |
3639 |
int i; |
|
Lines 3885-3890
channel_connect_to_path(const char *path, char *ctype, char *rname)
Link Here
|
| 3885 |
return connect_to(path, PORT_STREAMLOCAL, ctype, rname); |
3927 |
return connect_to(path, PORT_STREAMLOCAL, ctype, rname); |
| 3886 |
} |
3928 |
} |
| 3887 |
|
3929 |
|
|
|
3930 |
/* Check if connecting to that port is permitted and connect. */ |
| 3931 |
int |
| 3932 |
channel_connect_check_permitted_listens(const char *host, u_short port) |
| 3933 |
{ |
| 3934 |
int i, permit = 1; |
| 3935 |
|
| 3936 |
permit = all_listens_permitted; |
| 3937 |
if (!permit) { |
| 3938 |
for (i = 0; i < num_permitted_listens; i++) |
| 3939 |
if (open_match(&permitted_listens[i], host, port)) { |
| 3940 |
permit = 1; |
| 3941 |
break; |
| 3942 |
} |
| 3943 |
} |
| 3944 |
|
| 3945 |
if (!permit) { |
| 3946 |
logit("Received request for remote forward to host %.100s port %d, " |
| 3947 |
"but the request was denied.", host, port); |
| 3948 |
return -1; |
| 3949 |
} |
| 3950 |
|
| 3951 |
return 0; |
| 3952 |
} |
| 3953 |
|
| 3888 |
void |
3954 |
void |
| 3889 |
channel_send_window_changes(void) |
3955 |
channel_send_window_changes(void) |
| 3890 |
{ |
3956 |
{ |