]> git.ozlabs.org Git - ppp.git/commitdiff
pppd: Add ip-pre-up-script option (#510)
authorTomas Paukrt <44699103+tpaukrt@users.noreply.github.com>
Tue, 10 Sep 2024 10:13:59 +0000 (12:13 +0200)
committerGitHub <noreply@github.com>
Tue, 10 Sep 2024 10:13:59 +0000 (20:13 +1000)
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 <tomaspaukrt@email.cz>
pppd/ipcp.c
pppd/main.c
pppd/options.c
pppd/pppd-private.h

index 850e8cc894ce2aad3b42c85459d753b45580498a..06dfd894065753af2cdeabd68a624981065ebe05 100644 (file)
@@ -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))
@@ -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)) {
index b68917ff63105c62b67e7ce41a86a44ca9b62129..d8d62fe5fd33304db9c25d77bfafbde6e6d94878 100644 (file)
@@ -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);
index 227e615c956154b9e14676a0e0f5f1fa58ac41fc..2cdfaf271243337a0c930cd7d51852c2b4bc3c1f 100644 (file)
@@ -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 */
@@ -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,
index 46ce0c8bdceba2898ba2ad93b76201e647104272..a38f58a097ffda2158f7ca015e02e2d5bbd6401a 100644 (file)
@@ -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. */