100-debian_ip-ip_option.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. pppd: Allow specifying ip-up and ip-down scripts
  2. This patch implements the "ip-up-script" and "ip-down-script" options which
  3. allow to specify the path of the ip-up and ip-down scripts to call.
  4. These options default to _PATH_IPUP and _PATH_IPDOWN to retain the
  5. existing behaviour.
  6. The patch originated from the Debian project.
  7. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  8. --- a/pppd/ipcp.c
  9. +++ b/pppd/ipcp.c
  10. @@ -1958,7 +1958,7 @@ ipcp_up(f)
  11. */
  12. if (ipcp_script_state == s_down && ipcp_script_pid == 0) {
  13. ipcp_script_state = s_up;
  14. - ipcp_script(_PATH_IPUP, 0);
  15. + ipcp_script(path_ipup, 0);
  16. }
  17. }
  18. @@ -2008,7 +2008,7 @@ ipcp_down(f)
  19. /* Execute the ip-down script */
  20. if (ipcp_script_state == s_up && ipcp_script_pid == 0) {
  21. ipcp_script_state = s_down;
  22. - ipcp_script(_PATH_IPDOWN, 0);
  23. + ipcp_script(path_ipdown, 0);
  24. }
  25. }
  26. @@ -2062,13 +2062,13 @@ ipcp_script_done(arg)
  27. case s_up:
  28. if (ipcp_fsm[0].state != OPENED) {
  29. ipcp_script_state = s_down;
  30. - ipcp_script(_PATH_IPDOWN, 0);
  31. + ipcp_script(path_ipdown, 0);
  32. }
  33. break;
  34. case s_down:
  35. if (ipcp_fsm[0].state == OPENED) {
  36. ipcp_script_state = s_up;
  37. - ipcp_script(_PATH_IPUP, 0);
  38. + ipcp_script(path_ipup, 0);
  39. }
  40. break;
  41. }
  42. --- a/pppd/main.c
  43. +++ b/pppd/main.c
  44. @@ -316,6 +316,9 @@ main(argc, argv)
  45. struct protent *protp;
  46. char numbuf[16];
  47. + strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
  48. + strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
  49. +
  50. link_stats_valid = 0;
  51. new_phase(PHASE_INITIALIZE);
  52. --- a/pppd/options.c
  53. +++ b/pppd/options.c
  54. @@ -114,6 +114,8 @@ char linkname[MAXPATHLEN]; /* logical na
  55. bool tune_kernel; /* may alter kernel settings */
  56. int connect_delay = 1000; /* wait this many ms after connect script */
  57. int req_unit = -1; /* requested interface unit */
  58. +char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
  59. +char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
  60. bool multilink = 0; /* Enable multilink operation */
  61. char *bundle_name = NULL; /* bundle name for multilink */
  62. bool dump_options; /* print out option values */
  63. @@ -299,6 +301,13 @@ option_t general_options[] = {
  64. "Unset user environment variable",
  65. OPT_A2PRINTER | OPT_NOPRINT, (void *)user_unsetprint },
  66. + { "ip-up-script", o_string, path_ipup,
  67. + "Set pathname of ip-up script",
  68. + OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
  69. + { "ip-down-script", o_string, path_ipdown,
  70. + "Set pathname of ip-down script",
  71. + OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
  72. +
  73. #ifdef HAVE_MULTILINK
  74. { "multilink", o_bool, &multilink,
  75. "Enable multilink operation", OPT_PRIO | 1 },
  76. --- a/pppd/pppd.h
  77. +++ b/pppd/pppd.h
  78. @@ -318,6 +318,8 @@ extern bool tune_kernel; /* May alter ke
  79. extern int connect_delay; /* Time to delay after connect script */
  80. extern int max_data_rate; /* max bytes/sec through charshunt */
  81. extern int req_unit; /* interface unit number to use */
  82. +extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
  83. +extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
  84. extern bool multilink; /* enable multilink operation */
  85. extern bool noendpoint; /* don't send or accept endpt. discrim. */
  86. extern char *bundle_name; /* bundle name for multilink */