Date: Sun, 6 Nov 2016 16:24:16 +0000
From: "Kamil Rytarowski" <[email protected]>
Message-ID: <[email protected]>
| assert_pid1 asserts that non-root user cannot attach to PID 1 as it is the
| /dev/init process. This tests is skipped if run as root.
There's no need to skip it, just
child=fork(); /* err if -1 */
if (child == 0) {
(void)setuid(10);
if (ptrace(.....) < 0)
_exit(errno);
else
_exit(0);
}
waitpid(child, &status, 0);
/* and check status */
If you're root, the setuid() works, and the child isn't root any more.
if you happened to be uid(10), the setuid() is a no-op, if you were some
other user the setuid() fails, but you don't care.
kre