This is no likely to happen as we use O_NOFOLLOW with O_DIRECTORY,
but it's better to be prepared...
This will be more important in the upcoming openat2(RESOLVE_NO_SYMLINK)
case, but we should be consitent...
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
&how);
}
- if ((fd == -1) && (errno == ENOTDIR)) {
+ /*
+ * O_NOFOLLOW|O_DIRECTORY results in
+ * ENOTDIR instead of ELOOP.
+ *
+ * But we should be prepared to handle ELOOP too.
+ */
+ if ((fd == -1) && (errno == ENOTDIR || errno == ELOOP)) {
+ NTSTATUS orig_status = map_nt_error_from_unix(errno);
+
status = readlink_talloc(
mem_ctx, dirfsp, &rel_fname, substitute);
/*
* Restore the error status from SMB_VFS_OPENAT()
*/
- status = NT_STATUS_NOT_A_DIRECTORY;
+ status = orig_status;
}
goto fail;
}