16_all_auth-fail.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. diff -Nru ppp-2.4.5.orig/pppd/auth.c ppp-2.4.5/pppd/auth.c
  2. --- ppp-2.4.5.orig/pppd/auth.c 2010-08-08 09:58:19.000000000 +0200
  3. +++ ppp-2.4.5/pppd/auth.c 2010-08-08 10:06:06.000000000 +0200
  4. @@ -259,7 +259,7 @@
  5. struct wordlist **, struct wordlist **,
  6. char *, int));
  7. static void free_wordlist __P((struct wordlist *));
  8. -static void auth_script __P((char *));
  9. +static void auth_script __P((char *, int));
  10. static void auth_script_done __P((void *));
  11. static void set_allowed_addrs __P((int, struct wordlist *, struct wordlist *));
  12. static int some_ip_ok __P((struct wordlist *));
  13. @@ -690,7 +690,7 @@
  14. if (auth_script_state == s_up && auth_script_pid == 0) {
  15. update_link_stats(unit);
  16. auth_script_state = s_down;
  17. - auth_script(_PATH_AUTHDOWN);
  18. + auth_script(_PATH_AUTHDOWN, 0);
  19. }
  20. }
  21. if (!doing_multilink) {
  22. @@ -822,7 +822,7 @@
  23. auth_state = s_up;
  24. if (auth_script_state == s_down && auth_script_pid == 0) {
  25. auth_script_state = s_up;
  26. - auth_script(_PATH_AUTHUP);
  27. + auth_script(_PATH_AUTHUP, 0);
  28. }
  29. }
  30. @@ -923,6 +923,7 @@
  31. * Authentication failure: take the link down
  32. */
  33. status = EXIT_PEER_AUTH_FAILED;
  34. + auth_script(_PATH_AUTHFAIL, 1);
  35. lcp_close(unit, "Authentication failed");
  36. }
  37. @@ -1001,6 +1002,7 @@
  38. * authentication secrets.
  39. */
  40. status = EXIT_AUTH_TOPEER_FAILED;
  41. + auth_script(_PATH_AUTHFAIL, 1);
  42. lcp_close(unit, "Failed to authenticate ourselves to peer");
  43. }
  44. @@ -1233,6 +1235,8 @@
  45. if (user[0] == 0 && !explicit_user)
  46. strlcpy(user, our_name, sizeof(user));
  47. + script_setenv("LOCALNAME", user, 0);
  48. +
  49. /*
  50. * If we have a default route, require the peer to authenticate
  51. * unless the noauth option was given or the real user is root.
  52. @@ -2314,13 +2318,13 @@
  53. case s_up:
  54. if (auth_state == s_down) {
  55. auth_script_state = s_down;
  56. - auth_script(_PATH_AUTHDOWN);
  57. + auth_script(_PATH_AUTHDOWN, 0);
  58. }
  59. break;
  60. case s_down:
  61. if (auth_state == s_up) {
  62. auth_script_state = s_up;
  63. - auth_script(_PATH_AUTHUP);
  64. + auth_script(_PATH_AUTHUP, 0);
  65. }
  66. break;
  67. }
  68. @@ -2331,8 +2335,9 @@
  69. * interface-name peer-name real-user tty speed
  70. */
  71. static void
  72. -auth_script(script)
  73. +auth_script(script, wait)
  74. char *script;
  75. + int wait;
  76. {
  77. char strspeed[32];
  78. struct passwd *pw;
  79. @@ -2356,5 +2361,8 @@
  80. argv[5] = strspeed;
  81. argv[6] = NULL;
  82. - auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL, 0);
  83. + if (wait)
  84. + run_program(script, argv, 0, NULL, NULL, 1);
  85. + else
  86. + auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL, 0);
  87. }
  88. diff -Nru ppp-2.4.5.orig/pppd/pathnames.h ppp-2.4.5/pppd/pathnames.h
  89. --- ppp-2.4.5.orig/pppd/pathnames.h 2009-11-16 23:26:07.000000000 +0100
  90. +++ ppp-2.4.5/pppd/pathnames.h 2010-08-08 10:06:06.000000000 +0200
  91. @@ -27,6 +27,7 @@
  92. #define _PATH_IPPREUP _ROOT_PATH "/etc/ppp/ip-pre-up"
  93. #define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up"
  94. #define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
  95. +#define _PATH_AUTHFAIL _ROOT_PATH "/etc/ppp/auth-fail"
  96. #define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options."
  97. #define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors"
  98. #define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/"
  99. diff -Nru ppp-2.4.5.orig/pppd/pppd.8 ppp-2.4.5/pppd/pppd.8
  100. --- ppp-2.4.5.orig/pppd/pppd.8 2009-11-16 23:26:07.000000000 +0100
  101. +++ ppp-2.4.5/pppd/pppd.8 2010-08-08 10:06:06.000000000 +0200
  102. @@ -1553,8 +1553,8 @@
  103. Pppd invokes scripts at various stages in its processing which can be
  104. used to perform site-specific ancillary processing. These scripts are
  105. usually shell scripts, but could be executable code files instead.
  106. -Pppd does not wait for the scripts to finish (except for the ip-pre-up
  107. -script). The scripts are
  108. +Pppd does not wait for the scripts to finish (except for the ip-pre-up,
  109. +and auth-fail scripts). The scripts are
  110. executed as root (with the real and effective user-id set to 0), so
  111. that they can do things such as update routing tables or run
  112. privileged daemons. Be careful that the contents of these scripts do
  113. @@ -1582,6 +1582,11 @@
  114. The authenticated name of the peer. This is only set if the peer
  115. authenticates itself.
  116. .TP
  117. +.B LOCALNAME
  118. +The username passed to the user option of the pppd daemon. This is
  119. +handy to identify which account was used for authentication purposes
  120. +when multiple accounts are available.
  121. +.TP
  122. .B SPEED
  123. The baud rate of the tty device.
  124. .TP
  125. @@ -1634,6 +1639,11 @@
  126. /etc/ppp/auth\-up was previously executed. It is executed in the same
  127. manner with the same parameters as /etc/ppp/auth\-up.
  128. .TP
  129. +.B /etc/ppp/auth\-fail
  130. +A program or script which is executed should authentication fail. pppd
  131. +waits for this script to finish. It is executed in the same manner, with
  132. +the same parameters as /etc/ppp/auth\-up.
  133. +.TP
  134. .B /etc/ppp/ip\-pre\-up
  135. A program or script which is executed just before the ppp network
  136. interface is brought up. It is executed with the same parameters as