Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
mode_t mode)
{
int error = inject_unix_error("openat", handle);
-
- if (!fsp->fsp_flags.is_pathref && error != 0) {
+ int dirfsp_flags = (O_NOFOLLOW|O_DIRECTORY);
+ bool return_error;
+
+#ifdef O_PATH
+ dirfsp_flags |= O_PATH;
+#else
+#ifdef O_SEARCH
+ dirfsp_flags |= O_SEARCH;
+#endif
+#endif
+
+ return_error = (error != 0);
+ return_error &= !fsp->fsp_flags.is_pathref;
+ return_error &= ((flags & dirfsp_flags) != dirfsp_flags);
+
+ if (return_error) {
errno = error;
return -1;
}