@@ -620,6 +620,21 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurre
pseudo_diag("pseudo_append_element: invalid args.\n");
return -1;
}
+
+ /* If we end up resolving a path into /proc, it has special meaning.
+ * For instance, /dev/fd/0 -> /proc/self/fd/0 ->
+ * /proc/1475524/fd/0 -> /proc/1475524/fd/pipe:[1177004485]
+ * Trying to access the resolved name "pipe:[....]" may fail.
+ * Instead, once we enter /proc, we stop expanding symlinks.
+ *
+ * This now results in /dev/fd/0 -> /proc/self/fd/0
+ */
+ if (strncmp(newpath, "/proc", 5) == 0) {
+ pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "paes: %s in /proc\n",
+ newpath ? newpath : "<nil>");
+ leave_this = 1;
+ }
+
current = *pcurrent;
pseudo_debug(PDBGF_PATH | PDBGF_VERBOSE, "pae: '%s', + '%.*s', is_dir %d\n",
newpath, (int) elen, element, is_dir);
new file mode 100755
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+#
+# See Yocto Project bugzilla 16028
+#
+# It was determined that a utility that use /dev/fd may fail when run under
+# pseudo, while working properly outside.
+#
+# For example: echo "test" | cat /dev/fd/0
+
+# Tests
+result=$(echo "test" | cat 2>&1)
+rc=$?
+if [ $rc -ne 0 -o "$result" != "test" ]; then
+ echo Failed simple echo pipe test - $rc:
+ echo $result
+ exit 1
+fi
+
+result=$(echo "test" | cat /dev/fd/0 2>&1)
+rc=$?
+if [ $rc -ne 0 -o "$result" != "test" ]; then
+ echo Failed /dev/fd/0 echo pipe test - $rc:
+ echo $result
+ exit 1
+fi