]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Expand IS_DOS_* macros
authorVolker Lendecke <vl@samba.org>
Fri, 6 Oct 2023 11:42:19 +0000 (13:42 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 10 Oct 2023 23:23:40 +0000 (23:23 +0000)
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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dosmode.c

index dec1a22edd0a630dfbb901ae9de509a16fe1779b..f2b61f24177e7321553b2ae99d95f8bd93d47eea 100644 (file)
@@ -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 */