summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-10-03 12:02:36 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-10-07 11:18:35 +0100
commite1e481f3608c05ab14c61bf45cd0837d7287b6a5 (patch)
tree00e58150dc47c26dea5ff99e1e56182e5ad0a25b
parent929a27bf6cbca94d1141d2094ae0c915d93bd3f4 (diff)
downloadopenembedded-core-contrib-e1e481f3608c05ab14c61bf45cd0837d7287b6a5.tar.gz
pseudo: Add may unlink patch
Mark files which are unlinked (nlink == 0) but open with fd's as "may-unlink" to avoid problematic database entries. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/pseudo/files/mayunlink.patch37
-rw-r--r--meta/recipes-devtools/pseudo/pseudo_git.bb1
2 files changed, 38 insertions, 0 deletions
diff --git a/meta/recipes-devtools/pseudo/files/mayunlink.patch b/meta/recipes-devtools/pseudo/files/mayunlink.patch
new file mode 100644
index 0000000000..9d54e40dd9
--- /dev/null
+++ b/meta/recipes-devtools/pseudo/files/mayunlink.patch
@@ -0,0 +1,37 @@
+Some operations may call unlink() on an open fd, then call fchown/fchmod/fstat
+on that fd. This would currently readd its entry to the database, which
+is necessary to preserve its permissions information however since that
+file will be lost when it is closed, we don't want the DB entry to persist.
+Marking it as may_unlink means the code will know its likely been deleted
+and ignore the entry later, giving improved behaviour that simple path
+mismatch warnings. We can use an nlink of zero to detect this.
+
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+Upstream-Status: Pending
+
+Index: git/pseudo.c
+===================================================================
+--- git.orig/pseudo.c
++++ git/pseudo.c
+@@ -1100,6 +1100,21 @@ pseudo_op(pseudo_msg_t *msg, const char
+ break;
+ }
+
++ switch (msg->op) {
++ case OP_FCHOWN: /* FALLTHROUGH */
++ case OP_FCHMOD: /* FALLTHROUGH */
++ case OP_FSTAT:
++ if (!found_path && !found_ino && (msg->nlink == 0)) {
++ /* If nlink is 0 for an fchown/fchmod/fstat, we probably have an fd which is
++ * unlinked and we don't want to do inode/path matching against it. Marking it
++ * as may unlink gives the right hints in the database to ensure we
++ * handle correctly whilst maintaining the permissions whilst the
++ * file exists for the fd. */
++ pdb_may_unlink_file(msg, msg->client);
++ }
++ break;
++ }
++
+ op_exit:
+ /* in the case of an exact match, we just used the pointer
+ * rather than allocating space.
diff --git a/meta/recipes-devtools/pseudo/pseudo_git.bb b/meta/recipes-devtools/pseudo/pseudo_git.bb
index 7857b4f1b1..c5040f5f7f 100644
--- a/meta/recipes-devtools/pseudo/pseudo_git.bb
+++ b/meta/recipes-devtools/pseudo/pseudo_git.bb
@@ -7,6 +7,7 @@ SRC_URI = "git://git.yoctoproject.org/pseudo;branch=oe-core \
file://abort_on_mismatch.patch \
file://track_link_fds.patch \
file://xattr_fix.patch \
+ file://mayunlink.patch \
file://fallback-passwd \
file://fallback-group \
"