[LTP] network/sockets: Add handshake01
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Wed Nov 18 05:51:19 CET 2026
Hi Stephen,
On Tue, Nov 17, 2026, Stephen Bertram <sbertram@redhat.com> wrote:
> network/sockets: Add handshake01
> +static int unprivileged_done(void)
> +{
> + int fds[2], err = 0;
> + pid_t pid;
> +
> + SAFE_PIPE(fds);
> + pid = SAFE_FORK();
> +
> + if (!pid) {
> + int ret;
> +
> + SAFE_CLOSE(fds[0]);
> +
> + SAFE_SETGROUPS(0, NULL);
> + SAFE_SETGID(nobody_gid);
> + SAFE_SETUID(nobody_uid);
> +
> + ret = send_done();
> +
> + SAFE_WRITE(SAFE_WRITE_ALL, fds[1], &ret, sizeof(ret));
> + _exit(0);
> + }
> +
> + SAFE_CLOSE(fds[1]);
> + SAFE_READ(SAFE_READ_ALL, fds[0], &err, sizeof(err));
> + SAFE_CLOSE(fds[0]);
> + SAFE_WAITPID(pid, NULL, 0);
> +
> + return err;
> +}
Call tst_res() directly in the child process and terminate with exit(0)
instead of _exit(0) rather than sending the result over a pipe to the
parent. Drop SAFE_PIPE() and SAFE_WAITPID(), as the LTP library propagates
child results via shared memory and reaps children automatically.
> +static void run(void)
> +{
> + int root_err, child_err;
> +
> + nl_family_id = resolve_family(HANDSHAKE_FAMILY_NAME);
Move nl_family_id = resolve_family(HANDSHAKE_FAMILY_NAME) to setup() so the
static family ID resolution and TCONF check run once instead of on every -i
iteration.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list