What Privileges does vfork() child possess ?

2019-07-11 02:09发布

问题:

Does the process created with vfork() has same the same level of privileges that of a creator process i.e parent process ?

example : If I run a process as root does vfork() child possess the same execution privileges?

回答1:

Open Group (POSIX) specification of fork() says:

The fork() function shall create a new process. The new process (child process) shall be an exact copy of the calling process (parent process) except as detailed below:

As there is no mention of UIDs/GIDs below that text, you can deduce that these properties are inherited.

These properties are eventually changed by calls to appropriate property changing functions (setuid, etc) or exec.

The old (POSIX 2004 or earlier) specification of vfork() is similar:

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.

The specification of vfork() was removed from POSIX 2008 (aka POSIX 2016).