[PATCH] Remove some code duplication

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Nov 12 20:35:55 UTC 2018


Hi!

Review appreciated!

Thanks, Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From cfb5d5591f563894c3decafaebb07fba64d7dadf Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 9 Nov 2018 07:55:40 +0100
Subject: [PATCH] smbd: Use wire_perms_to_unix in unix_perms_from_wire

Same code, less lines

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/trans2.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 0003c3682e3..6ec319ce870 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1530,24 +1530,7 @@ static NTSTATUS unix_perms_from_wire( connection_struct *conn,
 		}
 	}
 
-	ret |= ((perms & UNIX_X_OTH ) ? S_IXOTH : 0);
-	ret |= ((perms & UNIX_W_OTH ) ? S_IWOTH : 0);
-	ret |= ((perms & UNIX_R_OTH ) ? S_IROTH : 0);
-	ret |= ((perms & UNIX_X_GRP ) ? S_IXGRP : 0);
-	ret |= ((perms & UNIX_W_GRP ) ? S_IWGRP : 0);
-	ret |= ((perms & UNIX_R_GRP ) ? S_IRGRP : 0);
-	ret |= ((perms & UNIX_X_USR ) ? S_IXUSR : 0);
-	ret |= ((perms & UNIX_W_USR ) ? S_IWUSR : 0);
-	ret |= ((perms & UNIX_R_USR ) ? S_IRUSR : 0);
-#ifdef S_ISVTX
-	ret |= ((perms & UNIX_STICKY ) ? S_ISVTX : 0);
-#endif
-#ifdef S_ISGID
-	ret |= ((perms & UNIX_SET_GID ) ? S_ISGID : 0);
-#endif
-#ifdef S_ISUID
-	ret |= ((perms & UNIX_SET_UID ) ? S_ISUID : 0);
-#endif
+	ret = wire_perms_to_unix(perms);
 
 	if (ptype == PERM_NEW_FILE) {
 		/*
-- 
2.11.0



More information about the samba-technical mailing list