* Some old and probably unused code has been removed, notably the pppgetpass program and the passprompt plugin, and some of the files in the sample and scripts directories. * If a remote number has been set, it is available to scripts in the REMOTENUMBER environment variable. * Various other bug fixes and minor enhancements. - Obsoleted patches: * ppp-fix-bashisms.patch - Update to version 2.5.1: * Pppd can now measure and log the round-trip time (RTT) of LCP echo-requests and record them in a binary file structured as a circular buffer. Other programs or scripts can examine the file and provide real-time statistics on link latency. This is enabled by a new "lcp-rtt-file" option. * New scripts net-init, net-pre-up and net-down are executed in the process of bringing the network interface up and down. They provide additional, more deterministic ways for pppd to interact with the rest of the networking configuration. * New options have been added to allow the system administrator to set the location of various scripts and secrets files. * A new "noresolvconf" option tells pppd not to write the /etc/ppp/resolv.conf file; DNS server addresses, if obtained from the peer, are still passed to scripts in the environment. * Pppd will now create the directory for the TDB connection database if it doesn't already exist. - Obsoleted patches: * ppp-mkdir-run.patch * ppp-pidfiles.patch OBS-URL: https://build.opensuse.org/package/show/network/ppp?expand=0&rev=86
92 lines
2.2 KiB
Diff
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]);
|