From: Ralph Boehme Date: Thu, 12 Oct 2017 13:41:01 +0000 (+0200) Subject: s3/smbd: README.Coding fixes in set_ea_dos_attribute X-Git-Tag: samba-4.6.9~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88dfaf1e4be5ac66bf3fd82f953d3fd79a0a309f;p=thirdparty%2Fsamba.git s3/smbd: README.Coding fixes in set_ea_dos_attribute While I'm at it, some README.Coding fixes in set_ea_dos_attribute. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12995 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit fbad64200e0199acb644d83073234b2f6c200fce) --- diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index df755427187..fdbc7517985 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -415,6 +415,7 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn, struct xattr_DOSATTRIB dosattrib; enum ndr_err_code ndr_err; DATA_BLOB blob; + int ret; if (!lp_store_dos_attributes(SNUM(conn))) { return NT_STATUS_NOT_IMPLEMENTED; @@ -456,14 +457,15 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn, return NT_STATUS_INVALID_PARAMETER; } - if (SMB_VFS_SETXATTR(conn, smb_fname->base_name, + ret = SMB_VFS_SETXATTR(conn, smb_fname->base_name, SAMBA_XATTR_DOS_ATTRIB, blob.data, blob.length, - 0) == -1) { + 0); + if (ret != 0) { NTSTATUS status = NT_STATUS_OK; bool need_close = false; files_struct *fsp = NULL; - if((errno != EPERM) && (errno != EACCES)) { + if ((errno != EPERM) && (errno != EACCES)) { DBG_INFO("Cannot set " "attribute EA on file %s: Error = %s\n", smb_fname_str_dbg(smb_fname), strerror(errno)); @@ -475,7 +477,7 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn, */ /* Check if we have write access. */ - if(!CAN_WRITE(conn) || !lp_dos_filemode(SNUM(conn))) + if (!CAN_WRITE(conn) || !lp_dos_filemode(SNUM(conn))) return NT_STATUS_ACCESS_DENIED; if (!can_write_to_file(conn, smb_fname)) { @@ -496,9 +498,10 @@ NTSTATUS set_ea_dos_attribute(connection_struct *conn, } become_root(); - if (SMB_VFS_FSETXATTR(fsp, - SAMBA_XATTR_DOS_ATTRIB, blob.data, - blob.length, 0) == 0) { + ret = SMB_VFS_FSETXATTR(fsp, + SAMBA_XATTR_DOS_ATTRIB, + blob.data, blob.length, 0); + if (ret == 0) { status = NT_STATUS_OK; } unbecome_root();