From: Stefan Metzmacher Date: Fri, 12 Aug 2022 17:12:44 +0000 (+0200) Subject: s3:smbd: let openat_pathref_dirfsp_nosymlink() handle ELOOP similar to ENOTDIR X-Git-Tag: talloc-2.4.0~1431 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35b99c87ef92df006f8b0a41bbea051f0faeadb9;p=thirdparty%2Fsamba.git s3:smbd: let openat_pathref_dirfsp_nosymlink() handle ELOOP similar to ENOTDIR 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 Reviewed-by: Volker Lendecke --- diff --git a/source3/smbd/files.c b/source3/smbd/files.c index f23e9e96e52..23de0ad63c2 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -860,7 +860,15 @@ next: &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); @@ -898,7 +906,7 @@ next: /* * Restore the error status from SMB_VFS_OPENAT() */ - status = NT_STATUS_NOT_A_DIRECTORY; + status = orig_status; } goto fail; }