version 1.250, 2016/02/08 23:40:12 |
version 1.251, 2016/04/06 06:42:17 |
|
|
{ |
{ |
struct Forward *fwd; |
struct Forward *fwd; |
extern uid_t original_real_uid; |
extern uid_t original_real_uid; |
|
int i; |
|
|
if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0 && |
if (newfwd->listen_port < IPPORT_RESERVED && original_real_uid != 0 && |
newfwd->listen_path == NULL) |
newfwd->listen_path == NULL) |
fatal("Privileged ports can only be forwarded by root."); |
fatal("Privileged ports can only be forwarded by root."); |
|
/* Don't add duplicates */ |
|
for (i = 0; i < options->num_local_forwards; i++) { |
|
if (forward_equals(newfwd, options->local_forwards + i)) |
|
return; |
|
} |
options->local_forwards = xreallocarray(options->local_forwards, |
options->local_forwards = xreallocarray(options->local_forwards, |
options->num_local_forwards + 1, |
options->num_local_forwards + 1, |
sizeof(*options->local_forwards)); |
sizeof(*options->local_forwards)); |
|
|
add_remote_forward(Options *options, const struct Forward *newfwd) |
add_remote_forward(Options *options, const struct Forward *newfwd) |
{ |
{ |
struct Forward *fwd; |
struct Forward *fwd; |
|
int i; |
|
|
|
/* Don't add duplicates */ |
|
for (i = 0; i < options->num_remote_forwards; i++) { |
|
if (forward_equals(newfwd, options->remote_forwards + i)) |
|
return; |
|
} |
options->remote_forwards = xreallocarray(options->remote_forwards, |
options->remote_forwards = xreallocarray(options->remote_forwards, |
options->num_remote_forwards + 1, |
options->num_remote_forwards + 1, |
sizeof(*options->remote_forwards)); |
sizeof(*options->remote_forwards)); |