[SCM] Samba Shared Repository - branch master updated
Matthias Dieter Wallnöfer
mdw at samba.org
Sat Mar 6 04:35:41 MST 2010
The branch, master has been updated
via e10fa46... LDB:tools - change counters to be unsigned
via 24049e8... s4:lsa RPC - fix up "gendb_*" result codes
via a6cf892... s4:lsa RPC - Change some counters to be "unsigned" where needed
via 9442a55... s4:samr RPC - Change some counters to be "unsigned" where needed
from c61c9c3... Fix for bug #7189 - Open txt files with notepad on samba shares creates problem.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit e10fa46f3e5b3481e3c95e52f9d666eafd50ed25
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Nov 6 18:35:17 2009 +0100
LDB:tools - change counters to be unsigned
In most cases we do count LDB objects which are enumerated within the "unsigned"
type. Therefore no need to use "signed" counters.
commit 24049e8fc58c5216b3af8fdaf327471eaff882a1
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sat Mar 6 11:19:04 2010 +0100
s4:lsa RPC - fix up "gendb_*" result codes
Make the resultcodes consistent: that means:
result < 0 -> NT_STATUS_INTERNAL_DB_CORRUPTION since our DB had a critical
error
result >= 0 -> depends on the function usage. I tried to let the logic always as
it was before.
commit a6cf89228f2daf5a95284ec57b9c38326e5574dc
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sat Nov 21 19:26:02 2009 +0100
s4:lsa RPC - Change some counters to be "unsigned" where needed
The "count" size specifiers I typed "uint32_t" since they're often returned as
an "uint32_t" (consider the IDL file). LDB counters need to be "signed" if they
count till a limit of a "gendb*" call or "unsigned" if they count directly the
number of objects.
commit 9442a5593d6de13e14e5df3b62e9fa295f42b3bd
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sat Nov 21 19:26:02 2009 +0100
s4:samr RPC - Change some counters to be "unsigned" where needed
The "count" size specifiers I typed "uint32_t" since they're often returned as
an "uint32_t" (consider the IDL file). LDB counters need to be "signed" if they
count till a limit of a "gendb*" call or "unsigned" if they count directly the
number of objects.
-----------------------------------------------------------------------
Summary of changes:
source4/lib/ldb/tools/cmdline.c | 4 +-
source4/lib/ldb/tools/ldbadd.c | 7 ++--
source4/lib/ldb/tools/ldbdel.c | 3 +-
source4/lib/ldb/tools/ldbedit.c | 20 +++++-----
source4/lib/ldb/tools/ldbsearch.c | 12 +++---
source4/lib/ldb/tools/ldbtest.c | 24 +++++++-----
source4/rpc_server/lsa/dcesrv_lsa.c | 49 +++++++++++++------------
source4/rpc_server/lsa/lsa_lookup.c | 63 +++++++++++++++++----------------
source4/rpc_server/samr/dcesrv_samr.c | 23 +++++++-----
9 files changed, 110 insertions(+), 95 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index f2becb1..869d5ca 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -347,8 +347,8 @@ failed:
*/
int handle_controls_reply(struct ldb_control **reply, struct ldb_control **request)
{
- int i, j;
- int ret = 0;
+ unsigned int i, j;
+ int ret = 0;
if (reply == NULL || request == NULL) return -1;
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index e618ab5..0dd35cc 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -35,7 +35,7 @@
#include "tools/cmdline.h"
#include "ldbutil.h"
-static int failures;
+static unsigned int failures;
static struct ldb_cmdline *options;
static void usage(void)
@@ -50,7 +50,7 @@ static void usage(void)
/*
add records from an opened file
*/
-static int process_file(struct ldb_context *ldb, FILE *f, int *count)
+static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
{
struct ldb_ldif *ldif;
int ret = LDB_SUCCESS;
@@ -93,7 +93,8 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count)
int main(int argc, const char **argv)
{
struct ldb_context *ldb;
- int i, ret=0, count=0;
+ unsigned int i, count = 0;
+ int ret=0;
ldb = ldb_init(NULL, NULL);
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index 1b8adf7..04884e1 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -43,7 +43,8 @@ static int dn_cmp(struct ldb_message **msg1, struct ldb_message **msg2)
static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struct ldb_control **req_ctrls)
{
- int ret, i, total=0;
+ int ret;
+ unsigned int i, total=0;
const char *attrs[] = { NULL };
struct ldb_result *res;
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index ecadf0f..4c5683c 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -88,10 +88,10 @@ static int modify_record(struct ldb_context *ldb,
*/
static struct ldb_message *msg_find(struct ldb_context *ldb,
struct ldb_message **msgs,
- int count,
+ unsigned int count,
struct ldb_dn *dn)
{
- int i;
+ unsigned int i;
for (i=0;i<count;i++) {
if (ldb_dn_compare(dn, msgs[i]->dn) == 0) {
return msgs[i];
@@ -104,10 +104,10 @@ static struct ldb_message *msg_find(struct ldb_context *ldb,
merge the changes in msgs2 into the messages from msgs1
*/
static int merge_edits(struct ldb_context *ldb,
- struct ldb_message **msgs1, int count1,
- struct ldb_message **msgs2, int count2)
+ struct ldb_message **msgs1, unsigned int count1,
+ struct ldb_message **msgs2, unsigned int count2)
{
- int i;
+ unsigned int i;
struct ldb_message *msg;
int ret = 0;
int adds=0, modifies=0, deletes=0;
@@ -171,9 +171,9 @@ static int merge_edits(struct ldb_context *ldb,
save a set of messages as ldif to a file
*/
static int save_ldif(struct ldb_context *ldb,
- FILE *f, struct ldb_message **msgs, int count)
+ FILE *f, struct ldb_message **msgs, unsigned int count)
{
- int i;
+ unsigned int i;
fprintf(f, "# editing %d records\n", count);
@@ -194,8 +194,8 @@ static int save_ldif(struct ldb_context *ldb,
/*
edit the ldb search results in msgs using the user selected editor
*/
-static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1, int count1,
- const char *editor)
+static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1,
+ unsigned int count1, const char *editor)
{
int fd, ret;
FILE *f;
@@ -203,7 +203,7 @@ static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1, int coun
char *cmd;
struct ldb_ldif *ldif;
struct ldb_message **msgs2 = NULL;
- int count2 = 0;
+ unsigned int count2 = 0;
/* write out the original set of messages to a temporary
file */
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index af0c12a..327a75e 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -54,15 +54,15 @@ struct search_context {
struct ldb_control **req_ctrls;
int sort;
- int num_stored;
+ unsigned int num_stored;
struct ldb_message **store;
- int refs_stored;
+ unsigned int refs_stored;
char **refs_store;
- int entries;
- int refs;
+ unsigned int entries;
+ unsigned int refs;
- int pending;
+ unsigned int pending;
int status;
};
@@ -240,7 +240,7 @@ again:
goto again;
if (sctx->sort && (sctx->num_stored != 0 || sctx->refs != 0)) {
- int i;
+ unsigned int i;
if (sctx->num_stored) {
LDB_TYPESAFE_QSORT(sctx->store, sctx->num_stored, ldb, do_compare_msg);
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index adc6ec8..1c877c7 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -52,10 +52,10 @@ static double _end_timer(void)
static void add_records(struct ldb_context *ldb,
struct ldb_dn *basedn,
- int count)
+ unsigned int count)
{
struct ldb_message msg;
- int i;
+ unsigned int i;
#if 0
if (ldb_lock(ldb, "transaction") != 0) {
@@ -141,10 +141,10 @@ static void add_records(struct ldb_context *ldb,
static void modify_records(struct ldb_context *ldb,
struct ldb_dn *basedn,
- int count)
+ unsigned int count)
{
struct ldb_message msg;
- int i;
+ unsigned int i;
for (i=0;i<count;i++) {
struct ldb_message_element el[3];
@@ -194,9 +194,9 @@ static void modify_records(struct ldb_context *ldb,
static void delete_records(struct ldb_context *ldb,
struct ldb_dn *basedn,
- int count)
+ unsigned int count)
{
- int i;
+ unsigned int i;
for (i=0;i<count;i++) {
struct ldb_dn *dn;
@@ -217,9 +217,10 @@ static void delete_records(struct ldb_context *ldb,
printf("\n");
}
-static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn, int nrecords, int nsearches)
+static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn,
+ unsigned int nrecords, unsigned int nsearches)
{
- int i;
+ unsigned int i;
for (i=0;i<nsearches;i++) {
int uid = (i * 700 + 17) % (nrecords * 2);
@@ -250,7 +251,8 @@ static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn, int nreco
printf("\n");
}
-static void start_test(struct ldb_context *ldb, int nrecords, int nsearches)
+static void start_test(struct ldb_context *ldb, unsigned int nrecords,
+ unsigned int nsearches)
{
struct ldb_dn *basedn;
@@ -411,7 +413,9 @@ int main(int argc, const char **argv)
printf("Testing with num-records=%d and num-searches=%d\n",
options->num_records, options->num_searches);
- start_test(ldb, options->num_records, options->num_searches);
+ start_test(ldb,
+ (unsigned int) options->num_records,
+ (unsigned int) options->num_searches);
start_test_index(&ldb);
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index 6a5a907..7c92a15 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -286,7 +286,7 @@ static NTSTATUS dcesrv_lsa_EnumPrivs(struct dcesrv_call_state *dce_call, TALLOC_
{
struct dcesrv_handle *h;
struct lsa_policy_state *state;
- int i;
+ uint32_t i;
const char *privname;
DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
@@ -682,10 +682,10 @@ static NTSTATUS dcesrv_lsa_EnumAccounts(struct dcesrv_call_state *dce_call, TALL
{
struct dcesrv_handle *h;
struct lsa_policy_state *state;
- int ret, i;
+ int ret;
struct ldb_message **res;
const char * const attrs[] = { "objectSid", NULL};
- uint32_t count;
+ uint32_t count, i;
DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
@@ -697,7 +697,7 @@ static NTSTATUS dcesrv_lsa_EnumAccounts(struct dcesrv_call_state *dce_call, TALL
ret = gendb_search(state->pdb, mem_ctx, NULL, &res, attrs,
"(&(objectSid=*)(privilege=*))");
if (ret < 0) {
- return NT_STATUS_NO_SUCH_USER;
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
if (*r->in.resume_handle >= ret) {
@@ -823,7 +823,7 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc
}
if (auth_struct.incoming.count) {
- int i;
+ uint32_t i;
struct trustAuthInOutBlob incoming;
incoming.count = auth_struct.incoming.count;
@@ -862,7 +862,7 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc
}
if (auth_struct.outgoing.count) {
- int i;
+ uint32_t i;
struct trustAuthInOutBlob outgoing;
outgoing.count = auth_struct.outgoing.count;
@@ -1046,7 +1046,7 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc
}
if (auth_struct.incoming.count) {
- int i;
+ uint32_t i;
for (i=0; i < auth_struct.incoming.count; i++ ) {
if (auth_struct.incoming.current[i]->AuthType == TRUST_AUTH_TYPE_NT4OWF) {
samdb_msg_add_hash(sam_ldb,
@@ -1626,7 +1626,7 @@ static NTSTATUS dcesrv_lsa_EnumTrustDom(struct dcesrv_call_state *dce_call, TALL
resumed based on resume_key */
count = gendb_search(policy_state->sam_ldb, mem_ctx, policy_state->system_dn, &domains, attrs,
"objectclass=trustedDomain");
- if (count == -1) {
+ if (count < 0) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -1719,7 +1719,7 @@ static NTSTATUS dcesrv_lsa_EnumTrustedDomainsEx(struct dcesrv_call_state *dce_ca
resumed based on resume_key */
count = gendb_search(policy_state->sam_ldb, mem_ctx, policy_state->system_dn, &domains, attrs,
"objectclass=trustedDomain");
- if (count == -1) {
+ if (count < 0) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -1815,7 +1815,8 @@ static NTSTATUS dcesrv_lsa_EnumPrivsAccount(struct dcesrv_call_state *dce_call,
{
struct dcesrv_handle *h;
struct lsa_account_state *astate;
- int ret, i;
+ int ret;
+ unsigned int i;
struct ldb_message **res;
const char * const attrs[] = { "privilege", NULL};
struct ldb_message_element *el;
@@ -1843,6 +1844,9 @@ static NTSTATUS dcesrv_lsa_EnumPrivsAccount(struct dcesrv_call_state *dce_call,
ret = gendb_search(astate->policy->pdb, mem_ctx, NULL, &res, attrs,
"objectSid=%s", sidstr);
+ if (ret < 0) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
if (ret != 1) {
return NT_STATUS_OK;
}
@@ -1882,7 +1886,8 @@ static NTSTATUS dcesrv_lsa_EnumAccountRights(struct dcesrv_call_state *dce_call,
{
struct dcesrv_handle *h;
struct lsa_policy_state *state;
- int ret, i;
+ int ret;
+ unsigned int i;
struct ldb_message **res;
const char * const attrs[] = { "privilege", NULL};
const char *sidstr;
@@ -1902,10 +1907,7 @@ static NTSTATUS dcesrv_lsa_EnumAccountRights(struct dcesrv_call_state *dce_call,
if (ret == 0) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- if (ret > 1) {
- return NT_STATUS_INTERNAL_DB_CORRUPTION;
- }
- if (ret == -1) {
+ if (ret != 1) {
DEBUG(3, ("searching for account rights for SID: %s failed: %s",
dom_sid_string(mem_ctx, r->in.sid),
ldb_errstring(state->pdb)));
@@ -1946,7 +1948,8 @@ static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_
const char *sidstr, *sidndrstr;
struct ldb_message *msg;
struct ldb_message_element *el;
- int i, ret;
+ int ret;
+ uint32_t i;
struct lsa_EnumAccountRights r2;
char *dnstr;
@@ -1993,7 +1996,7 @@ static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_
}
if (ldb_flag == LDB_FLAG_MOD_ADD) {
- int j;
+ uint32_t j;
for (j=0;j<r2.out.rights->count;j++) {
if (strcasecmp_m(r2.out.rights->names[j].string,
rights->names[i].string) == 0) {
@@ -2052,7 +2055,7 @@ static NTSTATUS dcesrv_lsa_AddPrivilegesToAccount(struct dcesrv_call_state *dce_
struct lsa_RightSet rights;
struct dcesrv_handle *h;
struct lsa_account_state *astate;
- int i;
+ uint32_t i;
DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_ACCOUNT);
@@ -2089,7 +2092,7 @@ static NTSTATUS dcesrv_lsa_RemovePrivilegesFromAccount(struct dcesrv_call_state
struct lsa_RightSet *rights;
struct dcesrv_handle *h;
struct lsa_account_state *astate;
- int i;
+ uint32_t i;
DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_ACCOUNT);
@@ -2168,7 +2171,7 @@ static NTSTATUS dcesrv_lsa_SetQuotasForAccount(struct dcesrv_call_state *dce_cal
static NTSTATUS dcesrv_lsa_GetSystemAccessAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct lsa_GetSystemAccessAccount *r)
{
- int i;
+ uint32_t i;
NTSTATUS status;
struct lsa_EnumPrivsAccount enumPrivs;
struct lsa_PrivilegeSet *privs;
@@ -2292,7 +2295,7 @@ static NTSTATUS dcesrv_lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALL
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- if (ret == -1) {
+ if (ret < 0) {
DEBUG(0,("Failure searching for CN=%s: %s\n",
name2, ldb_errstring(secret_state->sam_ldb)));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -2325,7 +2328,7 @@ static NTSTATUS dcesrv_lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALL
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- if (ret == -1) {
+ if (ret < 0) {
DEBUG(0,("Failure searching for CN=%s: %s\n",
name, ldb_errstring(secret_state->sam_ldb)));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -2904,7 +2907,7 @@ static NTSTATUS dcesrv_lsa_EnumAccountsWithUserRight(struct dcesrv_call_state *d
ret = gendb_search(state->pdb, mem_ctx, NULL, &res, attrs,
"privilege=%s", privname);
- if (ret == -1) {
+ if (ret < 0) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
if (ret == 0) {
diff --git a/source4/rpc_server/lsa/lsa_lookup.c b/source4/rpc_server/lsa/lsa_lookup.c
index b044eea..f5f0926 100644
--- a/source4/rpc_server/lsa/lsa_lookup.c
+++ b/source4/rpc_server/lsa/lsa_lookup.c
@@ -195,7 +195,7 @@ static NTSTATUS lookup_well_known_names(TALLOC_CTX *mem_ctx, const char *domain,
const char *name, const char **authority_name,
struct dom_sid **sid, uint32_t *rtype)
{
- int i;
+ unsigned int i;
for (i=0; well_known[i].sid; i++) {
if (domain) {
if (strcasecmp_m(domain, well_known[i].domain) == 0
@@ -221,7 +221,7 @@ static NTSTATUS lookup_well_known_sids(TALLOC_CTX *mem_ctx,
const char *sid_str, const char **authority_name,
const char **name, uint32_t *rtype)
{
- int i;
+ unsigned int i;
for (i=0; well_known[i].sid; i++) {
if (strcasecmp_m(sid_str, well_known[i].sid) == 0) {
*authority_name = well_known[i].domain;
@@ -379,12 +379,11 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct tevent_context *ev_ctx,
}
ret = gendb_search_dn(state->sam_ldb, mem_ctx, domain_dn, &res, attrs);
- if (ret == 1) {
- domain_sid = samdb_result_dom_sid(mem_ctx, res[0], "objectSid");
- if (domain_sid == NULL) {
- return NT_STATUS_INVALID_SID;
- }
- } else {
+ if (ret != 1) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+ domain_sid = samdb_result_dom_sid(mem_ctx, res[0], "objectSid");
+ if (domain_sid == NULL) {
return NT_STATUS_INVALID_SID;
}
@@ -398,8 +397,8 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct tevent_context *ev_ctx,
ret = gendb_search(state->sam_ldb, mem_ctx, domain_dn, &res, attrs,
"(&(sAMAccountName=%s)(objectSid=*))",
ldb_binary_encode_string(mem_ctx, username));
- if (ret == -1) {
- return NT_STATUS_INVALID_SID;
+ if (ret < 0) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
for (i=0; i < ret; i++) {
@@ -441,7 +440,7 @@ static NTSTATUS dcesrv_lsa_authority_list(struct lsa_policy_state *state, TALLOC
uint32_t *sid_index)
{
struct dom_sid *authority_sid;
- int i;
+ uint32_t i;
if (rtype != SID_NAME_DOMAIN) {
authority_sid = dom_sid_dup(mem_ctx, sid);
@@ -511,28 +510,30 @@ static NTSTATUS dcesrv_lsa_lookup_sid(struct lsa_policy_state *state, TALLOC_CTX
return NT_STATUS_NOT_FOUND;
}
+ /* need to re-add a check for an allocated sid */
+
ret = gendb_search(state->sam_ldb, mem_ctx, domain_dn, &res, attrs,
"objectSid=%s", ldap_encode_ndr_dom_sid(mem_ctx, sid));
- if (ret == 1) {
- *name = ldb_msg_find_attr_as_string(res[0], "sAMAccountName", NULL);
+ if ((ret < 0) || (ret > 1)) {
--
Samba Shared Repository
More information about the samba-cvs
mailing list