summaryrefslogtreecommitdiff
path: root/source3/groupdb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/groupdb')
-rw-r--r--source3/groupdb/mapping.c7
-rw-r--r--source3/groupdb/mapping_tdb.c23
-rw-r--r--source3/groupdb/proto.h27
3 files changed, 43 insertions, 14 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 3646e04d0a..70c96f186c 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -26,6 +26,7 @@
#include "groupdb/mapping.h"
#include "../libcli/security/security.h"
#include "lib/winbind_util.h"
+#include "tdb_compat.h"
static const struct mapping_backend *backend;
@@ -634,7 +635,7 @@ NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods,
return NT_STATUS_OK;
}
- *pp_alias_rids = TALLOC_ARRAY(mem_ctx, uint32, num_alias_sids);
+ *pp_alias_rids = talloc_array(mem_ctx, uint32, num_alias_sids);
if (*pp_alias_rids == NULL)
return NT_STATUS_NO_MEMORY;
@@ -777,8 +778,8 @@ NTSTATUS pdb_create_builtin_alias(uint32 rid)
map.gid = gid;
sid_copy(&map.sid, &sid);
map.sid_name_use = SID_NAME_ALIAS;
- fstrcpy(map.nt_name, groupname);
- fstrcpy(map.comment, "");
+ strlcpy(map.nt_name, groupname, sizeof(map.nt_name));
+ strlcpy(map.comment, "", sizeof(map.comment));
status = pdb_add_group_mapping_entry(&map);
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index 1137b8f658..fc195cb348 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -25,6 +25,7 @@
#include "passdb.h"
#include "groupdb/mapping.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#include "../libcli/security/security.h"
static struct db_context *db; /* used for driver files */
@@ -144,7 +145,7 @@ static bool add_mapping_entry(GROUP_MAP *map, int flag)
len = tdb_pack(NULL, 0, "ddff",
map->gid, map->sid_name_use, map->nt_name, map->comment);
- buf = TALLOC_ARRAY(key, char, len);
+ buf = talloc_array(key, char, len);
if (!buf) {
TALLOC_FREE(key);
return false;
@@ -848,7 +849,7 @@ static int convert_ldb_record(TDB_CONTEXT *ltdb, TDB_DATA key,
p += len + 1;
num_vals = pull_uint32(p, 0);
- if (StrCaseCmp(name, "member") == 0) {
+ if (strcasecmp_m(name, "member") == 0) {
num_mem = num_vals;
members = talloc_array(tmp_ctx, struct dom_sid, num_mem);
if (members == NULL) {
@@ -881,30 +882,30 @@ static int convert_ldb_record(TDB_CONTEXT *ltdb, TDB_DATA key,
/* we ignore unknown or uninteresting attributes
* (objectclass, etc.) */
- if (StrCaseCmp(name, "gidNumber") == 0) {
+ if (strcasecmp_m(name, "gidNumber") == 0) {
map.gid = strtoul(val, &q, 10);
if (*q) {
errno = EIO;
goto failed;
}
- } else if (StrCaseCmp(name, "sid") == 0) {
+ } else if (strcasecmp_m(name, "sid") == 0) {
if (!string_to_sid(&map.sid, val)) {
errno = EIO;
goto failed;
}
- } else if (StrCaseCmp(name, "sidNameUse") == 0) {
+ } else if (strcasecmp_m(name, "sidNameUse") == 0) {
map.sid_name_use = strtoul(val, &q, 10);
if (*q) {
errno = EIO;
goto failed;
}
- } else if (StrCaseCmp(name, "ntname") == 0) {
+ } else if (strcasecmp_m(name, "ntname") == 0) {
strlcpy(map.nt_name, val,
- sizeof(map.nt_name) -1);
- } else if (StrCaseCmp(name, "comment") == 0) {
+ sizeof(map.nt_name));
+ } else if (strcasecmp_m(name, "comment") == 0) {
strlcpy(map.comment, val,
- sizeof(map.comment) -1);
- } else if (StrCaseCmp(name, "member") == 0) {
+ sizeof(map.comment));
+ } else if (strcasecmp_m(name, "member") == 0) {
if (!string_to_sid(&members[j], val)) {
errno = EIO;
goto failed;
@@ -959,7 +960,7 @@ static bool mapping_switch(const char *ldb_path)
/* ldb is just a very fancy tdb, read out raw data and perform
* conversion */
ret = tdb_traverse(ltdb, convert_ldb_record, NULL);
- if (ret == -1) goto failed;
+ if (ret < 0) goto failed;
if (ltdb) {
tdb_close(ltdb);
diff --git a/source3/groupdb/proto.h b/source3/groupdb/proto.h
index 11162e6d3c..db07d4d64f 100644
--- a/source3/groupdb/proto.h
+++ b/source3/groupdb/proto.h
@@ -1,3 +1,28 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Group Mapping Database
+ *
+ * Copyright (C) Andrew Tridgell 1992-2006
+ * Copyright (C) Jean François Micouleau 1998-2001
+ * Copyright (C) Gerald Carter 2006
+ * Copyright (C) Volker Lendecke 2006
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GROUPDB_PROTO_H_
+#define _GROUPDB_PROTO_H_
/* The following definitions come from groupdb/mapping.c */
@@ -73,3 +98,5 @@ NTSTATUS pdb_create_builtin_alias(uint32 rid);
/* The following definitions come from groupdb/mapping_tdb.c */
const struct mapping_backend *groupdb_tdb_init(void);
+
+#endif /* _GROUPDB_PROTO_H_ */