Blame SOURCES/0137-Implement-testing-framework-for-pidns.patch

089393
From 4362ddaba8634a5ac6b4add0eaf25eec5f7315f5 Mon Sep 17 00:00:00 2001
089393
From: =?UTF-8?q?=C3=81kos=20Uzonyi?= <uzonyi.akos@gmail.com>
089393
Date: Fri, 26 Jun 2020 20:13:28 +0200
089393
Subject: [PATCH 137/138] Implement testing framework for pidns
089393
089393
* tests/pidns.c: New file.
089393
* tests/pidns.h: New file.
089393
* tests/Makefile.am (libtests_a_SOURCES): Add pidns.c, pidns.h.
089393
* tests/init.sh (test_pidns, test_pidns_run_strace): New functions.
089393
---
089393
 tests/Makefile.am |   2 +
089393
 tests/init.sh     |  30 +++++++
089393
 tests/pidns.c     | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
089393
 tests/pidns.h     |  56 +++++++++++++
089393
 4 files changed, 325 insertions(+)
089393
 create mode 100644 tests/pidns.c
089393
 create mode 100644 tests/pidns.h
089393
089393
Index: strace-5.7/tests/Makefile.am
089393
===================================================================
089393
--- strace-5.7.orig/tests/Makefile.am	2020-09-09 19:32:50.846965498 +0200
089393
+++ strace-5.7/tests/Makefile.am	2020-09-09 19:49:54.008575349 +0200
089393
@@ -44,6 +44,8 @@
089393
 	libsocketcall.c \
089393
 	lock_file.c \
089393
 	overflowuid.c \
089393
+	pidns.c \
089393
+	pidns.h \
089393
 	pipe_maxfd.c \
089393
 	print_quoted_string.c \
089393
 	print_time.c \
089393
Index: strace-5.7/tests/init.sh
089393
===================================================================
089393
--- strace-5.7.orig/tests/init.sh	2020-09-09 19:32:50.846965498 +0200
089393
+++ strace-5.7/tests/init.sh	2020-09-09 19:49:54.008575349 +0200
089393
@@ -387,6 +387,36 @@
089393
 	test_pure_prog_set "$@" < "$srcdir/$NAME.in"
089393
 }
089393
 
089393
+test_pidns_run_strace()
089393
+{
089393
+	local parent_pid init_pid
089393
+
089393
+	check_prog tail
089393
+	check_prog cut
089393
+	check_prog grep
089393
+
089393
+	run_prog > /dev/null
089393
+	run_strace --pidns-translation -f $@ $args > "$EXP"
089393
+
089393
+	# filter out logs made by the parent or init process of the pidns test
089393
+	parent_pid="$(tail -n 2 $LOG | head -n 1 | cut -d' ' -f1)"
089393
+	init_pid="$(tail -n 1 $LOG | cut -d' ' -f1)"
089393
+	grep -E -v "^($parent_pid|$init_pid) " "$LOG" > "$OUT"
089393
+	match_diff "$OUT" "$EXP"
089393
+}
089393
+
089393
+test_pidns()
089393
+{
089393
+	check_prog unshare
089393
+	unshare -Urpf true || framework_skip_ "unshare -Urpf true failed"
089393
+
089393
+	test_pidns_run_strace "$@"
089393
+
089393
+	# test PID translation when /proc is mounted from an other namespace
089393
+	STRACE="unshare -Urpf $STRACE"
089393
+	test_pidns_run_strace "$@"
089393
+}
089393
+
089393
 check_prog cat
089393
 check_prog rm
089393
 
089393
Index: strace-5.7/tests/pidns.c
089393
===================================================================
089393
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
089393
+++ strace-5.7/tests/pidns.c	2020-09-09 19:49:54.009575350 +0200
089393
@@ -0,0 +1,237 @@
089393
+/*
089393
+ * Testing framework for PID namespace translation
089393
+ *
089393
+ * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
089393
+ * All rights reserved.
089393
+ *
089393
+ * SPDX-License-Identifier: LGPL-2.1-or-later
089393
+ */
089393
+#include "tests.h"
089393
+#include "pidns.h"
089393
+#include "nsfs.h"
089393
+
089393
+#include <errno.h>
089393
+#include <stdio.h>
089393
+#include <string.h>
089393
+#include <sys/types.h>
089393
+#include <signal.h>
089393
+#include <stdlib.h>
089393
+#include <sched.h>
089393
+#include <unistd.h>
089393
+#include <sys/wait.h>
089393
+#include <linux/sched.h>
089393
+#include <fcntl.h>
089393
+#include <sys/ioctl.h>
089393
+
089393
+#ifndef CLONE_NEWUSER
089393
+# define CLONE_NEWUSER 0x10000000
089393
+#endif
089393
+
089393
+#ifndef CLONE_NEWPID
089393
+# define CLONE_NEWPID 0x20000000
089393
+#endif
089393
+
089393
+static bool pidns_translation = false;
089393
+static bool pidns_unshared = false;
089393
+
089393
+/* Our PIDs in strace's namespace */
089393
+static pid_t pidns_strace_ids[PT_COUNT];
089393
+
089393
+void
089393
+pidns_print_leader(void)
089393
+{
089393
+	if (pidns_translation)
089393
+		printf("%-5d ", pidns_strace_ids[PT_TID]);
089393
+}
089393
+
089393
+const char *
089393
+pidns_pid2str(enum pid_type type)
089393
+{
089393
+	static const char format[] = " /* %d in strace's PID NS */";
089393
+	static char buf[PT_COUNT][sizeof(format) + sizeof(int) * 3];
089393
+
089393
+	if (type < 0 || type >= PT_COUNT)
089393
+		return "";
089393
+
089393
+	if (!pidns_unshared || !pidns_strace_ids[type])
089393
+		return "";
089393
+
089393
+	snprintf(buf[type], sizeof(buf[type]), format, pidns_strace_ids[type]);
089393
+	return buf[type];
089393
+}
089393
+
089393
+/**
089393
+ * This function is like fork, but does a few more things. It sets up the
089393
+ * child's PGID and SID according to the parameters. Also it fills the
089393
+ * pidns_strace_ids array in the child's memory with the PIDs of the child in
089393
+ * parent's PID namespace. In the parent it waits for the child to terminate
089393
+ * (but leaves the zombie to use it later as a process group). If the child
089393
+ * terminates with nonzero exit status, the test is failed.
089393
+ *
089393
+ * @param pgid     The process group the child should be moved to. It's expected
089393
+ *                 to be a PID of a zombie process (will be reaped). If
089393
+ *                 negative, leave the child in the process group of the parent.
089393
+ *                 If 0, move the process to its own process group.
089393
+ * @param new_sid  Wheather child should be moved to a new session.
089393
+ */
089393
+static pid_t
089393
+pidns_fork(pid_t pgid, bool new_sid)
089393
+{
089393
+	int strace_ids_pipe[2];
089393
+	if (pipe(strace_ids_pipe) < 0)
089393
+		perror_msg_and_fail("pipe");
089393
+
089393
+	fflush(stdout);
089393
+	pid_t pid = fork();
089393
+	if (pid < 0)
089393
+		perror_msg_and_fail("fork");
089393
+
089393
+	if (!pid) {
089393
+		close(strace_ids_pipe[1]);
089393
+
089393
+		ssize_t len = read(strace_ids_pipe[0], pidns_strace_ids,
089393
+				sizeof(pidns_strace_ids));
089393
+		if (len < 0)
089393
+			perror_msg_and_fail("read");
089393
+		if (len != sizeof(pidns_strace_ids))
089393
+			error_msg_and_fail("read returned < sizeof(pidns_strace_ids)");
089393
+
089393
+		close(strace_ids_pipe[0]);
089393
+
089393
+		if (pidns_strace_ids[PT_SID])
089393
+			setsid();
089393
+
089393
+		return 0;
089393
+	}
089393
+
089393
+	pidns_strace_ids[PT_TID] = pid;
089393
+	pidns_strace_ids[PT_TGID] = pid;
089393
+	pidns_strace_ids[PT_PGID] = 0;
089393
+	pidns_strace_ids[PT_SID] = 0;
089393
+
089393
+	if (!pgid)
089393
+		pgid = pid;
089393
+
089393
+	if (pgid > 0) {
089393
+		if (setpgid(pid, pgid) < 0)
089393
+			perror_msg_and_fail("setpgid");
089393
+
089393
+		pidns_strace_ids[PT_PGID] = pgid;
089393
+	}
089393
+
089393
+	/* Reap group leader to test PGID decoding */
089393
+	if (pgid > 0 && pgid != pid) {
089393
+		int ret = waitpid(pgid, NULL, WNOHANG);
089393
+		if (ret < 0)
089393
+			perror_msg_and_fail("wait");
089393
+		if (!ret)
089393
+			error_msg_and_fail("could not reap group leader");
089393
+	}
089393
+
089393
+	if (new_sid) {
089393
+		pidns_strace_ids[PT_SID] = pid;
089393
+		pidns_strace_ids[PT_PGID] = pid;
089393
+	}
089393
+
089393
+	ssize_t len = write(strace_ids_pipe[1], pidns_strace_ids,
089393
+	                     sizeof(pidns_strace_ids));
089393
+	if (len < 0)
089393
+		perror_msg_and_fail("write");
089393
+	if (len != sizeof(pidns_strace_ids))
089393
+		error_msg_and_fail("write returned < sizeof(pidns_strace_ids)");
089393
+
089393
+	close(strace_ids_pipe[0]);
089393
+	close(strace_ids_pipe[1]);
089393
+
089393
+	/* WNOWAIT: leave the zombie, to be able to use it as a process group */
089393
+	siginfo_t siginfo;
089393
+	if (waitid(P_PID, pid, &siginfo, WEXITED | WNOWAIT) < 0)
089393
+		perror_msg_and_fail("wait");
089393
+	if (siginfo.si_code != CLD_EXITED || siginfo.si_status)
089393
+		error_msg_and_fail("child terminated with nonzero exit status");
089393
+
089393
+	return pid;
089393
+}
089393
+
089393
+static void
089393
+create_init_process(void)
089393
+{
089393
+	int child_pipe[2];
089393
+	if (pipe(child_pipe) < 0)
089393
+		perror_msg_and_fail("pipe");
089393
+
089393
+	pid_t pid = fork();
089393
+	if (pid < 0)
089393
+		perror_msg_and_fail("fork");
089393
+
089393
+	if (!pid) {
089393
+		close(child_pipe[1]);
089393
+		if (read(child_pipe[0], &child_pipe[1], sizeof(int)) != 0)
089393
+			_exit(1);
089393
+		_exit(0);
089393
+	}
089393
+
089393
+	close(child_pipe[0]);
089393
+}
089393
+
089393
+void
089393
+check_ns_ioctl(void)
089393
+{
089393
+	int fd = open("/proc/self/ns/pid", O_RDONLY);
089393
+	if (fd < 0) {
089393
+		if (errno == ENOENT)
089393
+			perror_msg_and_skip("opening /proc/self/ns/pid");
089393
+		else
089393
+			perror_msg_and_fail("opening /proc/self/ns/pid");
089393
+	}
089393
+
089393
+	int userns_fd = ioctl(fd, NS_GET_USERNS);
089393
+	if (userns_fd < 0) {
089393
+		if (errno == ENOTTY)
089393
+			error_msg_and_skip("NS_* ioctl commands are not "
089393
+			                   "supported by the kernel");
089393
+		else
089393
+			perror_msg_and_fail("ioctl(NS_GET_USERNS)");
089393
+	}
089393
+
089393
+	close(userns_fd);
089393
+	close(fd);
089393
+}
089393
+
089393
+void
089393
+pidns_test_init(void)
089393
+{
089393
+	pidns_translation = true;
089393
+
089393
+	check_ns_ioctl();
089393
+
089393
+	if (!pidns_fork(-1, false))
089393
+		return;
089393
+
089393
+	/* Unshare user namespace too, so we do not need to be root */
089393
+	if (unshare(CLONE_NEWUSER | CLONE_NEWPID) < 0) {
089393
+		if (errno == EPERM)
089393
+			perror_msg_and_skip("unshare");
089393
+
089393
+		perror_msg_and_fail("unshare");
089393
+	}
089393
+
089393
+	pidns_unshared = true;
089393
+
089393
+	create_init_process();
089393
+
089393
+	if (!pidns_fork(-1, false))
089393
+		return;
089393
+
089393
+	if (!pidns_fork(-1, true))
089393
+		return;
089393
+
089393
+	pid_t pgid;
089393
+	if (!(pgid = pidns_fork(0, false)))
089393
+		return;
089393
+
089393
+	if (!pidns_fork(pgid, false))
089393
+		return;
089393
+
089393
+	exit(0);
089393
+}
089393
Index: strace-5.7/tests/pidns.h
089393
===================================================================
089393
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
089393
+++ strace-5.7/tests/pidns.h	2020-09-09 19:49:54.009575350 +0200
089393
@@ -0,0 +1,56 @@
089393
+/*
089393
+ * Test PID namespace translation
089393
+ *
089393
+ * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
089393
+ * All rights reserved.
089393
+ *
089393
+ * SPDX-License-Identifier: LGPL-2.1-or-later
089393
+ */
089393
+#ifndef STRACE_PIDNS_H
089393
+#define STRACE_PIDNS_H
089393
+
089393
+#ifdef PIDNS_TRANSLATION
089393
+# define PIDNS_TEST_INIT pidns_test_init()
089393
+#else
089393
+# define PIDNS_TEST_INIT
089393
+#endif
089393
+
089393
+#include <sys/types.h>
089393
+
089393
+enum pid_type {
089393
+	PT_TID,
089393
+	PT_TGID,
089393
+	PT_PGID,
089393
+	PT_SID,
089393
+
089393
+	PT_COUNT,
089393
+	PT_NONE = -1
089393
+};
089393
+
089393
+/* Prints leader (process tid) if pidns_test_init was called */
089393
+void pidns_print_leader(void);
089393
+
089393
+/*
089393
+ * Returns a static buffer containing the translation string of our PID.
089393
+ */
089393
+const char *pidns_pid2str(enum pid_type type);
089393
+
089393
+/**
089393
+ * Skips the test if NS_* ioctl commands are not supported by the kernel.
089393
+ */
089393
+void check_ns_ioctl(void);
089393
+
089393
+/**
089393
+ * Init pidns testing.
089393
+ *
089393
+ * Should be called at the beginning of the test's main function
089393
+ *
089393
+ * This function calls fork a couple of times, and returns in the child
089393
+ * processes. These child processes are in a new PID namespace with different
089393
+ * PID configurations (group leader, session leader, ...). If any child
089393
+ * terminates with nonzero exit status the test is failed. Otherwise the test is
089393
+ * succesful, and the parent process exits with 0.
089393
+ */
089393
+void pidns_test_init(void);
089393
+
089393
+#endif
089393
\ No newline at end of file
089393
Index: strace-5.7/tests-m32/Makefile.am
089393
===================================================================
089393
--- strace-5.7.orig/tests-m32/Makefile.am	2020-09-09 19:32:50.846965498 +0200
089393
+++ strace-5.7/tests-m32/Makefile.am	2020-09-09 19:49:54.009575350 +0200
089393
@@ -7,14 +7,14 @@
089393
 # SPDX-License-Identifier: GPL-2.0-or-later
089393
 
089393
 OS = linux
089393
-CC = @CC_FOR_M32@
089393
-ARCH = @arch_m32@
089393
+CC = @CC@
089393
+ARCH = @arch@
089393
 NATIVE_ARCH = @arch_native@
089393
-SIZEOF_KERNEL_LONG_T = 4
089393
-SIZEOF_LONG = 4
089393
-MPERS_NAME = m32
089393
-MPERS_CC_FLAGS = @CFLAGS_FOR_M32@ @cc_flags_m32@
089393
-ARCH_MFLAGS = -DMPERS_IS_$(MPERS_NAME) $(MPERS_CC_FLAGS)
089393
+SIZEOF_KERNEL_LONG_T = @SIZEOF_KERNEL_LONG_T@
089393
+SIZEOF_LONG = @SIZEOF_LONG@
089393
+MPERS_NAME =
089393
+MPERS_CC_FLAGS =
089393
+ARCH_MFLAGS =
089393
 AM_CFLAGS = $(WARN_CFLAGS)
089393
 AM_CPPFLAGS = $(ARCH_MFLAGS) \
089393
 	      -I$(builddir) \
089393
@@ -44,6 +44,8 @@
089393
 	libsocketcall.c \
089393
 	lock_file.c \
089393
 	overflowuid.c \
089393
+	pidns.c \
089393
+	pidns.h \
089393
 	pipe_maxfd.c \
089393
 	print_quoted_string.c \
089393
 	print_time.c \
089393
Index: strace-5.7/tests-m32/init.sh
089393
===================================================================
089393
--- strace-5.7.orig/tests-m32/init.sh	2020-09-09 19:32:50.846965498 +0200
089393
+++ strace-5.7/tests-m32/init.sh	2020-09-09 19:49:54.009575350 +0200
089393
@@ -387,6 +387,36 @@
089393
 	test_pure_prog_set "$@" < "$srcdir/$NAME.in"
089393
 }
089393
 
089393
+test_pidns_run_strace()
089393
+{
089393
+	local parent_pid init_pid
089393
+
089393
+	check_prog tail
089393
+	check_prog cut
089393
+	check_prog grep
089393
+
089393
+	run_prog > /dev/null
089393
+	run_strace --pidns-translation -f $@ $args > "$EXP"
089393
+
089393
+	# filter out logs made by the parent or init process of the pidns test
089393
+	parent_pid="$(tail -n 2 $LOG | head -n 1 | cut -d' ' -f1)"
089393
+	init_pid="$(tail -n 1 $LOG | cut -d' ' -f1)"
089393
+	grep -E -v "^($parent_pid|$init_pid) " "$LOG" > "$OUT"
089393
+	match_diff "$OUT" "$EXP"
089393
+}
089393
+
089393
+test_pidns()
089393
+{
089393
+	check_prog unshare
089393
+	unshare -Urpf true || framework_skip_ "unshare -Urpf true failed"
089393
+
089393
+	test_pidns_run_strace "$@"
089393
+
089393
+	# test PID translation when /proc is mounted from an other namespace
089393
+	STRACE="unshare -Urpf $STRACE"
089393
+	test_pidns_run_strace "$@"
089393
+}
089393
+
089393
 check_prog cat
089393
 check_prog rm
089393
 
089393
Index: strace-5.7/tests-m32/pidns.c
089393
===================================================================
089393
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
089393
+++ strace-5.7/tests-m32/pidns.c	2020-09-09 19:49:54.009575350 +0200
089393
@@ -0,0 +1,237 @@
089393
+/*
089393
+ * Testing framework for PID namespace translation
089393
+ *
089393
+ * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
089393
+ * All rights reserved.
089393
+ *
089393
+ * SPDX-License-Identifier: LGPL-2.1-or-later
089393
+ */
089393
+#include "tests.h"
089393
+#include "pidns.h"
089393
+#include "nsfs.h"
089393
+
089393
+#include <errno.h>
089393
+#include <stdio.h>
089393
+#include <string.h>
089393
+#include <sys/types.h>
089393
+#include <signal.h>
089393
+#include <stdlib.h>
089393
+#include <sched.h>
089393
+#include <unistd.h>
089393
+#include <sys/wait.h>
089393
+#include <linux/sched.h>
089393
+#include <fcntl.h>
089393
+#include <sys/ioctl.h>
089393
+
089393
+#ifndef CLONE_NEWUSER
089393
+# define CLONE_NEWUSER 0x10000000
089393
+#endif
089393
+
089393
+#ifndef CLONE_NEWPID
089393
+# define CLONE_NEWPID 0x20000000
089393
+#endif
089393
+
089393
+static bool pidns_translation = false;
089393
+static bool pidns_unshared = false;
089393
+
089393
+/* Our PIDs in strace's namespace */
089393
+static pid_t pidns_strace_ids[PT_COUNT];
089393
+
089393
+void
089393
+pidns_print_leader(void)
089393
+{
089393
+	if (pidns_translation)
089393
+		printf("%-5d ", pidns_strace_ids[PT_TID]);
089393
+}
089393
+
089393
+const char *
089393
+pidns_pid2str(enum pid_type type)
089393
+{
089393
+	static const char format[] = " /* %d in strace's PID NS */";
089393
+	static char buf[PT_COUNT][sizeof(format) + sizeof(int) * 3];
089393
+
089393
+	if (type < 0 || type >= PT_COUNT)
089393
+		return "";
089393
+
089393
+	if (!pidns_unshared || !pidns_strace_ids[type])
089393
+		return "";
089393
+
089393
+	snprintf(buf[type], sizeof(buf[type]), format, pidns_strace_ids[type]);
089393
+	return buf[type];
089393
+}
089393
+
089393
+/**
089393
+ * This function is like fork, but does a few more things. It sets up the
089393
+ * child's PGID and SID according to the parameters. Also it fills the
089393
+ * pidns_strace_ids array in the child's memory with the PIDs of the child in
089393
+ * parent's PID namespace. In the parent it waits for the child to terminate
089393
+ * (but leaves the zombie to use it later as a process group). If the child
089393
+ * terminates with nonzero exit status, the test is failed.
089393
+ *
089393
+ * @param pgid     The process group the child should be moved to. It's expected
089393
+ *                 to be a PID of a zombie process (will be reaped). If
089393
+ *                 negative, leave the child in the process group of the parent.
089393
+ *                 If 0, move the process to its own process group.
089393
+ * @param new_sid  Wheather child should be moved to a new session.
089393
+ */
089393
+static pid_t
089393
+pidns_fork(pid_t pgid, bool new_sid)
089393
+{
089393
+	int strace_ids_pipe[2];
089393
+	if (pipe(strace_ids_pipe) < 0)
089393
+		perror_msg_and_fail("pipe");
089393
+
089393
+	fflush(stdout);
089393
+	pid_t pid = fork();
089393
+	if (pid < 0)
089393
+		perror_msg_and_fail("fork");
089393
+
089393
+	if (!pid) {
089393
+		close(strace_ids_pipe[1]);
089393
+
089393
+		ssize_t len = read(strace_ids_pipe[0], pidns_strace_ids,
089393
+				sizeof(pidns_strace_ids));
089393
+		if (len < 0)
089393
+			perror_msg_and_fail("read");
089393
+		if (len != sizeof(pidns_strace_ids))
089393
+			error_msg_and_fail("read returned < sizeof(pidns_strace_ids)");
089393
+
089393
+		close(strace_ids_pipe[0]);
089393
+
089393
+		if (pidns_strace_ids[PT_SID])
089393
+			setsid();
089393
+
089393
+		return 0;
089393
+	}
089393
+
089393
+	pidns_strace_ids[PT_TID] = pid;
089393
+	pidns_strace_ids[PT_TGID] = pid;
089393
+	pidns_strace_ids[PT_PGID] = 0;
089393
+	pidns_strace_ids[PT_SID] = 0;
089393
+
089393
+	if (!pgid)
089393
+		pgid = pid;
089393
+
089393
+	if (pgid > 0) {
089393
+		if (setpgid(pid, pgid) < 0)
089393
+			perror_msg_and_fail("setpgid");
089393
+
089393
+		pidns_strace_ids[PT_PGID] = pgid;
089393
+	}
089393
+
089393
+	/* Reap group leader to test PGID decoding */
089393
+	if (pgid > 0 && pgid != pid) {
089393
+		int ret = waitpid(pgid, NULL, WNOHANG);
089393
+		if (ret < 0)
089393
+			perror_msg_and_fail("wait");
089393
+		if (!ret)
089393
+			error_msg_and_fail("could not reap group leader");
089393
+	}
089393
+
089393
+	if (new_sid) {
089393
+		pidns_strace_ids[PT_SID] = pid;
089393
+		pidns_strace_ids[PT_PGID] = pid;
089393
+	}
089393
+
089393
+	ssize_t len = write(strace_ids_pipe[1], pidns_strace_ids,
089393
+	                     sizeof(pidns_strace_ids));
089393
+	if (len < 0)
089393
+		perror_msg_and_fail("write");
089393
+	if (len != sizeof(pidns_strace_ids))
089393
+		error_msg_and_fail("write returned < sizeof(pidns_strace_ids)");
089393
+
089393
+	close(strace_ids_pipe[0]);
089393
+	close(strace_ids_pipe[1]);
089393
+
089393
+	/* WNOWAIT: leave the zombie, to be able to use it as a process group */
089393
+	siginfo_t siginfo;
089393
+	if (waitid(P_PID, pid, &siginfo, WEXITED | WNOWAIT) < 0)
089393
+		perror_msg_and_fail("wait");
089393
+	if (siginfo.si_code != CLD_EXITED || siginfo.si_status)
089393
+		error_msg_and_fail("child terminated with nonzero exit status");
089393
+
089393
+	return pid;
089393
+}
089393
+
089393
+static void
089393
+create_init_process(void)
089393
+{
089393
+	int child_pipe[2];
089393
+	if (pipe(child_pipe) < 0)
089393
+		perror_msg_and_fail("pipe");
089393
+
089393
+	pid_t pid = fork();
089393
+	if (pid < 0)
089393
+		perror_msg_and_fail("fork");
089393
+
089393
+	if (!pid) {
089393
+		close(child_pipe[1]);
089393
+		if (read(child_pipe[0], &child_pipe[1], sizeof(int)) != 0)
089393
+			_exit(1);
089393
+		_exit(0);
089393
+	}
089393
+
089393
+	close(child_pipe[0]);
089393
+}
089393
+
089393
+void
089393
+check_ns_ioctl(void)
089393
+{
089393
+	int fd = open("/proc/self/ns/pid", O_RDONLY);
089393
+	if (fd < 0) {
089393
+		if (errno == ENOENT)
089393
+			perror_msg_and_skip("opening /proc/self/ns/pid");
089393
+		else
089393
+			perror_msg_and_fail("opening /proc/self/ns/pid");
089393
+	}
089393
+
089393
+	int userns_fd = ioctl(fd, NS_GET_USERNS);
089393
+	if (userns_fd < 0) {
089393
+		if (errno == ENOTTY)
089393
+			error_msg_and_skip("NS_* ioctl commands are not "
089393
+			                   "supported by the kernel");
089393
+		else
089393
+			perror_msg_and_fail("ioctl(NS_GET_USERNS)");
089393
+	}
089393
+
089393
+	close(userns_fd);
089393
+	close(fd);
089393
+}
089393
+
089393
+void
089393
+pidns_test_init(void)
089393
+{
089393
+	pidns_translation = true;
089393
+
089393
+	check_ns_ioctl();
089393
+
089393
+	if (!pidns_fork(-1, false))
089393
+		return;
089393
+
089393
+	/* Unshare user namespace too, so we do not need to be root */
089393
+	if (unshare(CLONE_NEWUSER | CLONE_NEWPID) < 0) {
089393
+		if (errno == EPERM)
089393
+			perror_msg_and_skip("unshare");
089393
+
089393
+		perror_msg_and_fail("unshare");
089393
+	}
089393
+
089393
+	pidns_unshared = true;
089393
+
089393
+	create_init_process();
089393
+
089393
+	if (!pidns_fork(-1, false))
089393
+		return;
089393
+
089393
+	if (!pidns_fork(-1, true))
089393
+		return;
089393
+
089393
+	pid_t pgid;
089393
+	if (!(pgid = pidns_fork(0, false)))
089393
+		return;
089393
+
089393
+	if (!pidns_fork(pgid, false))
089393
+		return;
089393
+
089393
+	exit(0);
089393
+}
089393
Index: strace-5.7/tests-m32/pidns.h
089393
===================================================================
089393
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
089393
+++ strace-5.7/tests-m32/pidns.h	2020-09-09 19:49:54.010575350 +0200
089393
@@ -0,0 +1,56 @@
089393
+/*
089393
+ * Test PID namespace translation
089393
+ *
089393
+ * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
089393
+ * All rights reserved.
089393
+ *
089393
+ * SPDX-License-Identifier: LGPL-2.1-or-later
089393
+ */
089393
+#ifndef STRACE_PIDNS_H
089393
+#define STRACE_PIDNS_H
089393
+
089393
+#ifdef PIDNS_TRANSLATION
089393
+# define PIDNS_TEST_INIT pidns_test_init()
089393
+#else
089393
+# define PIDNS_TEST_INIT
089393
+#endif
089393
+
089393
+#include <sys/types.h>
089393
+
089393
+enum pid_type {
089393
+	PT_TID,
089393
+	PT_TGID,
089393
+	PT_PGID,
089393
+	PT_SID,
089393
+
089393
+	PT_COUNT,
089393
+	PT_NONE = -1
089393
+};
089393
+
089393
+/* Prints leader (process tid) if pidns_test_init was called */
089393
+void pidns_print_leader(void);
089393
+
089393
+/*
089393
+ * Returns a static buffer containing the translation string of our PID.
089393
+ */
089393
+const char *pidns_pid2str(enum pid_type type);
089393
+
089393
+/**
089393
+ * Skips the test if NS_* ioctl commands are not supported by the kernel.
089393
+ */
089393
+void check_ns_ioctl(void);
089393
+
089393
+/**
089393
+ * Init pidns testing.
089393
+ *
089393
+ * Should be called at the beginning of the test's main function
089393
+ *
089393
+ * This function calls fork a couple of times, and returns in the child
089393
+ * processes. These child processes are in a new PID namespace with different
089393
+ * PID configurations (group leader, session leader, ...). If any child
089393
+ * terminates with nonzero exit status the test is failed. Otherwise the test is
089393
+ * succesful, and the parent process exits with 0.
089393
+ */
089393
+void pidns_test_init(void);
089393
+
089393
+#endif
089393
\ No newline at end of file
089393
Index: strace-5.7/tests-mx32/Makefile.am
089393
===================================================================
089393
--- strace-5.7.orig/tests-mx32/Makefile.am	2020-09-09 19:32:50.846965498 +0200
089393
+++ strace-5.7/tests-mx32/Makefile.am	2020-09-09 19:49:54.010575350 +0200
089393
@@ -7,14 +7,14 @@
089393
 # SPDX-License-Identifier: GPL-2.0-or-later
089393
 
089393
 OS = linux
089393
-CC = @CC_FOR_MX32@
089393
-ARCH = @arch_mx32@
089393
+CC = @CC@
089393
+ARCH = @arch@
089393
 NATIVE_ARCH = @arch_native@
089393
 SIZEOF_KERNEL_LONG_T = @SIZEOF_KERNEL_LONG_T@
089393
-SIZEOF_LONG = 4
089393
-MPERS_NAME = mx32
089393
-MPERS_CC_FLAGS = @CFLAGS_FOR_MX32@ @cc_flags_mx32@
089393
-ARCH_MFLAGS = -DMPERS_IS_$(MPERS_NAME) $(MPERS_CC_FLAGS)
089393
+SIZEOF_LONG = @SIZEOF_LONG@
089393
+MPERS_NAME =
089393
+MPERS_CC_FLAGS =
089393
+ARCH_MFLAGS =
089393
 AM_CFLAGS = $(WARN_CFLAGS)
089393
 AM_CPPFLAGS = $(ARCH_MFLAGS) \
089393
 	      -I$(builddir) \
089393
@@ -44,6 +44,8 @@
089393
 	libsocketcall.c \
089393
 	lock_file.c \
089393
 	overflowuid.c \
089393
+	pidns.c \
089393
+	pidns.h \
089393
 	pipe_maxfd.c \
089393
 	print_quoted_string.c \
089393
 	print_time.c \
089393
Index: strace-5.7/tests-mx32/init.sh
089393
===================================================================
089393
--- strace-5.7.orig/tests-mx32/init.sh	2020-09-09 19:32:50.846965498 +0200
089393
+++ strace-5.7/tests-mx32/init.sh	2020-09-09 19:49:54.010575350 +0200
089393
@@ -387,6 +387,36 @@
089393
 	test_pure_prog_set "$@" < "$srcdir/$NAME.in"
089393
 }
089393
 
089393
+test_pidns_run_strace()
089393
+{
089393
+	local parent_pid init_pid
089393
+
089393
+	check_prog tail
089393
+	check_prog cut
089393
+	check_prog grep
089393
+
089393
+	run_prog > /dev/null
089393
+	run_strace --pidns-translation -f $@ $args > "$EXP"
089393
+
089393
+	# filter out logs made by the parent or init process of the pidns test
089393
+	parent_pid="$(tail -n 2 $LOG | head -n 1 | cut -d' ' -f1)"
089393
+	init_pid="$(tail -n 1 $LOG | cut -d' ' -f1)"
089393
+	grep -E -v "^($parent_pid|$init_pid) " "$LOG" > "$OUT"
089393
+	match_diff "$OUT" "$EXP"
089393
+}
089393
+
089393
+test_pidns()
089393
+{
089393
+	check_prog unshare
089393
+	unshare -Urpf true || framework_skip_ "unshare -Urpf true failed"
089393
+
089393
+	test_pidns_run_strace "$@"
089393
+
089393
+	# test PID translation when /proc is mounted from an other namespace
089393
+	STRACE="unshare -Urpf $STRACE"
089393
+	test_pidns_run_strace "$@"
089393
+}
089393
+
089393
 check_prog cat
089393
 check_prog rm
089393
 
089393
Index: strace-5.7/tests-mx32/pidns.c
089393
===================================================================
089393
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
089393
+++ strace-5.7/tests-mx32/pidns.c	2020-09-09 19:49:54.010575350 +0200
089393
@@ -0,0 +1,237 @@
089393
+/*
089393
+ * Testing framework for PID namespace translation
089393
+ *
089393
+ * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
089393
+ * All rights reserved.
089393
+ *
089393
+ * SPDX-License-Identifier: LGPL-2.1-or-later
089393
+ */
089393
+#include "tests.h"
089393
+#include "pidns.h"
089393
+#include "nsfs.h"
089393
+
089393
+#include <errno.h>
089393
+#include <stdio.h>
089393
+#include <string.h>
089393
+#include <sys/types.h>
089393
+#include <signal.h>
089393
+#include <stdlib.h>
089393
+#include <sched.h>
089393
+#include <unistd.h>
089393
+#include <sys/wait.h>
089393
+#include <linux/sched.h>
089393
+#include <fcntl.h>
089393
+#include <sys/ioctl.h>
089393
+
089393
+#ifndef CLONE_NEWUSER
089393
+# define CLONE_NEWUSER 0x10000000
089393
+#endif
089393
+
089393
+#ifndef CLONE_NEWPID
089393
+# define CLONE_NEWPID 0x20000000
089393
+#endif
089393
+
089393
+static bool pidns_translation = false;
089393
+static bool pidns_unshared = false;
089393
+
089393
+/* Our PIDs in strace's namespace */
089393
+static pid_t pidns_strace_ids[PT_COUNT];
089393
+
089393
+void
089393
+pidns_print_leader(void)
089393
+{
089393
+	if (pidns_translation)
089393
+		printf("%-5d ", pidns_strace_ids[PT_TID]);
089393
+}
089393
+
089393
+const char *
089393
+pidns_pid2str(enum pid_type type)
089393
+{
089393
+	static const char format[] = " /* %d in strace's PID NS */";
089393
+	static char buf[PT_COUNT][sizeof(format) + sizeof(int) * 3];
089393
+
089393
+	if (type < 0 || type >= PT_COUNT)
089393
+		return "";
089393
+
089393
+	if (!pidns_unshared || !pidns_strace_ids[type])
089393
+		return "";
089393
+
089393
+	snprintf(buf[type], sizeof(buf[type]), format, pidns_strace_ids[type]);
089393
+	return buf[type];
089393
+}
089393
+
089393
+/**
089393
+ * This function is like fork, but does a few more things. It sets up the
089393
+ * child's PGID and SID according to the parameters. Also it fills the
089393
+ * pidns_strace_ids array in the child's memory with the PIDs of the child in
089393
+ * parent's PID namespace. In the parent it waits for the child to terminate
089393
+ * (but leaves the zombie to use it later as a process group). If the child
089393
+ * terminates with nonzero exit status, the test is failed.
089393
+ *
089393
+ * @param pgid     The process group the child should be moved to. It's expected
089393
+ *                 to be a PID of a zombie process (will be reaped). If
089393
+ *                 negative, leave the child in the process group of the parent.
089393
+ *                 If 0, move the process to its own process group.
089393
+ * @param new_sid  Wheather child should be moved to a new session.
089393
+ */
089393
+static pid_t
089393
+pidns_fork(pid_t pgid, bool new_sid)
089393
+{
089393
+	int strace_ids_pipe[2];
089393
+	if (pipe(strace_ids_pipe) < 0)
089393
+		perror_msg_and_fail("pipe");
089393
+
089393
+	fflush(stdout);
089393
+	pid_t pid = fork();
089393
+	if (pid < 0)
089393
+		perror_msg_and_fail("fork");
089393
+
089393
+	if (!pid) {
089393
+		close(strace_ids_pipe[1]);
089393
+
089393
+		ssize_t len = read(strace_ids_pipe[0], pidns_strace_ids,
089393
+				sizeof(pidns_strace_ids));
089393
+		if (len < 0)
089393
+			perror_msg_and_fail("read");
089393
+		if (len != sizeof(pidns_strace_ids))
089393
+			error_msg_and_fail("read returned < sizeof(pidns_strace_ids)");
089393
+
089393
+		close(strace_ids_pipe[0]);
089393
+
089393
+		if (pidns_strace_ids[PT_SID])
089393
+			setsid();
089393
+
089393
+		return 0;
089393
+	}
089393
+
089393
+	pidns_strace_ids[PT_TID] = pid;
089393
+	pidns_strace_ids[PT_TGID] = pid;
089393
+	pidns_strace_ids[PT_PGID] = 0;
089393
+	pidns_strace_ids[PT_SID] = 0;
089393
+
089393
+	if (!pgid)
089393
+		pgid = pid;
089393
+
089393
+	if (pgid > 0) {
089393
+		if (setpgid(pid, pgid) < 0)
089393
+			perror_msg_and_fail("setpgid");
089393
+
089393
+		pidns_strace_ids[PT_PGID] = pgid;
089393
+	}
089393
+
089393
+	/* Reap group leader to test PGID decoding */
089393
+	if (pgid > 0 && pgid != pid) {
089393
+		int ret = waitpid(pgid, NULL, WNOHANG);
089393
+		if (ret < 0)
089393
+			perror_msg_and_fail("wait");
089393
+		if (!ret)
089393
+			error_msg_and_fail("could not reap group leader");
089393
+	}
089393
+
089393
+	if (new_sid) {
089393
+		pidns_strace_ids[PT_SID] = pid;
089393
+		pidns_strace_ids[PT_PGID] = pid;
089393
+	}
089393
+
089393
+	ssize_t len = write(strace_ids_pipe[1], pidns_strace_ids,
089393
+	                     sizeof(pidns_strace_ids));
089393
+	if (len < 0)
089393
+		perror_msg_and_fail("write");
089393
+	if (len != sizeof(pidns_strace_ids))
089393
+		error_msg_and_fail("write returned < sizeof(pidns_strace_ids)");
089393
+
089393
+	close(strace_ids_pipe[0]);
089393
+	close(strace_ids_pipe[1]);
089393
+
089393
+	/* WNOWAIT: leave the zombie, to be able to use it as a process group */
089393
+	siginfo_t siginfo;
089393
+	if (waitid(P_PID, pid, &siginfo, WEXITED | WNOWAIT) < 0)
089393
+		perror_msg_and_fail("wait");
089393
+	if (siginfo.si_code != CLD_EXITED || siginfo.si_status)
089393
+		error_msg_and_fail("child terminated with nonzero exit status");
089393
+
089393
+	return pid;
089393
+}
089393
+
089393
+static void
089393
+create_init_process(void)
089393
+{
089393
+	int child_pipe[2];
089393
+	if (pipe(child_pipe) < 0)
089393
+		perror_msg_and_fail("pipe");
089393
+
089393
+	pid_t pid = fork();
089393
+	if (pid < 0)
089393
+		perror_msg_and_fail("fork");
089393
+
089393
+	if (!pid) {
089393
+		close(child_pipe[1]);
089393
+		if (read(child_pipe[0], &child_pipe[1], sizeof(int)) != 0)
089393
+			_exit(1);
089393
+		_exit(0);
089393
+	}
089393
+
089393
+	close(child_pipe[0]);
089393
+}
089393
+
089393
+void
089393
+check_ns_ioctl(void)
089393
+{
089393
+	int fd = open("/proc/self/ns/pid", O_RDONLY);
089393
+	if (fd < 0) {
089393
+		if (errno == ENOENT)
089393
+			perror_msg_and_skip("opening /proc/self/ns/pid");
089393
+		else
089393
+			perror_msg_and_fail("opening /proc/self/ns/pid");
089393
+	}
089393
+
089393
+	int userns_fd = ioctl(fd, NS_GET_USERNS);
089393
+	if (userns_fd < 0) {
089393
+		if (errno == ENOTTY)
089393
+			error_msg_and_skip("NS_* ioctl commands are not "
089393
+			                   "supported by the kernel");
089393
+		else
089393
+			perror_msg_and_fail("ioctl(NS_GET_USERNS)");
089393
+	}
089393
+
089393
+	close(userns_fd);
089393
+	close(fd);
089393
+}
089393
+
089393
+void
089393
+pidns_test_init(void)
089393
+{
089393
+	pidns_translation = true;
089393
+
089393
+	check_ns_ioctl();
089393
+
089393
+	if (!pidns_fork(-1, false))
089393
+		return;
089393
+
089393
+	/* Unshare user namespace too, so we do not need to be root */
089393
+	if (unshare(CLONE_NEWUSER | CLONE_NEWPID) < 0) {
089393
+		if (errno == EPERM)
089393
+			perror_msg_and_skip("unshare");
089393
+
089393
+		perror_msg_and_fail("unshare");
089393
+	}
089393
+
089393
+	pidns_unshared = true;
089393
+
089393
+	create_init_process();
089393
+
089393
+	if (!pidns_fork(-1, false))
089393
+		return;
089393
+
089393
+	if (!pidns_fork(-1, true))
089393
+		return;
089393
+
089393
+	pid_t pgid;
089393
+	if (!(pgid = pidns_fork(0, false)))
089393
+		return;
089393
+
089393
+	if (!pidns_fork(pgid, false))
089393
+		return;
089393
+
089393
+	exit(0);
089393
+}
089393
Index: strace-5.7/tests-mx32/pidns.h
089393
===================================================================
089393
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
089393
+++ strace-5.7/tests-mx32/pidns.h	2020-09-09 19:49:54.010575350 +0200
089393
@@ -0,0 +1,56 @@
089393
+/*
089393
+ * Test PID namespace translation
089393
+ *
089393
+ * Copyright (c) 2020 Ákos Uzonyi <uzonyi.akos@gmail.com>
089393
+ * All rights reserved.
089393
+ *
089393
+ * SPDX-License-Identifier: LGPL-2.1-or-later
089393
+ */
089393
+#ifndef STRACE_PIDNS_H
089393
+#define STRACE_PIDNS_H
089393
+
089393
+#ifdef PIDNS_TRANSLATION
089393
+# define PIDNS_TEST_INIT pidns_test_init()
089393
+#else
089393
+# define PIDNS_TEST_INIT
089393
+#endif
089393
+
089393
+#include <sys/types.h>
089393
+
089393
+enum pid_type {
089393
+	PT_TID,
089393
+	PT_TGID,
089393
+	PT_PGID,
089393
+	PT_SID,
089393
+
089393
+	PT_COUNT,
089393
+	PT_NONE = -1
089393
+};
089393
+
089393
+/* Prints leader (process tid) if pidns_test_init was called */
089393
+void pidns_print_leader(void);
089393
+
089393
+/*
089393
+ * Returns a static buffer containing the translation string of our PID.
089393
+ */
089393
+const char *pidns_pid2str(enum pid_type type);
089393
+
089393
+/**
089393
+ * Skips the test if NS_* ioctl commands are not supported by the kernel.
089393
+ */
089393
+void check_ns_ioctl(void);
089393
+
089393
+/**
089393
+ * Init pidns testing.
089393
+ *
089393
+ * Should be called at the beginning of the test's main function
089393
+ *
089393
+ * This function calls fork a couple of times, and returns in the child
089393
+ * processes. These child processes are in a new PID namespace with different
089393
+ * PID configurations (group leader, session leader, ...). If any child
089393
+ * terminates with nonzero exit status the test is failed. Otherwise the test is
089393
+ * succesful, and the parent process exits with 0.
089393
+ */
089393
+void pidns_test_init(void);
089393
+
089393
+#endif
089393
\ No newline at end of file
089393
Index: strace-5.7/tests/Makefile.in
089393
===================================================================
089393
--- strace-5.7.orig/tests/Makefile.in	2020-09-09 19:46:24.904450714 +0200
089393
+++ strace-5.7/tests/Makefile.in	2020-09-09 19:51:23.607628754 +0200
089393
@@ -531,7 +531,7 @@
089393
 	libtests_a-libmmsg.$(OBJEXT) \
089393
 	libtests_a-libsocketcall.$(OBJEXT) \
089393
 	libtests_a-lock_file.$(OBJEXT) \
089393
-	libtests_a-overflowuid.$(OBJEXT) \
089393
+	libtests_a-overflowuid.$(OBJEXT) libtests_a-pidns.$(OBJEXT) \
089393
 	libtests_a-pipe_maxfd.$(OBJEXT) \
089393
 	libtests_a-print_quoted_string.$(OBJEXT) \
089393
 	libtests_a-print_time.$(OBJEXT) \
089393
@@ -3899,6 +3899,7 @@
089393
 	./$(DEPDIR)/libtests_a-libsocketcall.Po \
089393
 	./$(DEPDIR)/libtests_a-lock_file.Po \
089393
 	./$(DEPDIR)/libtests_a-overflowuid.Po \
089393
+	./$(DEPDIR)/libtests_a-pidns.Po \
089393
 	./$(DEPDIR)/libtests_a-pipe_maxfd.Po \
089393
 	./$(DEPDIR)/libtests_a-print_quoted_string.Po \
089393
 	./$(DEPDIR)/libtests_a-print_time.Po \
089393
@@ -5122,6 +5123,8 @@
089393
 	libsocketcall.c \
089393
 	lock_file.c \
089393
 	overflowuid.c \
089393
+	pidns.c \
089393
+	pidns.h \
089393
 	pipe_maxfd.c \
089393
 	print_quoted_string.c \
089393
 	print_time.c \
089393
@@ -9926,6 +9929,7 @@
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-libsocketcall.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-lock_file.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-overflowuid.Po@am__quote@ # am--include-marker
089393
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-pidns.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-pipe_maxfd.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-print_quoted_string.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-print_time.Po@am__quote@ # am--include-marker
089393
@@ -10651,6 +10655,20 @@
089393
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-overflowuid.obj `if test -f 'overflowuid.c'; then $(CYGPATH_W) 'overflowuid.c'; else $(CYGPATH_W) '$(srcdir)/overflowuid.c'; fi`
089393
 
089393
+libtests_a-pidns.o: pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pidns.o -MD -MP -MF $(DEPDIR)/libtests_a-pidns.Tpo -c -o libtests_a-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pidns.Tpo $(DEPDIR)/libtests_a-pidns.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libtests_a-pidns.o' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
089393
+
089393
+libtests_a-pidns.obj: pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pidns.obj -MD -MP -MF $(DEPDIR)/libtests_a-pidns.Tpo -c -o libtests_a-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pidns.Tpo $(DEPDIR)/libtests_a-pidns.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libtests_a-pidns.obj' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
089393
+
089393
 libtests_a-pipe_maxfd.o: pipe_maxfd.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pipe_maxfd.o -MD -MP -MF $(DEPDIR)/libtests_a-pipe_maxfd.Tpo -c -o libtests_a-pipe_maxfd.o `test -f 'pipe_maxfd.c' || echo '$(srcdir)/'`pipe_maxfd.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pipe_maxfd.Tpo $(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
@@ -11748,6 +11766,7 @@
089393
 	-rm -f ./$(DEPDIR)/libtests_a-libsocketcall.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-lock_file.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-overflowuid.Po
089393
+	-rm -f ./$(DEPDIR)/libtests_a-pidns.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_quoted_string.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_time.Po
089393
@@ -12605,6 +12624,7 @@
089393
 	-rm -f ./$(DEPDIR)/libtests_a-libsocketcall.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-lock_file.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-overflowuid.Po
089393
+	-rm -f ./$(DEPDIR)/libtests_a-pidns.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_quoted_string.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_time.Po
089393
Index: strace-5.7/tests-m32/Makefile.in
089393
===================================================================
089393
--- strace-5.7.orig/tests-m32/Makefile.in	2020-09-09 19:49:34.530563739 +0200
089393
+++ strace-5.7/tests-m32/Makefile.in	2020-09-09 19:52:01.333651241 +0200
089393
@@ -531,7 +531,7 @@
089393
 	libtests_a-libmmsg.$(OBJEXT) \
089393
 	libtests_a-libsocketcall.$(OBJEXT) \
089393
 	libtests_a-lock_file.$(OBJEXT) \
089393
-	libtests_a-overflowuid.$(OBJEXT) \
089393
+	libtests_a-overflowuid.$(OBJEXT) libtests_a-pidns.$(OBJEXT) \
089393
 	libtests_a-pipe_maxfd.$(OBJEXT) \
089393
 	libtests_a-print_quoted_string.$(OBJEXT) \
089393
 	libtests_a-print_time.$(OBJEXT) \
089393
@@ -3899,6 +3899,7 @@
089393
 	./$(DEPDIR)/libtests_a-libsocketcall.Po \
089393
 	./$(DEPDIR)/libtests_a-lock_file.Po \
089393
 	./$(DEPDIR)/libtests_a-overflowuid.Po \
089393
+	./$(DEPDIR)/libtests_a-pidns.Po \
089393
 	./$(DEPDIR)/libtests_a-pipe_maxfd.Po \
089393
 	./$(DEPDIR)/libtests_a-print_quoted_string.Po \
089393
 	./$(DEPDIR)/libtests_a-print_time.Po \
089393
@@ -5122,6 +5123,8 @@
089393
 	libsocketcall.c \
089393
 	lock_file.c \
089393
 	overflowuid.c \
089393
+	pidns.c \
089393
+	pidns.h \
089393
 	pipe_maxfd.c \
089393
 	print_quoted_string.c \
089393
 	print_time.c \
089393
@@ -9926,6 +9929,7 @@
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-libsocketcall.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-lock_file.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-overflowuid.Po@am__quote@ # am--include-marker
089393
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-pidns.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-pipe_maxfd.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-print_quoted_string.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-print_time.Po@am__quote@ # am--include-marker
089393
@@ -10651,6 +10655,20 @@
089393
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-overflowuid.obj `if test -f 'overflowuid.c'; then $(CYGPATH_W) 'overflowuid.c'; else $(CYGPATH_W) '$(srcdir)/overflowuid.c'; fi`
089393
 
089393
+libtests_a-pidns.o: pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pidns.o -MD -MP -MF $(DEPDIR)/libtests_a-pidns.Tpo -c -o libtests_a-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pidns.Tpo $(DEPDIR)/libtests_a-pidns.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libtests_a-pidns.o' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
089393
+
089393
+libtests_a-pidns.obj: pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pidns.obj -MD -MP -MF $(DEPDIR)/libtests_a-pidns.Tpo -c -o libtests_a-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pidns.Tpo $(DEPDIR)/libtests_a-pidns.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libtests_a-pidns.obj' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
089393
+
089393
 libtests_a-pipe_maxfd.o: pipe_maxfd.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pipe_maxfd.o -MD -MP -MF $(DEPDIR)/libtests_a-pipe_maxfd.Tpo -c -o libtests_a-pipe_maxfd.o `test -f 'pipe_maxfd.c' || echo '$(srcdir)/'`pipe_maxfd.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pipe_maxfd.Tpo $(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
@@ -11748,6 +11766,7 @@
089393
 	-rm -f ./$(DEPDIR)/libtests_a-libsocketcall.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-lock_file.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-overflowuid.Po
089393
+	-rm -f ./$(DEPDIR)/libtests_a-pidns.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_quoted_string.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_time.Po
089393
@@ -12605,6 +12624,7 @@
089393
 	-rm -f ./$(DEPDIR)/libtests_a-libsocketcall.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-lock_file.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-overflowuid.Po
089393
+	-rm -f ./$(DEPDIR)/libtests_a-pidns.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_quoted_string.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_time.Po
089393
Index: strace-5.7/tests-mx32/Makefile.in
089393
===================================================================
089393
--- strace-5.7.orig/tests-mx32/Makefile.in	2020-09-09 19:49:39.557566736 +0200
089393
+++ strace-5.7/tests-mx32/Makefile.in	2020-09-09 19:52:26.062665980 +0200
089393
@@ -531,7 +531,7 @@
089393
 	libtests_a-libmmsg.$(OBJEXT) \
089393
 	libtests_a-libsocketcall.$(OBJEXT) \
089393
 	libtests_a-lock_file.$(OBJEXT) \
089393
-	libtests_a-overflowuid.$(OBJEXT) \
089393
+	libtests_a-overflowuid.$(OBJEXT) libtests_a-pidns.$(OBJEXT) \
089393
 	libtests_a-pipe_maxfd.$(OBJEXT) \
089393
 	libtests_a-print_quoted_string.$(OBJEXT) \
089393
 	libtests_a-print_time.$(OBJEXT) \
089393
@@ -3899,6 +3899,7 @@
089393
 	./$(DEPDIR)/libtests_a-libsocketcall.Po \
089393
 	./$(DEPDIR)/libtests_a-lock_file.Po \
089393
 	./$(DEPDIR)/libtests_a-overflowuid.Po \
089393
+	./$(DEPDIR)/libtests_a-pidns.Po \
089393
 	./$(DEPDIR)/libtests_a-pipe_maxfd.Po \
089393
 	./$(DEPDIR)/libtests_a-print_quoted_string.Po \
089393
 	./$(DEPDIR)/libtests_a-print_time.Po \
089393
@@ -5122,6 +5123,8 @@
089393
 	libsocketcall.c \
089393
 	lock_file.c \
089393
 	overflowuid.c \
089393
+	pidns.c \
089393
+	pidns.h \
089393
 	pipe_maxfd.c \
089393
 	print_quoted_string.c \
089393
 	print_time.c \
089393
@@ -9926,6 +9929,7 @@
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-libsocketcall.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-lock_file.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-overflowuid.Po@am__quote@ # am--include-marker
089393
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-pidns.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-pipe_maxfd.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-print_quoted_string.Po@am__quote@ # am--include-marker
089393
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtests_a-print_time.Po@am__quote@ # am--include-marker
089393
@@ -10651,6 +10655,20 @@
089393
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-overflowuid.obj `if test -f 'overflowuid.c'; then $(CYGPATH_W) 'overflowuid.c'; else $(CYGPATH_W) '$(srcdir)/overflowuid.c'; fi`
089393
 
089393
+libtests_a-pidns.o: pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pidns.o -MD -MP -MF $(DEPDIR)/libtests_a-pidns.Tpo -c -o libtests_a-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pidns.Tpo $(DEPDIR)/libtests_a-pidns.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libtests_a-pidns.o' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-pidns.o `test -f 'pidns.c' || echo '$(srcdir)/'`pidns.c
089393
+
089393
+libtests_a-pidns.obj: pidns.c
089393
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pidns.obj -MD -MP -MF $(DEPDIR)/libtests_a-pidns.Tpo -c -o libtests_a-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
089393
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pidns.Tpo $(DEPDIR)/libtests_a-pidns.Po
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pidns.c' object='libtests_a-pidns.obj' libtool=no @AMDEPBACKSLASH@
089393
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
089393
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libtests_a-pidns.obj `if test -f 'pidns.c'; then $(CYGPATH_W) 'pidns.c'; else $(CYGPATH_W) '$(srcdir)/pidns.c'; fi`
089393
+
089393
 libtests_a-pipe_maxfd.o: pipe_maxfd.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libtests_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libtests_a-pipe_maxfd.o -MD -MP -MF $(DEPDIR)/libtests_a-pipe_maxfd.Tpo -c -o libtests_a-pipe_maxfd.o `test -f 'pipe_maxfd.c' || echo '$(srcdir)/'`pipe_maxfd.c
089393
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libtests_a-pipe_maxfd.Tpo $(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
@@ -11748,6 +11766,7 @@
089393
 	-rm -f ./$(DEPDIR)/libtests_a-libsocketcall.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-lock_file.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-overflowuid.Po
089393
+	-rm -f ./$(DEPDIR)/libtests_a-pidns.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_quoted_string.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_time.Po
089393
@@ -12605,6 +12624,7 @@
089393
 	-rm -f ./$(DEPDIR)/libtests_a-libsocketcall.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-lock_file.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-overflowuid.Po
089393
+	-rm -f ./$(DEPDIR)/libtests_a-pidns.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-pipe_maxfd.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_quoted_string.Po
089393
 	-rm -f ./$(DEPDIR)/libtests_a-print_time.Po