Skip to content

Commit

Permalink
pppd: Add ip-pre-up-script option (#510)
Browse files Browse the repository at this point in the history
This option allows a user to specify the path to the script
usually located at /etc/ppp/ip-pre-up, similarly to the
existing ip-up-script and ip-down-script options.

Signed-off-by: Tomas Paukrt <[email protected]>
  • Loading branch information
tpaukrt authored Sep 10, 2024
1 parent 9d82710 commit b918c07
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pppd/ipcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ ip_demand_conf(int u)
}
if (!sifaddr(u, wo->ouraddr, wo->hisaddr, GetMask(wo->ouraddr)))
return 0;
ipcp_script(PPP_PATH_IPPREUP, 1);
ipcp_script(path_ippreup, 1);
if (!sifup(u))
return 0;
if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
Expand Down Expand Up @@ -1932,7 +1932,7 @@ ipcp_up(fsm *f)
ifindex = if_nametoindex(ifname);

/* run the pre-up script, if any, and wait for it to finish */
ipcp_script(PPP_PATH_IPPREUP, 1);
ipcp_script(path_ippreup, 1);

/* check if preup script renamed the interface */
if (!if_indextoname(ifindex, ifname)) {
Expand Down
1 change: 1 addition & 0 deletions pppd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ main(int argc, char *argv[])

strlcpy(path_ipup, PPP_PATH_IPUP, MAXPATHLEN);
strlcpy(path_ipdown, PPP_PATH_IPDOWN, MAXPATHLEN);
strlcpy(path_ippreup, PPP_PATH_IPPREUP, MAXPATHLEN);

#ifdef PPP_WITH_IPV6CP
strlcpy(path_ipv6up, PPP_PATH_IPV6UP, MAXPATHLEN);
Expand Down
4 changes: 4 additions & 0 deletions pppd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ int connect_delay = 1000; /* wait this many ms after connect script */
int req_unit = -1; /* requested interface unit */
char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
char path_ippreup[MAXPATHLEN]; /* pathname of ip-pre-up script */
char req_ifname[IFNAMSIZ]; /* requested interface name */
bool multilink = 0; /* Enable multilink operation */
char *bundle_name = NULL; /* bundle name for multilink */
Expand Down Expand Up @@ -337,6 +338,9 @@ struct option general_options[] = {
{ "ip-down-script", o_string, path_ipdown,
"Set pathname of ip-down script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
{ "ip-pre-up-script", o_string, path_ippreup,
"Set pathname of ip-pre-up script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },

#ifdef PPP_WITH_IPV6CP
{ "ipv6-up-script", o_string, path_ipv6up,
Expand Down
1 change: 1 addition & 0 deletions pppd/pppd-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ extern int max_data_rate; /* max bytes/sec through charshunt */
extern int req_unit; /* interface unit number to use */
extern char path_ipup[]; /* pathname of ip-up script */
extern char path_ipdown[]; /* pathname of ip-down script */
extern char path_ippreup[]; /* pathname of ip-pre-up script */
extern char req_ifname[]; /* interface name to use (IFNAMSIZ) */
extern bool multilink; /* enable multilink operation (options.c) */
extern bool noendpoint; /* don't send or accept endpt. discrim. */
Expand Down

0 comments on commit b918c07

Please sign in to comment.