summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2022-08-08 15:23:29 +0200
committerVolker Lendecke <vl@samba.org>2022-08-15 15:03:36 +0000
commitce804b78164a3166a16ca3071028536761fd18d7 (patch)
tree02ffe5ed5fcb9c23f8c61e356157bf3a4aa1cec9 /lib/replace
parent2369d0833361faf4a125431e735fce7efb6024d6 (diff)
downloadsamba-ce804b78164a3166a16ca3071028536761fd18d7.tar.gz
lib/replace: add a replacement for openat2() that returns ENOSYS
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/replace.c9
-rw-r--r--lib/replace/system/filesys.h35
-rw-r--r--lib/replace/wscript1
3 files changed, 45 insertions, 0 deletions
diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index 0652cb4e6d6..763afec78c5 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -1081,3 +1081,12 @@ ssize_t rep_copy_file_range(int fd_in,
return -1;
}
#endif /* HAVE_COPY_FILE_RANGE */
+
+#ifndef HAVE_OPENAT2
+long rep_openat2(int dirfd, const char *pathname,
+ struct open_how *how, size_t size)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif /* !HAVE_OPENAT2 */
diff --git a/lib/replace/system/filesys.h b/lib/replace/system/filesys.h
index bb9482c69af..8005b18780f 100644
--- a/lib/replace/system/filesys.h
+++ b/lib/replace/system/filesys.h
@@ -243,4 +243,39 @@ int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size
#endif /* !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS) */
+#ifdef HAVE_LINUX_OPENAT2_H
+#include <linux/openat2.h>
+#else /* ! HAVE_LINUX_OPENAT2_H */
+/* how->resolve flags for openat2(2). */
+#define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings
+ (includes bind-mounts). */
+#define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style
+ "magic-links". */
+#define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks
+ (implies OEXT_NO_MAGICLINKS) */
+#define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like
+ "..", symlinks, and absolute
+ paths which escape the dirfd. */
+#define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".."
+ be scoped inside the dirfd
+ (similar to chroot(2)). */
+#define RESOLVE_CACHED 0x20 /* Only complete if resolution can be
+ completed through cached lookup. May
+ return -EAGAIN if that's not
+ possible. */
+struct __rep_open_how {
+ uint64_t flags;
+ uint64_t mode;
+ uint64_t resolve;
+};
+#define open_how __rep_open_how
+#endif /* ! HAVE_LINUX_OPENAT2_H */
+
+#ifndef HAVE_OPENAT2
+long rep_openat2(int dirfd, const char *pathname,
+ struct open_how *how, size_t size);
+#define openat2(dirfd, pathname, how, size) \
+ rep_openat2(dirfd, pathname, how, size)
+#endif /* !HAVE_OPENAT2 */
+
#endif
diff --git a/lib/replace/wscript b/lib/replace/wscript
index dd9b19219a1..2f179992c82 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -66,6 +66,7 @@ def configure(conf):
conf.CHECK_HEADERS('errno.h')
conf.CHECK_HEADERS('getopt.h iconv.h')
conf.CHECK_HEADERS('memory.h nss.h sasl/sasl.h')
+ conf.CHECK_HEADERS('linux/openat2.h')
conf.CHECK_FUNCS_IN('inotify_init', 'inotify', checklibc=True,
headers='sys/inotify.h')