-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --pppd-call option. #270
Changes from 1 commit
28275e1
764d7df
4072b3e
025dea7
58ffeeb
50a3703
eea27be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
case "$PPP_IPPARAM" in | ||
openfortivpn*) | ||
rconf=/etc/resolv.conf | ||
[[ -f $rconf.openfortivpn ]] && cp -pv $rconf.openfortivpn $rconf | ||
exit 0 | ||
;; | ||
esac 2>&1 | logger -p daemon.debug -i -t "$0" | ||
|
||
true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
case "$PPP_IPPARAM" in | ||
openfortivpn*) | ||
rconf=/etc/resolv.conf | ||
routes=$(echo $PPP_IPPARAM | tr , ' ') | ||
for r in $routes; do | ||
[[ $r = "openfortivpn" ]] && continue | ||
com="ip route add ${r%/*} via ${r##*/}" | ||
echo $com | ||
$com | ||
done | ||
cp -pv $rconf $rconf.openfortivpn | ||
if [[ "$DNS1" ]]; then | ||
echo nameserver $DNS1 > $rconf | ||
[[ "$DNS2" ]] && [[ "$DNS1" != "$DNS2" ]] && echo nameserver $DNS2 >> $rconf | ||
fi | ||
exit 0 | ||
;; | ||
esac 2>&1 | logger -p daemon.debug -i -t "$0" | ||
|
||
true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
38400 | ||
:1.1.1.1 | ||
noipdefault | ||
noaccomp | ||
noauth | ||
default-asyncmap | ||
nopcomp | ||
receive-all | ||
nodefaultroute | ||
nodetach | ||
lcp-max-configure 40 | ||
mru 1354 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -515,12 +515,38 @@ int ipv4_protect_tunnel_route(struct tunnel *tunnel) | |
return ret; | ||
} | ||
|
||
static void add_text_route(struct tunnel *tunnel, const char *dest, | ||
const char *mask, const char *gw) | ||
{ | ||
size_t l0, l1; | ||
const char fmt[] = ",%s/%s/%s"; | ||
const char trigger[] = "openfortivpn"; | ||
char **target = &tunnel->config->pppd_ipparam; | ||
char *ptr; | ||
|
||
if (*target == NULL || strncmp(*target, trigger, strlen(trigger))) | ||
return; | ||
if (!dest || !mask || !gw) | ||
return; | ||
log_info("Registering route %s/%s via %s\n", dest, mask, gw); | ||
l0 = strlen(*target); | ||
l1 = strlen(fmt) + strlen(dest) + strlen(mask) + strlen(gw) + 1; | ||
if ((ptr = realloc(*target, l0 + l1))) { | ||
*target = ptr; | ||
snprintf(*target + l0, l1, fmt, dest, mask, gw); | ||
} else { | ||
int eno = errno; | ||
log_error("Could not reallocate array: %s\n", strerror(eno)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that the message is any better this way, just for mere consistency with the rest of the code:
|
||
} | ||
} | ||
|
||
int ipv4_add_split_vpn_route(struct tunnel *tunnel, char *dest, char *mask, | ||
char *gateway) | ||
{ | ||
struct rtentry *route; | ||
char env_var[24]; | ||
|
||
add_text_route(tunnel, dest, mask, gateway); | ||
if (tunnel->ipv4.split_routes == MAX_SPLIT_ROUTES) | ||
return ERR_IPV4_NO_MEM; | ||
if ((tunnel->ipv4.split_rt == NULL) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,6 +145,14 @@ static int pppd_run(struct tunnel *tunnel) | |
NULL // terminal null pointer required by execvp() | ||
}; | ||
|
||
if (tunnel->config->pppd_call != NULL) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just write:
Again I do not care myself but but the checkpatch.pl script of the Linux kernel emits a warning and we try to follow the Linux kernel coding style. |
||
int j = 1; | ||
args[j++] = "call"; | ||
args[j++] = tunnel->config->pppd_call; | ||
while (j < ARRAY_SIZE(args)) | ||
args[j++] = NULL; | ||
} | ||
|
||
// Dynamically get first NULL pointer so that changes of | ||
// args above don't need code changes here | ||
int i = ARRAY_SIZE(args) - 1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While log_error() may theoretically change the value of
errno
, for mere consistency with the rest of the code I suggest getting rid ofeno
and usingerrno
directly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually log_error() cannot change the value of
errno
before it is used as thestrerror(errno)
argument is evaluated before the function is called.