diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/groupdb/mapping.c | 10 | ||||
-rw-r--r-- | source3/include/passdb.h | 4 | ||||
-rw-r--r-- | source3/passdb/py_passdb.c | 19 | ||||
-rw-r--r-- | source3/rpc_server/samr/srv_samr_nt.c | 52 |
4 files changed, 61 insertions, 24 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c index 638c06a8f1..e9a6c3b729 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; } diff --git a/source3/include/passdb.h b/source3/include/passdb.h index 1d0f2f36be..ea53279d42 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 f02230fd01..48b151387a 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 016d426bfe..9cd08873dd 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: @@ -6112,7 +6119,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 +6129,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)) @@ -6153,26 +6165,36 @@ 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 ); + fstr_sprintf(group_name, "%s\\%s", + lp_netbios_name(), info->acct_name); status = can_create( p->mem_ctx, 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 +6204,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 *********/ |