From 21d16fe2122cab9b2ed111d76d78b7dd5c8b66df Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 30 Apr 2020 15:35:36 -0700 Subject: [PATCH] s3: smbd: Reformat users of can_write_to_file(). Make new parameter addition clearer. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/smbd/dosmode.c | 15 +++++++++++---- source3/smbd/file_access.c | 2 +- source3/smbd/nttrans.c | 8 ++++++-- source3/smbd/posix_acls.c | 4 +++- source3/smbd/proto.h | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 7ddc5fd3fc6..b061e9ac794 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -219,7 +219,9 @@ static uint32_t dos_mode_from_sbuf(connection_struct *conn, } } else if (ro_opts == MAP_READONLY_PERMISSIONS) { /* Check actual permissions for read-only. */ - if (!can_write_to_file(conn, smb_fname)) { + if (!can_write_to_file(conn, + smb_fname)) + { result |= FILE_ATTRIBUTE_READONLY; } } /* Else never set the readonly bit. */ @@ -539,7 +541,8 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn, } if (!set_dosmode_ok && lp_dos_filemode(SNUM(conn))) { - set_dosmode_ok = can_write_to_file(conn, smb_fname); + set_dosmode_ok = can_write_to_file(conn, + smb_fname); } if (!set_dosmode_ok) { @@ -1069,7 +1072,9 @@ int file_set_dosmode(connection_struct *conn, bits on a file. Just like file_ntimes below. */ - if (!can_write_to_file(conn, smb_fname)) { + if (!can_write_to_file(conn, + smb_fname)) + { errno = EACCES; return -1; } @@ -1242,7 +1247,9 @@ int file_ntimes(connection_struct *conn, const struct smb_filename *smb_fname, */ /* Check if we have write access. */ - if (can_write_to_file(conn, smb_fname)) { + if (can_write_to_file(conn, + smb_fname)) + { /* We are allowed to become root and change the filetime. */ become_root(); ret = SMB_VFS_NTIMES(conn, smb_fname, ft); diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index a05b031c62d..1b9785d670a 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -131,7 +131,7 @@ bool can_delete_file_in_directory(connection_struct *conn, ****************************************************************************/ bool can_write_to_file(connection_struct *conn, - const struct smb_filename *smb_fname) + const struct smb_filename *smb_fname) { return NT_STATUS_IS_OK(smbd_check_access_rights(conn, smb_fname, diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index a99aa78bde8..c44501108ab 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -726,7 +726,9 @@ void reply_ntcreate_and_X(struct smb_request *req) p += 25; if (fsp->fsp_flags.is_directory || fsp->fsp_flags.can_write || - can_write_to_file(conn, smb_fname)) { + can_write_to_file(conn, + smb_fname)) + { perms = FILE_GENERIC_ALL; } else { perms = FILE_GENERIC_READ|FILE_EXECUTE; @@ -1388,7 +1390,9 @@ static void call_nt_transact_create(connection_struct *conn, p += 25; if (fsp->fsp_flags.is_directory || fsp->fsp_flags.can_write || - can_write_to_file(conn, smb_fname)) { + can_write_to_file(conn, + smb_fname)) + { perms = FILE_GENERIC_ALL; } else { perms = FILE_GENERIC_READ|FILE_EXECUTE; diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 6fbec943b0e..2e78b9c3bbb 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -2846,7 +2846,9 @@ static bool acl_group_override(connection_struct *conn, /* user has writeable permission */ if (lp_dos_filemode(SNUM(conn)) && - can_write_to_file(conn, smb_fname)) { + can_write_to_file(conn, + smb_fname)) + { return true; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index cdb7dcce41c..5303c477cf7 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -334,7 +334,7 @@ bool can_delete_file_in_directory(connection_struct *conn, struct files_struct *dirfsp, const struct smb_filename *smb_fname); bool can_write_to_file(connection_struct *conn, - const struct smb_filename *smb_fname); + const struct smb_filename *smb_fname); bool directory_has_default_acl(connection_struct *conn, struct files_struct *dirfsp, struct smb_filename *smb_fname); -- 2.47.3