ppp/ppp-fork-fix.patch
Reinhard Max 5d5a2e27d9 - Update to version 2.5.0. This release is a major release of pppd
which contains breaking changes for third-party plugins, a
  complete revamp of the build-system and that allows for
  flexibility of configuring features as needed.
  * Support for PEAP authentication
  * Support for loading PKCS12 certificate envelopes
  * Adoption of GNU Autoconf / Automake build environment
  * Support for pkgconfig
  * Bunch of fixes and cleanup to PPPoE and IPv6 support
  * Major revision to PPPD's Plugin API
  * Lots of internal fixes and cleanups for Radius and PPPoE
  * Dropped IPX support, as Linux has dropped it in version 5.15
  * Pppd is no longer installed setuid-root
  * New pppd options:
    - ipv6cp-noremote, ipv6cp-nosend, ipv6cp-use-remotenumber,
      ipv6-up-script, ipv6-down-script
    - -v, show-options
    - usepeerwins, ipcp-no-address, ipcp-no-addresses, nosendip
  * On Linux, any baud rate can be set on a serial port provided
    the kernel serial driver supports that.
- Obsoleted patches:
  * ppp-lib64.patch
  * ppp-compiling-with-clang-encounters-an-error-in-eap-tls..patch
  * ppp-pie.patch
- Enable support for systemd notification.

OBS-URL: https://build.opensuse.org/package/show/network/ppp?expand=0&rev=75
2023-07-05 15:45:43 +00:00

92 lines
2.2 KiB
Diff

--- pppd/main.c.orig
+++ pppd/main.c
@@ -1632,14 +1632,6 @@ ppp_safe_fork(int infd, int outfd, int e
int fd, pipefd[2];
char buf[1];
- /* make sure fds 0, 1, 2 are occupied (probably not necessary) */
- while ((fd = dup(fd_devnull)) >= 0) {
- if (fd > 2) {
- close(fd);
- break;
- }
- }
-
if (pipe(pipefd) == -1)
pipefd[0] = pipefd[1] = -1;
pid = fork();
@@ -1663,25 +1655,31 @@ ppp_safe_fork(int infd, int outfd, int e
tdb_close(pppdb);
#endif
- /* make sure infd, outfd and errfd won't get tromped on below */
- if (infd == 1 || infd == 2)
- infd = dup(infd);
- if (outfd == 0 || outfd == 2)
- outfd = dup(outfd);
- if (errfd == 0 || errfd == 1)
- errfd = dup(errfd);
-
+ /* make sure fds 0, 1, 2 are occupied, so the duplicated fds always > 2 */
+ while ((fd = dup(fd_devnull)) >= 0) {
+ if (fd > 2) {
+ close(fd);
+ break;
+ }
+ }
+
+ /* always copy fd's to avoid to use a already closed fd later */
+ {
+ int fdi = infd, fdo = outfd;
+
+ infd = dup(infd);
+ outfd = dup(outfd);
+ if (errfd >= 0) {
+ fd = errfd;
+ errfd = dup(errfd);
+ close(fd);
+ }
+ close(fdi);
+ close(fdo);
+ }
closelog();
- /* dup the in, out, err fds to 0, 1, 2 */
- if (infd != 0)
- dup2(infd, 0);
- if (outfd != 1)
- dup2(outfd, 1);
- if (errfd != 2)
- dup2(errfd, 2);
-
- if (log_to_fd > 2)
+ if (log_to_fd > 0)
close(log_to_fd);
if (the_channel->close)
(*the_channel->close)();
@@ -1689,12 +1687,18 @@ ppp_safe_fork(int infd, int outfd, int e
close(devfd); /* some plugins don't have a close function */
close(fd_ppp);
close(fd_devnull);
- if (infd != 0)
- close(infd);
- if (outfd != 1)
- close(outfd);
- if (errfd != 2)
- close(errfd);
+
+ close(0);
+ dup2(infd, 0);
+ close(infd);
+ close(1);
+ dup2(outfd, 1);
+ close(outfd);
+ if (errfd >= 0) {
+ close(2);
+ dup2(errfd, 2);
+ close(errfd);
+ }
notify(fork_notifier, 0);
close(pipefd[0]);