Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Max Kellermann <max+openembedded@blarg.de>
To: openembedded-core@lists.openembedded.org
Cc: Max Kellermann <max.kellermann@gmail.com>
Subject: [PATCH pseudo v2] ports/linux: wrap faccessat()
Date: Thu,  1 Aug 2019 18:20:41 +0200	[thread overview]
Message-ID: <20190801162041.24941-1-max+openembedded@blarg.de> (raw)
In-Reply-To: <20190801111701.367588b2@seebsdell>

From: Max Kellermann <max.kellermann@gmail.com>

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
---
 ports/linux/guts/faccessat.c | 33 +++++++++++++++++++++++++++++++++
 ports/linux/wrapfuncs.in     |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 ports/linux/guts/faccessat.c

diff --git a/ports/linux/guts/faccessat.c b/ports/linux/guts/faccessat.c
new file mode 100644
index 0000000..64189fa
--- /dev/null
+++ b/ports/linux/guts/faccessat.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 Max Kellermann <max.kellermann@gmail.com>
+ * guts/COPYRIGHT for information.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * static int
+ * wrap_faccessat(int dirfd, const char *path, int mode, int flags) {
+ *	int rc = -1;
+ */
+	struct stat64 buf;
+
+	/* note:  no attempt to handle the case where user isn't
+	 * root.
+	 */
+	rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, flags);
+	if (rc == -1)
+		return rc;
+
+	if (mode & X_OK) {
+		if (buf.st_mode & 0111) {
+			return 0;
+		} else {
+			errno = EPERM;
+			return -1;
+		}
+	} else {
+		return 0;
+	}
+
+/*	return rc;
+ * }
+ */
diff --git a/ports/linux/wrapfuncs.in b/ports/linux/wrapfuncs.in
index a129eba..2a118fc 100644
--- a/ports/linux/wrapfuncs.in
+++ b/ports/linux/wrapfuncs.in
@@ -56,3 +56,4 @@ int getgrent_r(struct group *gbuf, char *buf, size_t buflen, struct group **gbuf
 int capset(cap_user_header_t hdrp, const cap_user_data_t datap); /* real_func=pseudo_capset */
 long syscall(long nr, ...); /* hand_wrapped=1 */
 int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags); /* flags=AT_SYMLINK_NOFOLLOW */
+int faccessat(int dirfd, const char *path, int mode, int flags);
-- 
2.20.1



  parent reply	other threads:[~2019-08-01 16:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 16:02 [PATCH pseudo] ports/linux: wrap faccessat() Max Kellermann
2019-08-01 16:17 ` Seebs
2019-08-01 16:19   ` Max Kellermann
2019-08-01 16:20   ` Max Kellermann [this message]
2019-08-01 16:31   ` ✗ patchtest: failure for ports/linux: wrap faccessat() (rev2) Patchwork
2019-08-01 16:31 ` ✗ patchtest: failure for ports/linux: wrap faccessat() Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190801162041.24941-1-max+openembedded@blarg.de \
    --to=max+openembedded@blarg.de \
    --cc=max.kellermann@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox