[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Mon Sep 26 11:57:03 MDT 2011


The branch, master has been updated
       via  b93eae2 s3-samr: Remove fstring in samr.
       via  f741917 s3-passdb: Cleanup use of fstring and move to talloc.
       via  0ff0b37 s3-group-mapping: Remove unused functions.
      from  94b0f8f s3: Slightly simplify print_kdc_line()

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


- Log -----------------------------------------------------------------
commit b93eae206433450fbd45ce96bff2c0be5a055a70
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Sep 26 17:59:02 2011 +0200

    s3-samr: Remove fstring in samr.
    
    Autobuild-User: Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date: Mon Sep 26 19:56:04 CEST 2011 on sn-devel-104

commit f7419172f03089276cab71c41419a5c57508d42e
Author: Simo Sorce <idra at samba.org>
Date:   Mon Sep 26 11:30:05 2011 -0400

    s3-passdb: Cleanup use of fstring and move to talloc.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>

commit 0ff0b37f43d6a3ad52b1c954bc8f921222424c0d
Author: Simo Sorce <idra at samba.org>
Date:   Mon Sep 26 11:26:52 2011 -0400

    s3-group-mapping: Remove unused functions.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 source3/groupdb/mapping.c             |   44 ++++-----------------
 source3/groupdb/proto.h               |    2 -
 source3/include/passdb.h              |    4 +-
 source3/passdb/py_passdb.c            |   19 +++++++--
 source3/rpc_server/samr/srv_samr_nt.c |   67 ++++++++++++++++++++++++---------
 5 files changed, 73 insertions(+), 63 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 70c96f1..e9a6c3b 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -549,8 +549,14 @@ NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods,
 		return NT_STATUS_NO_SUCH_ALIAS;
 	}
 
-	fstrcpy(info->acct_name, map.nt_name);
-	fstrcpy(info->acct_desc, map.comment);
+	info->acct_name = talloc_strdup(info, map.nt_name);
+	if (!info->acct_name) {
+		return NT_STATUS_NO_MEMORY;
+	}
+	info->acct_desc = talloc_strdup(info, map.comment);
+	if (!info->acct_desc) {
+		return NT_STATUS_NO_MEMORY;
+	}
 	sid_peek_rid(&map.sid, &info->rid);
 	return NT_STATUS_OK;
 }
@@ -699,40 +705,6 @@ NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
 	return NT_STATUS_UNSUCCESSFUL;
 }
 
-/****************************************************************************
- These need to be redirected through pdb_interface.c
-****************************************************************************/
-bool pdb_get_dom_grp_info(const struct dom_sid *sid, struct acct_info *info)
-{
-	GROUP_MAP map;
-	bool res;
-
-	become_root();
-	res = get_domain_group_from_sid(*sid, &map);
-	unbecome_root();
-
-	if (!res)
-		return False;
-
-	fstrcpy(info->acct_name, map.nt_name);
-	fstrcpy(info->acct_desc, map.comment);
-	sid_peek_rid(sid, &info->rid);
-	return True;
-}
-
-bool pdb_set_dom_grp_info(const struct dom_sid *sid, const struct acct_info *info)
-{
-	GROUP_MAP map;
-
-	if (!get_domain_group_from_sid(*sid, &map))
-		return False;
-
-	fstrcpy(map.nt_name, info->acct_name);
-	fstrcpy(map.comment, info->acct_desc);
-
-	return NT_STATUS_IS_OK(pdb_update_group_mapping_entry(&map));
-}
-
 /********************************************************************
  Really just intended to be called by smbd
 ********************************************************************/
diff --git a/source3/groupdb/proto.h b/source3/groupdb/proto.h
index db07d4d..f30584c 100644
--- a/source3/groupdb/proto.h
+++ b/source3/groupdb/proto.h
@@ -91,8 +91,6 @@ NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
 					   enum lsa_SidType sid_name_use,
 					   GROUP_MAP **rmap, size_t *num_entries,
 					   bool unix_only);
-bool pdb_get_dom_grp_info(const struct dom_sid *sid, struct acct_info *info);
-bool pdb_set_dom_grp_info(const struct dom_sid *sid, const struct acct_info *info);
 NTSTATUS pdb_create_builtin_alias(uint32 rid);
 
 /* The following definitions come from groupdb/mapping_tdb.c  */
diff --git a/source3/include/passdb.h b/source3/include/passdb.h
index 1d0f2f3..ea53279 100644
--- a/source3/include/passdb.h
+++ b/source3/include/passdb.h
@@ -218,8 +218,8 @@ struct samu {
 };
 
 struct acct_info {
-	fstring acct_name; /* account name */
-	fstring acct_desc; /* account name */
+	char *acct_name; /* account name */
+	char *acct_desc; /* account name */
 	uint32_t rid; /* domain-relative RID */
 };
 
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
index f02230f..48b1513 100644
--- a/source3/passdb/py_passdb.c
+++ b/source3/passdb/py_passdb.c
@@ -2062,7 +2062,7 @@ static PyObject *py_pdb_get_aliasinfo(pytalloc_Object *self, PyObject *args)
 	TALLOC_CTX *tframe;
 	PyObject *py_alias_sid;
 	struct dom_sid *alias_sid;
-	struct acct_info alias_info;
+	struct acct_info *alias_info;
 	PyObject *py_alias_info;
 
 	if (!PyArg_ParseTuple(args, "O!:get_aliasinfo", dom_sid_Type, &py_alias_sid)) {
@@ -2078,7 +2078,13 @@ static PyObject *py_pdb_get_aliasinfo(pytalloc_Object *self, PyObject *args)
 
 	alias_sid = pytalloc_get_ptr(py_alias_sid);
 
-	status = methods->get_aliasinfo(methods, alias_sid, &alias_info);
+	alias_info = talloc_zero(tframe, struct acct_info);
+	if (!alias_info) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	status = methods->get_aliasinfo(methods, alias_sid, alias_info);
 	if (!NT_STATUS_IS_OK(status)) {
 		PyErr_Format(py_pdb_error, "Unable to get alias information, (%d,%s)",
 				NT_STATUS_V(status),
@@ -2094,9 +2100,12 @@ static PyObject *py_pdb_get_aliasinfo(pytalloc_Object *self, PyObject *args)
 		return NULL;
 	}
 
-	PyDict_SetItemString(py_alias_info, "acct_name", PyString_FromString(alias_info.acct_name));
-	PyDict_SetItemString(py_alias_info, "acct_desc", PyString_FromString(alias_info.acct_desc));
-	PyDict_SetItemString(py_alias_info, "rid", PyInt_FromLong(alias_info.rid));
+	PyDict_SetItemString(py_alias_info, "acct_name",
+			     PyString_FromString(alias_info->acct_name));
+	PyDict_SetItemString(py_alias_info, "acct_desc",
+			     PyString_FromString(alias_info->acct_desc));
+	PyDict_SetItemString(py_alias_info, "rid",
+			     PyInt_FromLong(alias_info->rid));
 
 	talloc_free(tframe);
 
diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c
index 016d426..567265d 100644
--- a/source3/rpc_server/samr/srv_samr_nt.c
+++ b/source3/rpc_server/samr/srv_samr_nt.c
@@ -1564,7 +1564,7 @@ NTSTATUS _samr_QueryAliasInfo(struct pipes_struct *p,
 			      struct samr_QueryAliasInfo *r)
 {
 	struct samr_alias_info *ainfo;
-	struct acct_info info;
+	struct acct_info *info;
 	NTSTATUS status;
 	union samr_AliasInfo *alias_info = NULL;
 	const char *alias_name = NULL;
@@ -1584,16 +1584,23 @@ NTSTATUS _samr_QueryAliasInfo(struct pipes_struct *p,
 		return NT_STATUS_NO_MEMORY;
 	}
 
+	info = talloc_zero(p->mem_ctx, struct acct_info);
+	if (!info) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
 	become_root();
-	status = pdb_get_aliasinfo(&ainfo->sid, &info);
+	status = pdb_get_aliasinfo(&ainfo->sid, info);
 	unbecome_root();
 
-	if ( !NT_STATUS_IS_OK(status))
+	if (!NT_STATUS_IS_OK(status)) {
+		TALLOC_FREE(info);
 		return status;
+	}
 
-	/* FIXME: info contains fstrings */
-	alias_name = talloc_strdup(r, info.acct_name);
-	alias_description = talloc_strdup(r, info.acct_desc);
+	alias_name = talloc_steal(r, info->acct_name);
+	alias_description = talloc_steal(r, info->acct_desc);
+	TALLOC_FREE(info);
 
 	switch (r->in.level) {
 	case ALIASINFOALL:
@@ -1827,14 +1834,16 @@ NTSTATUS _samr_ChangePasswordUser2(struct pipes_struct *p,
 	NTSTATUS status;
 	char *user_name = NULL;
 	char *rhost;
-	fstring wks;
+	const char *wks = NULL;
 
 	DEBUG(5,("_samr_ChangePasswordUser2: %d\n", __LINE__));
 
 	if (!r->in.account->string) {
 		return NT_STATUS_INVALID_PARAMETER;
 	}
-	fstrcpy(wks, r->in.server->string);
+	if (r->in.server && r->in.server->string) {
+		wks = r->in.server->string;
+	}
 
 	DEBUG(5,("_samr_ChangePasswordUser2: user: %s wks: %s\n", user_name, wks));
 
@@ -6112,7 +6121,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
 			    struct samr_SetAliasInfo *r)
 {
 	struct samr_alias_info *ainfo;
-	struct acct_info info;
+	struct acct_info *info;
 	NTSTATUS status;
 
 	ainfo = policy_handle_find(p, r->in.alias_handle,
@@ -6122,10 +6131,15 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
 		return status;
 	}
 
+	info = talloc_zero(p->mem_ctx, struct acct_info);
+	if (!info) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
 	/* get the current group information */
 
 	become_root();
-	status = pdb_get_aliasinfo( &ainfo->sid, &info );
+	status = pdb_get_aliasinfo(&ainfo->sid, info);
 	unbecome_root();
 
 	if ( !NT_STATUS_IS_OK(status))
@@ -6134,7 +6148,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
 	switch (r->in.level) {
 		case ALIASINFONAME:
 		{
-			fstring group_name;
+			char *group_name;
 
 			/* We currently do not support renaming groups in the
 			   the BUILTIN domain.  Refer to util_builtin.c to understand
@@ -6153,26 +6167,43 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
 			/* If the name is the same just reply "ok".  Yes this
 			   doesn't allow you to change the case of a group name. */
 
-			if ( strequal( r->in.info->name.string, info.acct_name ) )
+			if (strequal(r->in.info->name.string, info->acct_name)) {
 				return NT_STATUS_OK;
+			}
 
-			fstrcpy( info.acct_name, r->in.info->name.string);
+			talloc_free(info->acct_name);
+			info->acct_name = talloc_strdup(info, r->in.info->name.string);
+			if (!info->acct_name) {
+				return NT_STATUS_NO_MEMORY;
+			}
 
 			/* make sure the name doesn't already exist as a user
 			   or local group */
 
-			fstr_sprintf( group_name, "%s\\%s", lp_netbios_name(), info.acct_name );
+			group_name = talloc_asprintf(p->mem_ctx,
+						     "%s\\%s",
+						     lp_netbios_name(),
+						     info->acct_name);
+			if (group_name == NULL) {
+				return NT_STATUS_NO_MEMORY;
+			}
+
 			status = can_create( p->mem_ctx, group_name );
+			talloc_free(group_name);
 			if ( !NT_STATUS_IS_OK( status ) )
 				return status;
 			break;
 		}
 		case ALIASINFODESCRIPTION:
+			TALLOC_FREE(info->acct_desc);
 			if (r->in.info->description.string) {
-				fstrcpy(info.acct_desc,
-					r->in.info->description.string);
+				info->acct_desc = talloc_strdup(info,
+								r->in.info->description.string);
 			} else {
-				fstrcpy( info.acct_desc, "" );
+				info->acct_desc = talloc_strdup(info, "");
+			}
+			if (!info->acct_desc) {
+				return NT_STATUS_NO_MEMORY;
 			}
 			break;
 		default:
@@ -6182,7 +6213,7 @@ NTSTATUS _samr_SetAliasInfo(struct pipes_struct *p,
         /******** BEGIN SeAddUsers BLOCK *********/
 
 	become_root();
-        status = pdb_set_aliasinfo( &ainfo->sid, &info );
+        status = pdb_set_aliasinfo(&ainfo->sid, info);
 	unbecome_root();
 
         /******** End SeAddUsers BLOCK *********/


-- 
Samba Shared Repository


More information about the samba-cvs mailing list