[SCM] Samba Shared Repository - branch v3-6-test updated
Jeremy Allison
jra at samba.org
Thu Mar 31 11:09:19 MDT 2011
The branch, v3-6-test has been updated
via d989660 Fix bug #7996 - sgid bit lost on folder rename.
via 854c3f4 SMBTA: make vfs_smb_traffic_analyzer aware of the sendfile and recvfile functionality and store the results as common read/write results. (cherry picked from commit cf5ed92bb78806403a857b371ef15f985a4e2b64)
via 9330f33 Make ndr_push_charset robust in the face of zero destination length.
from 7187655 debug: ignore debug_set_logfile() with a blank string
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit d989660833f6362460fcc4c7cd535fb1649e4501
Author: Jeremy Allison <jra at samba.org>
Date: Thu Mar 31 09:57:42 2011 -0700
Fix bug #7996 - sgid bit lost on folder rename.
Refuse to set dos attributes into unix mode bits on such a
folder.
commit 854c3f46468f801bb098c555aabafa2dea4d1cf9
Author: Holger Hetterich <hhetter at novell.com>
Date: Tue Mar 29 22:16:10 2011 +0200
SMBTA: make vfs_smb_traffic_analyzer aware of the sendfile and recvfile functionality and store the results as common read/write results.
(cherry picked from commit cf5ed92bb78806403a857b371ef15f985a4e2b64)
commit 9330f3339d15b731d44b8f74fa9f59837ef91dbd
Author: Jeremy Allison <jra at samba.org>
Date: Wed Mar 30 12:58:33 2011 -0700
Make ndr_push_charset robust in the face of zero destination length.
-----------------------------------------------------------------------
Summary of changes:
librpc/ndr/ndr_string.c | 19 +++++++-----
source3/include/proto.h | 1 +
source3/modules/vfs_smb_traffic_analyzer.c | 42 +++++++++++++++++++++++++++-
source3/smbd/dosmode.c | 21 ++++++++++++++
source3/smbd/posix_acls.c | 2 +-
5 files changed, 75 insertions(+), 10 deletions(-)
Changeset truncated at 500 lines:
diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c
index 610676c..d750e2c 100644
--- a/librpc/ndr/ndr_string.c
+++ b/librpc/ndr/ndr_string.c
@@ -705,17 +705,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags,
required = byte_mul * length;
NDR_PUSH_NEED_BYTES(ndr, required);
- ret = convert_string(CH_UNIX, chset,
+
+ if (required) {
+ ret = convert_string(CH_UNIX, chset,
var, strlen(var),
ndr->data+ndr->offset, required, false);
- if (ret == -1) {
- return ndr_push_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
- }
+ if (ret == -1) {
+ return ndr_push_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
- /* Make sure the remaining part of the string is filled with zeroes */
- if (ret < required) {
- memset(ndr->data+ndr->offset+ret, 0, required-ret);
+ /* Make sure the remaining part of the string is filled with zeroes */
+ if (ret < required) {
+ memset(ndr->data+ndr->offset+ret, 0, required-ret);
+ }
}
ndr->offset += required;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index aa0287c..9d82b13 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4677,6 +4677,7 @@ uint32_t map_canon_ace_perms(int snum,
mode_t perms,
bool directory_ace);
NTSTATUS unpack_nt_owners(connection_struct *conn, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, const struct security_descriptor *psd);
+bool current_user_in_group(connection_struct *conn, gid_t gid);
SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl);
NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
struct security_descriptor **ppdesc);
diff --git a/source3/modules/vfs_smb_traffic_analyzer.c b/source3/modules/vfs_smb_traffic_analyzer.c
index 1e1732d..613b3e1 100644
--- a/source3/modules/vfs_smb_traffic_analyzer.c
+++ b/source3/modules/vfs_smb_traffic_analyzer.c
@@ -746,6 +746,44 @@ static int smb_traffic_analyzer_mkdir(vfs_handle_struct *handle, \
return s_data.result;
}
+static ssize_t smb_traffic_analyzer_sendfile(vfs_handle_struct *handle,
+ int tofd,
+ files_struct *fromfsp,
+ const DATA_BLOB *hdr,
+ SMB_OFF_T offset,
+ size_t n)
+{
+ struct rw_data s_data;
+ s_data.len = SMB_VFS_NEXT_SENDFILE(handle,
+ tofd, fromfsp, hdr, offset, n);
+ s_data.filename = fromfsp->fsp_name->base_name;
+ DEBUG(10, ("smb_traffic_analyzer_sendfile: sendfile(r): %s\n",
+ fsp_str_dbg(fromfsp)));
+ smb_traffic_analyzer_send_data(handle,
+ &s_data,
+ vfs_id_read);
+ return s_data.len;
+}
+
+static ssize_t smb_traffic_analyzer_recvfile(vfs_handle_struct *handle,
+ int fromfd,
+ files_struct *tofsp,
+ SMB_OFF_T offset,
+ size_t n)
+{
+ struct rw_data s_data;
+ s_data.len = SMB_VFS_NEXT_RECVFILE(handle,
+ fromfd, tofsp, offset, n);
+ s_data.filename = tofsp->fsp_name->base_name;
+ DEBUG(10, ("smb_traffic_analyzer_recvfile: recvfile(w): %s\n",
+ fsp_str_dbg(tofsp)));
+ smb_traffic_analyzer_send_data(handle,
+ &s_data,
+ vfs_id_write);
+ return s_data.len;
+}
+
+
static ssize_t smb_traffic_analyzer_read(vfs_handle_struct *handle, \
files_struct *fsp, void *data, size_t n)
{
@@ -855,7 +893,9 @@ static struct vfs_fn_pointers vfs_smb_traffic_analyzer_fns = {
.chdir = smb_traffic_analyzer_chdir,
.open = smb_traffic_analyzer_open,
.rmdir = smb_traffic_analyzer_rmdir,
- .close_fn = smb_traffic_analyzer_close
+ .close_fn = smb_traffic_analyzer_close,
+ .sendfile = smb_traffic_analyzer_sendfile,
+ .recvfile = smb_traffic_analyzer_recvfile
};
/* Module initialization */
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 325a3c6..d8c12ee 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -796,6 +796,27 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
unixmode |= (smb_fname->st.st_ex_mode & (S_IWUSR|S_IWGRP|S_IWOTH));
}
+ /*
+ * From the chmod 2 man page:
+ *
+ * "If the calling process is not privileged, and the group of the file
+ * does not match the effective group ID of the process or one of its
+ * supplementary group IDs, the S_ISGID bit will be turned off, but
+ * this will not cause an error to be returned."
+ *
+ * Simply refuse to do the chmod in this case.
+ */
+
+ if (S_ISDIR(smb_fname->st.st_ex_mode) && (unixmode & S_ISGID) &&
+ geteuid() != sec_initial_uid() &&
+ !current_user_in_group(conn, smb_fname->st.st_ex_gid)) {
+ DEBUG(3,("file_set_dosmode: setgid bit cannot be "
+ "set for directory %s\n",
+ smb_fname_str_dbg(smb_fname)));
+ errno = EPERM;
+ return -1;
+ }
+
ret = SMB_VFS_CHMOD(conn, smb_fname->base_name, unixmode);
if (ret == 0) {
if(!newfile || (lret != -1)) {
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index ebdc644..e41ee3c 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -2651,7 +2651,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
Check if the current user group list contains a given group.
****************************************************************************/
-static bool current_user_in_group(connection_struct *conn, gid_t gid)
+bool current_user_in_group(connection_struct *conn, gid_t gid)
{
int i;
const struct security_unix_token *utok = get_current_utok(conn);
--
Samba Shared Repository
More information about the samba-cvs
mailing list