From 0057e5ff94114dd10781808cb41ffa5eb5f4a5bf Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 17 Jan 2016 22:26:01 +0100 Subject: [PATCH] remove incorrect usage of vfork() From "man vfork(3)": The vfork() function shall be equivalent to fork(), except that the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork(), or returns from the function in which vfork() was called, or calls any other function before successfully calling _exit() or one of the exec family of functions. All of these instances do some filedescriptor modifications before calling execve(). Since these were the only users of vfork() the tryvfork detection can entirely go away. --- CHANGES | 3 ++- Makefile | 7 ------- TARGETS | 1 - fork.h1 => fork.h | 1 - fork.h2 | 7 ------- qmail-lspawn.c | 2 +- qmail-rspawn.c | 2 +- qmail.c | 2 +- tryvfork.c | 4 ---- 9 files changed, 5 insertions(+), 24 deletions(-) rename fork.h1 => fork.h (75%) delete mode 100644 fork.h2 delete mode 100644 tryvfork.c diff --git a/CHANGES b/CHANGES index cc1f60e1..1fb1d446 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,5 @@ -20190805 version: notqmail 1.07. +201908xx version: notqmail 1.07. +20190819 remove incorrect usage of vfork() 20190710 code: add instchown to set ownership and mode on installed files. 20190709 code: add instpackage to install without root access. 20190714 code: removed idedit, install-big. var-qmail packages are no more. diff --git a/Makefile b/Makefile index 0be111cc..a6b9ad74 100644 --- a/Makefile +++ b/Makefile @@ -632,13 +632,6 @@ forgeries.0: \ forgeries.7 nroff -man forgeries.7 > forgeries.0 -fork.h: \ -compile load tryvfork.c fork.h1 fork.h2 - ( ( ./compile tryvfork.c && ./load tryvfork ) >/dev/null \ - 2>&1 \ - && cat fork.h2 || cat fork.h1 ) > fork.h - rm -f tryvfork.o tryvfork - forward: \ load forward.o qmail.o strerr.a alloc.a fd.a wait.a sig.a env.a \ substdio.a error.a str.a fs.a auto_qmail.o diff --git a/TARGETS b/TARGETS index cd3f8937..b97e16a3 100644 --- a/TARGETS +++ b/TARGETS @@ -5,7 +5,6 @@ systype load make-compile compile -fork.h qmail-local.o qmail.o quote.o diff --git a/fork.h1 b/fork.h similarity index 75% rename from fork.h1 rename to fork.h index b786255f..7a3ecc3d 100644 --- a/fork.h1 +++ b/fork.h @@ -2,6 +2,5 @@ #define FORK_H extern int fork(); -#define vfork fork #endif diff --git a/fork.h2 b/fork.h2 deleted file mode 100644 index 41773b64..00000000 --- a/fork.h2 +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef FORK_H -#define FORK_H - -extern int fork(); -extern int vfork(); - -#endif diff --git a/qmail-lspawn.c b/qmail-lspawn.c index 99b54633..35040034 100644 --- a/qmail-lspawn.c +++ b/qmail-lspawn.c @@ -156,7 +156,7 @@ char *local; args[0] = "bin/qmail-getpw"; args[1] = local; args[2] = 0; - switch(gpwpid = vfork()) + switch(gpwpid = fork()) { case -1: _exit(QLX_SYS); diff --git a/qmail-rspawn.c b/qmail-rspawn.c index 05f29dec..a9d042a3 100644 --- a/qmail-rspawn.c +++ b/qmail-rspawn.c @@ -96,7 +96,7 @@ char *s; char *r; int at; args[3] = r; args[4] = 0; - if (!(f = vfork())) + if (!(f = fork())) { if (fd_move(0,fdmess) == -1) _exit(111); if (fd_move(1,fdout) == -1) _exit(111); diff --git a/qmail.c b/qmail.c index 186c0923..5df09b90 100644 --- a/qmail.c +++ b/qmail.c @@ -29,7 +29,7 @@ struct qmail *qq; if (pipe(pim) == -1) return -1; if (pipe(pie) == -1) { close(pim[0]); close(pim[1]); return -1; } - switch(qq->pid = vfork()) { + switch(qq->pid = fork()) { case -1: close(pim[0]); close(pim[1]); close(pie[0]); close(pie[1]); diff --git a/tryvfork.c b/tryvfork.c deleted file mode 100644 index 21387e49..00000000 --- a/tryvfork.c +++ /dev/null @@ -1,4 +0,0 @@ -void main() -{ - vfork(); -}