问题
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 tofork(), except that the behavior is undefined if the process created byvfork()either modifies any data other than a variable of typepid_tused to store the return value fromvfork(), or returns from the function in whichvfork()was called, or calls any other function before successfully calling_exit()or one of theexecfamily of functions.
The specification of vfork() was removed from POSIX 2008 (aka POSIX 2016).
来源:https://stackoverflow.com/questions/47827680/what-privileges-does-vfork-child-possess