[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Tue Aug 7 01:00:03 MDT 2012


The branch, master has been updated
       via  f06c216 s3-pysmbd: Try opening as a file, then as a directory
       via  e571d5c s3-pysmbd: Use talloc_zero()
       via  e658421 s3-passdb: Simplify idmap wrapper in pdb_samba4
       via  227d490 s3-pysmbd: Add talloc_stackframe() to smbd_set_simple_acl wrapper
      from  721096b s3:smb2_server: make use of smbd_smb2_inbuf_parse_compound() in smbd_smb2_request_read*()

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f06c216d0b3ffd036ac10f9abe9b2fe3ff319f09
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 7 14:19:06 2012 +1000

    s3-pysmbd: Try opening as a file, then as a directory
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Aug  7 08:59:21 CEST 2012 on sn-devel-104

commit e571d5c03ef416bc7f6a1eb66567ec2715da9d21
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 7 14:18:41 2012 +1000

    s3-pysmbd: Use talloc_zero()
    
    This avoids operating on uninitialised data
    
    Andrew Bartlett

commit e658421fe1f724da0e627c0ae407804993c2521e
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 7 14:17:09 2012 +1000

    s3-passdb: Simplify idmap wrapper in pdb_samba4
    
    The source3 consumers of this API are now quite happy to be given an answer
    of ID_TYPE_BOTH, so we do not need this extra code to try and force the
    answer to UID or GID.
    
    Andrew Bartlett

commit 227d490477230cfdd6b912b6f6a63314fa64ca88
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 7 10:45:14 2012 +1000

    s3-pysmbd: Add talloc_stackframe() to smbd_set_simple_acl wrapper

-----------------------------------------------------------------------

Summary of changes:
 source3/passdb/pdb_samba4.c |   59 ++++++------------------------------------
 source3/smbd/pysmbd.c       |   12 ++++++--
 2 files changed, 18 insertions(+), 53 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/passdb/pdb_samba4.c b/source3/passdb/pdb_samba4.c
index 40827df..01eb4ba 100644
--- a/source3/passdb/pdb_samba4.c
+++ b/source3/passdb/pdb_samba4.c
@@ -2058,67 +2058,26 @@ static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *si
 		m->private_data, struct pdb_samba4_state);
 	struct id_map id_map;
 	struct id_map *id_maps[2];
-	const char *attrs[] = { "objectClass", NULL };
-	struct ldb_message *msg;
-	struct ldb_dn *dn;
 	NTSTATUS status;
-	int rc;
 	TALLOC_CTX *tmp_ctx = talloc_stackframe();
 	if (!tmp_ctx) {
 		return false;
 	}
 
 	ZERO_STRUCT(id_map);
+	id_map.sid = sid;
+	id_maps[0] = &id_map;
+	id_maps[1] = NULL;
 
-	dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, sid));
-	if (!dn || !ldb_dn_validate(dn)) {
-		talloc_free(tmp_ctx);
+	status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
+	talloc_free(tmp_ctx);
+	if (!NT_STATUS_IS_OK(status)) {
 		return false;
 	}
-	rc = dsdb_search_one(state->ldb, tmp_ctx, &msg, dn, LDB_SCOPE_BASE, attrs, 0, NULL);
-	if (rc == LDB_ERR_NO_SUCH_OBJECT) {
-		DEBUG(5, (__location__ "SID to Unix ID lookup failed because SID %s could not be found in the samdb\n", dom_sid_string(tmp_ctx, sid)));
-		talloc_free(tmp_ctx);
-		return false;
+	if (id_map.xid.type != ID_TYPE_NOT_SPECIFIED) {
+		*id = id_map.xid;
+		return true;
 	}
-	if (samdb_find_attribute(state->ldb, msg, "objectClass", "group")) {
-		id->type = ID_TYPE_GID;
-
-		ZERO_STRUCT(id_map);
-		id_map.sid = sid;
-		id_maps[0] = &id_map;
-		id_maps[1] = NULL;
-		
-		status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
-		talloc_free(tmp_ctx);
-		if (!NT_STATUS_IS_OK(status)) {
-			return false;
-		}
-		if (id_map.xid.type == ID_TYPE_GID || id_map.xid.type == ID_TYPE_BOTH) {
-			id->id = id_map.xid.id;
-			return true;
-		}
-		return false;
-	} else if (samdb_find_attribute(state->ldb, msg, "objectClass", "user")) {
-		id->type = ID_TYPE_UID;
-		ZERO_STRUCT(id_map);
-		id_map.sid = sid;
-		id_maps[0] = &id_map;
-		id_maps[1] = NULL;
-		
-		status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
-		talloc_free(tmp_ctx);
-		if (!NT_STATUS_IS_OK(status)) {
-			return false;
-		}
-		if (id_map.xid.type == ID_TYPE_UID || id_map.xid.type == ID_TYPE_BOTH) {
-			id->id = id_map.xid.id;
-			return true;
-		}
-		return false;
-	}
-	DEBUG(5, (__location__ "SID to Unix ID lookup failed because SID %s was found, but was not a user or group\n", dom_sid_string(tmp_ctx, sid)));
-	talloc_free(tmp_ctx);
 	return false;
 }
 
diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c
index 9a44d25..6bef8af 100644
--- a/source3/smbd/pysmbd.c
+++ b/source3/smbd/pysmbd.c
@@ -101,7 +101,7 @@ static NTSTATUS set_nt_acl_no_snum(const char *fname,
 
 	smbd_vfs_init(conn);
 
-	fsp = talloc(frame, struct files_struct);
+	fsp = talloc_zero(frame, struct files_struct);
 	if (fsp == NULL) {
 		TALLOC_FREE(frame);
 		return NT_STATUS_NO_MEMORY;
@@ -129,9 +129,9 @@ static NTSTATUS set_nt_acl_no_snum(const char *fname,
 	flags = O_RDONLY;
 #endif
 
-	fsp->fh->fd = SMB_VFS_OPEN(conn, smb_fname, fsp, flags, 00400);
+	fsp->fh->fd = SMB_VFS_OPEN(conn, smb_fname, fsp, O_RDWR, 00400);
 	if (fsp->fh->fd == -1 && errno == EISDIR) {
-		fsp->fh->fd = SMB_VFS_OPEN(conn, smb_fname, fsp, O_RDWR, 00400);
+		fsp->fh->fd = SMB_VFS_OPEN(conn, smb_fname, fsp, flags, 00400);
 	}
 	if (fsp->fh->fd == -1) {
 		printf("open: error=%d (%s)\n", errno, strerror(errno));
@@ -254,14 +254,20 @@ static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args)
 	char *fname;
 	int uid, gid;
 	SMB_ACL_T acl;
+	TALLOC_CTX *frame;
 
 	if (!PyArg_ParseTuple(args, "sii", &fname, &uid, &gid))
 		return NULL;
 
 	acl = make_simple_acl(uid, gid);
 
+	frame = talloc_stackframe();
+
 	status = set_sys_acl_no_snum(fname, SMB_ACL_TYPE_ACCESS, acl);
 	sys_acl_free_acl(acl);
+
+	TALLOC_FREE(frame);
+
 	PyErr_NTSTATUS_IS_ERR_RAISE(status);
 
 	Py_RETURN_NONE;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list