From: Volker Lendecke Date: Fri, 6 Oct 2023 11:42:19 +0000 (+0200) Subject: smbd: Expand IS_DOS_* macros X-Git-Tag: tevent-0.16.0~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=817f68e4a13d38acc6e9849643a95e35a7ef08e1;p=thirdparty%2Fsamba.git smbd: Expand IS_DOS_* macros To me these macros hide more than they clarify. In a lot of places we already directly check for these flags without those macros. Unify that. Also, check for the dosmode bits first, lp_map_* is a bit more effort to evaluate. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index dec1a22edd0..f2b61f24177 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -112,7 +112,8 @@ mode_t unix_mode(connection_struct *conn, int dosmode, mode_t dir_mode = 0; /* Mode of the inherit_from directory if * inheriting. */ - if (!lp_store_dos_attributes(SNUM(conn)) && IS_DOS_READONLY(dosmode)) { + if ((dosmode & FILE_ATTRIBUTE_READONLY) && + !lp_store_dos_attributes(SNUM(conn))) { result &= ~(S_IWUSR | S_IWGRP | S_IWOTH); } @@ -140,7 +141,7 @@ mode_t unix_mode(connection_struct *conn, int dosmode, result = 0; } - if (IS_DOS_DIR(dosmode)) { + if (dosmode & FILE_ATTRIBUTE_DIRECTORY) { /* We never make directories read only for the owner as under DOS a user can always create a file in a read-only directory. */ result |= (S_IFDIR | S_IWUSR); @@ -158,14 +159,20 @@ mode_t unix_mode(connection_struct *conn, int dosmode, result |= lp_force_directory_mode(SNUM(conn)); } } else { - if (lp_map_archive(SNUM(conn)) && IS_DOS_ARCHIVE(dosmode)) + if ((dosmode & FILE_ATTRIBUTE_ARCHIVE) && + lp_map_archive(SNUM(conn))) { result |= S_IXUSR; + } - if (lp_map_system(SNUM(conn)) && IS_DOS_SYSTEM(dosmode)) + if ((dosmode & FILE_ATTRIBUTE_SYSTEM) && + lp_map_system(SNUM(conn))) { result |= S_IXGRP; + } - if (lp_map_hidden(SNUM(conn)) && IS_DOS_HIDDEN(dosmode)) + if ((dosmode & FILE_ATTRIBUTE_HIDDEN) && + lp_map_hidden(SNUM(conn))) { result |= S_IXOTH; + } if (dir_mode) { /* Inherit 666 component of parent directory mode */