summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-04-24 09:17:08 +0200
committerAndrew Bartlett <abartlet@samba.org>2009-04-24 09:17:08 +0200
commit2ee9ee2c17ce435ce45a773f19302a7b474554c2 (patch)
tree2ea91c2d36664f02e001575be0591660190d86ed
parentb82a204b9b2c28707ab7866a511ea4f5912826ac (diff)
parentaf6316d1500cfcedd5fd59ed0ddbba9aec9c3756 (diff)
downloadsamba-2ee9ee2c17ce435ce45a773f19302a7b474554c2.tar.gz
samba-2ee9ee2c17ce435ce45a773f19302a7b474554c2.tar.bz2
samba-2ee9ee2c17ce435ce45a773f19302a7b474554c2.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba into abartlet-devel
-rw-r--r--lib/util/charset/charcnv.c4
-rw-r--r--lib/util/charset/charset.h3
-rw-r--r--lib/util/charset/tests/iconv.c2
-rw-r--r--lib/util/charset/util_unistr.c13
-rw-r--r--source3/groupdb/mapping_ldb.c10
-rw-r--r--source3/lib/charcnv.c61
-rw-r--r--source3/lib/ldb/common/ldb.c6
-rw-r--r--source3/lib/ldb/common/ldb_dn.c53
-rw-r--r--source3/lib/ldb/include/ldb.h9
-rw-r--r--source3/lib/ldb/tools/ldbadd.c2
-rw-r--r--source3/lib/ldb/tools/ldbdel.c2
-rw-r--r--source3/lib/ldb/tools/ldbedit.c2
-rw-r--r--source3/lib/ldb/tools/ldbmodify.c2
-rw-r--r--source3/lib/ldb/tools/ldbrename.c2
-rw-r--r--source3/lib/ldb/tools/ldbsearch.c2
-rw-r--r--source3/libads/ldap.c22
-rw-r--r--source4/lib/ldb/common/ldb.c6
-rw-r--r--source4/lib/registry/patchfile_preg.c38
-rw-r--r--source4/libcli/security/tests/bindings.py6
-rw-r--r--source4/librpc/ndr/py_security.c2
-rw-r--r--source4/ntvfs/posix/pvfs_rename.c4
21 files changed, 180 insertions, 71 deletions
diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c
index 94d47a9f7f..a479f44426 100644
--- a/lib/util/charset/charcnv.c
+++ b/lib/util/charset/charcnv.c
@@ -430,7 +430,7 @@ _PUBLIC_ codepoint_t next_codepoint_convenience(struct smb_iconv_convenience *ic
return the number of bytes occupied by the CH_UNIX character, or
-1 on failure
*/
-_PUBLIC_ ssize_t push_codepoint(struct smb_iconv_convenience *ic,
+_PUBLIC_ ssize_t push_codepoint_convenience(struct smb_iconv_convenience *ic,
char *str, codepoint_t c)
{
smb_iconv_t descriptor;
@@ -478,3 +478,5 @@ _PUBLIC_ ssize_t push_codepoint(struct smb_iconv_convenience *ic,
}
return 5 - olen;
}
+
+
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index 37c5acafaf..2c8aa41ad5 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -151,11 +151,12 @@ ssize_t iconv_talloc(TALLOC_CTX *mem_ctx,
extern struct smb_iconv_convenience *global_iconv_convenience;
codepoint_t next_codepoint(const char *str, size_t *size);
+ssize_t push_codepoint(char *str, codepoint_t c);
/* codepoints */
codepoint_t next_codepoint_convenience(struct smb_iconv_convenience *ic,
const char *str, size_t *size);
-ssize_t push_codepoint(struct smb_iconv_convenience *ic,
+ssize_t push_codepoint_convenience(struct smb_iconv_convenience *ic,
char *str, codepoint_t c);
codepoint_t toupper_m(codepoint_t val);
codepoint_t tolower_m(codepoint_t val);
diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c
index 091876f63b..e8d7bc1384 100644
--- a/lib/util/charset/tests/iconv.c
+++ b/lib/util/charset/tests/iconv.c
@@ -288,7 +288,7 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint)
size_t size, size2;
codepoint_t c;
- size = push_codepoint(lp_iconv_convenience(tctx->lp_ctx), (char *)buf, codepoint);
+ size = push_codepoint_convenience(lp_iconv_convenience(tctx->lp_ctx), (char *)buf, codepoint);
torture_assert(tctx, size != -1 || (codepoint >= 0xd800 && codepoint <= 0x10000),
"Invalid Codepoint range");
diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
index ea2bfeab9f..024dc70acc 100644
--- a/lib/util/charset/util_unistr.c
+++ b/lib/util/charset/util_unistr.c
@@ -444,7 +444,7 @@ _PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src)
c = tolower_m(c);
- c_size = push_codepoint(iconv_convenience, dest+size, c);
+ c_size = push_codepoint_convenience(iconv_convenience, dest+size, c);
if (c_size == -1) {
talloc_free(dest);
return NULL;
@@ -490,7 +490,7 @@ _PUBLIC_ char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n)
c = toupper_m(c);
- c_size = push_codepoint(iconv_convenience, dest+size, c);
+ c_size = push_codepoint_convenience(iconv_convenience, dest+size, c);
if (c_size == -1) {
talloc_free(dest);
return NULL;
@@ -551,7 +551,7 @@ _PUBLIC_ void strlower_m(char *s)
while (*s) {
size_t c_size, c_size2;
codepoint_t c = next_codepoint_convenience(iconv_convenience, s, &c_size);
- c_size2 = push_codepoint(iconv_convenience, d, tolower_m(c));
+ c_size2 = push_codepoint_convenience(iconv_convenience, d, tolower_m(c));
if (c_size2 > c_size) {
DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strlower_m\n",
c, tolower_m(c), (int)c_size, (int)c_size2));
@@ -590,7 +590,7 @@ _PUBLIC_ void strupper_m(char *s)
while (*s) {
size_t c_size, c_size2;
codepoint_t c = next_codepoint_convenience(iconv_convenience, s, &c_size);
- c_size2 = push_codepoint(iconv_convenience, d, toupper_m(c));
+ c_size2 = push_codepoint_convenience(iconv_convenience, d, toupper_m(c));
if (c_size2 > c_size) {
DEBUG(0,("FATAL: codepoint 0x%x (0x%x) expanded from %d to %d bytes in strupper_m\n",
c, toupper_m(c), (int)c_size, (int)c_size2));
@@ -992,3 +992,8 @@ _PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size)
{
return next_codepoint_convenience(get_iconv_convenience(), str, size);
}
+
+_PUBLIC_ ssize_t push_codepoint(char *str, codepoint_t c)
+{
+ return push_codepoint_convenience(get_iconv_convenience(), str, c);
+}
diff --git a/source3/groupdb/mapping_ldb.c b/source3/groupdb/mapping_ldb.c
index a162c194d6..7ad0bbb703 100644
--- a/source3/groupdb/mapping_ldb.c
+++ b/source3/groupdb/mapping_ldb.c
@@ -23,7 +23,7 @@
#include "includes.h"
#include "groupdb/mapping.h"
-#include "lib/ldb/include/includes.h"
+#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
static struct ldb_context *ldb;
@@ -57,7 +57,7 @@ static bool init_group_mapping(void)
db_path = state_path("group_mapping.ldb");
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
if (ldb == NULL) goto failed;
/* Ensure this db is created read/write for root only. */
@@ -133,8 +133,8 @@ static struct ldb_dn *mapping_dn(TALLOC_CTX *mem_ctx, const DOM_SID *sid)
}
/* we split by domain and rid so we can do a subtree search
when we only want one domain */
- return ldb_dn_string_compose(mem_ctx, NULL, "rid=%u,domain=%s",
- rid, string_sid);
+ return ldb_dn_new_fmt(mem_ctx, ldb, "rid=%u,domain=%s",
+ rid, string_sid);
}
/*
@@ -328,7 +328,7 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_
/* we do a subtree search on the domain */
if (domsid != NULL) {
sid_to_fstring(name, domsid);
- basedn = ldb_dn_string_compose(tmp_ctx, NULL, "domain=%s", name);
+ basedn = ldb_dn_new_fmt(tmp_ctx, ldb, "domain=%s", name);
if (basedn == NULL) goto failed;
}
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 374079c8ae..eb794d8347 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -1861,3 +1861,64 @@ codepoint_t next_codepoint(const char *str, size_t *size)
/* no other length is valid */
return INVALID_CODEPOINT;
}
+
+/*
+ push a single codepoint into a CH_UNIX string the target string must
+ be able to hold the full character, which is guaranteed if it is at
+ least 5 bytes in size. The caller may pass less than 5 bytes if they
+ are sure the character will fit (for example, you can assume that
+ uppercase/lowercase of a character will not add more than 1 byte)
+
+ return the number of bytes occupied by the CH_UNIX character, or
+ -1 on failure
+*/
+_PUBLIC_ ssize_t push_codepoint(char *str, codepoint_t c)
+{
+ smb_iconv_t descriptor;
+ uint8_t buf[4];
+ size_t ilen, olen;
+ const char *inbuf;
+
+ if (c < 128) {
+ *str = c;
+ return 1;
+ }
+
+ lazy_initialize_conv();
+
+ descriptor = conv_handles[CH_UNIX][CH_UTF16LE];
+ if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) {
+ return -1;
+ }
+
+ if (c < 0x10000) {
+ ilen = 2;
+ olen = 5;
+ inbuf = (char *)buf;
+ SSVAL(buf, 0, c);
+ smb_iconv(descriptor, &inbuf, &ilen, &str, &olen);
+ if (ilen != 0) {
+ return -1;
+ }
+ return 5 - olen;
+ }
+
+ c -= 0x10000;
+
+ buf[0] = (c>>10) & 0xFF;
+ buf[1] = (c>>18) | 0xd8;
+ buf[2] = c & 0xFF;
+ buf[3] = ((c>>8) & 0x3) | 0xdc;
+
+ ilen = 4;
+ olen = 5;
+ inbuf = (char *)buf;
+
+ smb_iconv(descriptor, &inbuf, &ilen, &str, &olen);
+ if (ilen != 0) {
+ return -1;
+ }
+ return 5 - olen;
+}
+
+
diff --git a/source3/lib/ldb/common/ldb.c b/source3/lib/ldb/common/ldb.c
index cef7373c26..791c1863d7 100644
--- a/source3/lib/ldb/common/ldb.c
+++ b/source3/lib/ldb/common/ldb.c
@@ -39,7 +39,7 @@
initialise a ldb context
The mem_ctx is optional
*/
-struct ldb_context *ldb_init(void *mem_ctx)
+struct ldb_context *ldb_init(void *mem_ctx, struct tevent_context *tev_ctx)
{
struct ldb_context *ldb = talloc_zero(mem_ctx, struct ldb_context);
int ret;
@@ -166,7 +166,7 @@ static const struct ldb_dn *ldb_set_default_basedn(struct ldb_context *ldb)
}
tmp_ctx = talloc_new(ldb);
- ret = ldb_search(ldb, ldb, &res, ldb_dn_new(tmp_ctx), LDB_SCOPE_BASE,
+ ret = ldb_search(ldb, ldb, &res, ldb_dn_new(tmp_ctx, ldb, NULL), LDB_SCOPE_BASE,
attrs, "(objectClass=*)");
if (ret == LDB_SUCCESS) {
if (res->count == 1) {
@@ -601,7 +601,7 @@ int ldb_build_search_req(struct ldb_request **ret_req,
req->operation = LDB_SEARCH;
if (base == NULL) {
- req->op.search.base = ldb_dn_new(req);
+ req->op.search.base = ldb_dn_new(req, ldb, NULL);
} else {
req->op.search.base = base;
}
diff --git a/source3/lib/ldb/common/ldb_dn.c b/source3/lib/ldb/common/ldb_dn.c
index 7ef3c38024..09d58555bd 100644
--- a/source3/lib/ldb/common/ldb_dn.c
+++ b/source3/lib/ldb/common/ldb_dn.c
@@ -332,21 +332,44 @@ failed:
return dc;
}
-struct ldb_dn *ldb_dn_new(void *mem_ctx)
+struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *text)
{
struct ldb_dn *edn;
- edn = talloc(mem_ctx, struct ldb_dn);
- LDB_DN_NULL_FAILED(edn);
-
- /* Initially there are no components */
- edn->comp_num = 0;
- edn->components = NULL;
+ if (text == NULL) {
+ edn = talloc_zero(mem_ctx, struct ldb_dn);
+ } else {
+ edn = ldb_dn_explode(mem_ctx, text);
+ }
return edn;
+}
-failed:
- return NULL;
+bool ldb_dn_validate(struct ldb_dn *dn)
+{
+ /* This implementation does not do "lazy" evaluation of DN's, so
+ * if a DN can be created it will be valid. */
+ return true;
+}
+
+struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...)
+{
+ char *strdn;
+ va_list ap;
+ struct ldb_dn *dn;
+
+ if ( (! mem_ctx) || (! ldb)) return NULL;
+
+ va_start(ap, new_fmt);
+ strdn = talloc_vasprintf(mem_ctx, new_fmt, ap);
+ if (strdn == NULL)
+ return NULL;
+ va_end(ap);
+
+ dn = ldb_dn_explode(mem_ctx, strdn);
+
+ talloc_free(strdn);
+ return dn;
}
/*
@@ -360,7 +383,7 @@ struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn)
if (dn == NULL) return NULL;
/* Allocate a structure to hold the exploded DN */
- edn = ldb_dn_new(mem_ctx);
+ edn = talloc_zero(mem_ctx, struct ldb_dn);
if (edn == NULL) {
return NULL;
}
@@ -440,7 +463,7 @@ struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn)
*/
/* Allocate a structure to hold the exploded DN */
- if (!(edn = ldb_dn_new(mem_ctx))) {
+ if (!(edn = talloc_zero(mem_ctx, struct ldb_dn))) {
return NULL;
}
@@ -599,7 +622,7 @@ struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const str
if (edn == NULL) return NULL;
- cedn = ldb_dn_new(mem_ctx);
+ cedn = talloc_zero(mem_ctx, struct ldb_dn);
if (!cedn) {
return NULL;
}
@@ -737,7 +760,7 @@ struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int n
if (dn == NULL) return NULL;
if (num_el <= 0) return NULL;
- newdn = ldb_dn_new(mem_ctx);
+ newdn = talloc_zero(mem_ctx, struct ldb_dn);
LDB_DN_NULL_FAILED(newdn);
newdn->comp_num = num_el;
@@ -814,7 +837,7 @@ struct ldb_dn *ldb_dn_build_child(void *mem_ctx, const char *attr,
newdn = ldb_dn_copy_partial(mem_ctx, base, base->comp_num + 1);
LDB_DN_NULL_FAILED(newdn);
} else {
- newdn = ldb_dn_new(mem_ctx);
+ newdn = talloc_zero(mem_ctx, struct ldb_dn);
LDB_DN_NULL_FAILED(newdn);
newdn->comp_num = 1;
@@ -847,7 +870,7 @@ struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const str
}
if (dn2 == NULL) {
- newdn = ldb_dn_new(mem_ctx);
+ newdn = talloc_zero(mem_ctx, struct ldb_dn);
LDB_DN_NULL_FAILED(newdn);
newdn->comp_num = dn1->comp_num;
diff --git a/source3/lib/ldb/include/ldb.h b/source3/lib/ldb/include/ldb.h
index 113652a1a7..466e4a21ee 100644
--- a/source3/lib/ldb/include/ldb.h
+++ b/source3/lib/ldb/include/ldb.h
@@ -795,10 +795,13 @@ int ldb_global_init(void);
\param mem_ctx pointer to a talloc memory context. Pass NULL if there is
no suitable context available.
+ \param ev_ctx Event context. This is here for API compatibility
+ with the Samba 4 version of LDB and ignored in this version of LDB.
+
\return pointer to ldb_context that should be free'd (using talloc_free())
at the end of the program.
*/
-struct ldb_context *ldb_init(void *mem_ctx);
+struct ldb_context *ldb_init(void *mem_ctx, struct tevent_context *ev_ctx);
/**
Connect to a database.
@@ -1275,7 +1278,9 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb,
int ldb_dn_is_special(const struct ldb_dn *dn);
int ldb_dn_check_special(const struct ldb_dn *dn, const char *check);
char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
-struct ldb_dn *ldb_dn_new(void *mem_ctx);
+struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn);
+bool ldb_dn_validate(struct ldb_dn *dn);
+struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...);
struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn);
char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn);
diff --git a/source3/lib/ldb/tools/ldbadd.c b/source3/lib/ldb/tools/ldbadd.c
index 155395e065..c23a13ab3c 100644
--- a/source3/lib/ldb/tools/ldbadd.c
+++ b/source3/lib/ldb/tools/ldbadd.c
@@ -90,7 +90,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbdel.c b/source3/lib/ldb/tools/ldbdel.c
index c58a82a523..bdd1b60014 100644
--- a/source3/lib/ldb/tools/ldbdel.c
+++ b/source3/lib/ldb/tools/ldbdel.c
@@ -80,7 +80,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbedit.c b/source3/lib/ldb/tools/ldbedit.c
index a33e6ae704..6b9eaec111 100644
--- a/source3/lib/ldb/tools/ldbedit.c
+++ b/source3/lib/ldb/tools/ldbedit.c
@@ -282,7 +282,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbmodify.c b/source3/lib/ldb/tools/ldbmodify.c
index f12387a8f6..e3552b4ea3 100644
--- a/source3/lib/ldb/tools/ldbmodify.c
+++ b/source3/lib/ldb/tools/ldbmodify.c
@@ -92,7 +92,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbrename.c b/source3/lib/ldb/tools/ldbrename.c
index d6c3a4ab62..d66d4b93c3 100644
--- a/source3/lib/ldb/tools/ldbrename.c
+++ b/source3/lib/ldb/tools/ldbrename.c
@@ -59,7 +59,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbsearch.c b/source3/lib/ldb/tools/ldbsearch.c
index e5cec0fa66..f1c88d580b 100644
--- a/source3/lib/ldb/tools/ldbsearch.c
+++ b/source3/lib/ldb/tools/ldbsearch.c
@@ -279,7 +279,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index cc72d81b86..588c0a131c 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -22,7 +22,7 @@
*/
#include "includes.h"
-#include "lib/ldb/include/includes.h"
+#include "lib/ldb/include/ldb.h"
#ifdef HAVE_LDAP
@@ -3858,34 +3858,36 @@ ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
struct ldb_dn *name_dn = NULL;
const char *name = NULL;
char *ou_string = NULL;
+ struct ldb_context *ldb = ldb_init(mem_ctx, NULL);
- name_dn = ldb_dn_explode(mem_ctx, *account_ou);
- if (name_dn) {
+ name_dn = ldb_dn_new(mem_ctx, ldb, *account_ou);
+ if (name_dn && ldb_dn_validate(name_dn)) {
+ talloc_free(ldb);
return ADS_SUCCESS;
}
ou_string = ads_ou_string(ads, *account_ou);
if (!ou_string) {
+ talloc_free(ldb);
return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
}
- name = talloc_asprintf(mem_ctx, "%s,%s", ou_string,
- ads->config.bind_path);
+ name_dn = ldb_dn_new_fmt(mem_ctx, ldb, "%s,%s", ou_string,
+ ads->config.bind_path);
SAFE_FREE(ou_string);
- if (!name) {
- return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
- }
- name_dn = ldb_dn_explode(mem_ctx, name);
- if (!name_dn) {
+ if (!name_dn || !ldb_dn_validate(name_dn)) {
+ talloc_free(ldb);
return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
}
*account_ou = talloc_strdup(mem_ctx, name);
if (!*account_ou) {
+ talloc_free(ldb);
return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
}
+ talloc_free(ldb);
return ADS_SUCCESS;
}
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 86ce2069a5..64ad6832db 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -1430,3 +1430,9 @@ void *ldb_get_opaque(struct ldb_context *ldb, const char *name)
}
return NULL;
}
+
+int ldb_global_init(void)
+{
+ /* Provided for compatibility with some older versions of ldb */
+ return 0;
+}
diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index e9801bb425..30a9aea2a5 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -27,27 +27,26 @@
struct preg_data {
int fd;
TALLOC_CTX *ctx;
- struct smb_iconv_convenience *ic;
};
-static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
+static WERROR preg_read_utf16(int fd, char *c)
{
uint16_t v;
if (read(fd, &v, 2) < 2) {
return WERR_GENERAL_FAILURE;
}
- push_codepoint(ic, c, v);
+ push_codepoint(c, v);
return WERR_OK;
}
-static WERROR preg_write_utf16(struct smb_iconv_convenience *ic, int fd, const char *string)
+static WERROR preg_write_utf16(int fd, const char *string)
{
codepoint_t v;
uint16_t i;
size_t size;
for (i = 0; i < strlen(string); i+=size) {
- v = next_codepoint_convenience(ic, &string[i], &size);
+ v = next_codepoint(&string[i], &size);
if (write(fd, &v, 2) < 2) {
return WERR_GENERAL_FAILURE;
}
@@ -67,19 +66,19 @@ static WERROR reg_preg_diff_set_value(void *_data, const char *key_name,
struct preg_data *data = (struct preg_data *)_data;
uint32_t buf;
- preg_write_utf16(data->ic, data->fd, "[");
- preg_write_utf16(data->ic, data->fd, key_name);
- preg_write_utf16(data->ic, data->fd, ";");
- preg_write_utf16(data->ic, data->fd, value_name);
- preg_write_utf16(data->ic, data->fd, ";");
+ preg_write_utf16(data->fd, "[");
+ preg_write_utf16(data->fd, key_name);
+ preg_write_utf16(data->fd, ";");
+ preg_write_utf16(data->fd, value_name);
+ preg_write_utf16(data->fd, ";");
SIVAL(&buf, 0, value_type);
write(data->fd, &buf, sizeof(uint32_t));
- preg_write_utf16(data->ic, data->fd, ";");
+ preg_write_utf16(data->fd, ";");
SIVAL(&buf, 0, value_data.length);
write(data->fd, &buf, sizeof(uint32_t));
- preg_write_utf16(data->ic, data->fd, ";");
+ preg_write_utf16(data->fd, ";");
write(data->fd, value_data.data, value_data.length);
- preg_write_utf16(data->ic, data->fd, "]");
+ preg_write_utf16(data->fd, "]");
return WERR_OK;
}
@@ -169,7 +168,6 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
write(data->fd, (uint8_t *)&preg_header,8);
data->ctx = ctx;
- data->ic = ic;
*callbacks = talloc(ctx, struct reg_diff_callbacks);
@@ -228,7 +226,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
while(1) {
uint32_t value_type, length;
- if (!W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr))) {
+ if (!W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr))) {
break;
}
if (*buf_ptr != '[') {
@@ -239,7 +237,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
/* Get the path */
buf_ptr = buf;
- while (W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
+ while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
*buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
@@ -248,7 +246,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
/* Get the name */
buf_ptr = buf;
- while (W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
+ while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
*buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
@@ -265,7 +263,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
/* Read past delimiter */
buf_ptr = buf;
- if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
+ if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
*buf_ptr == ';') && buf_ptr-buf < buf_size) {
DEBUG(0, ("Error in PReg file.\n"));
ret = WERR_GENERAL_FAILURE;
@@ -279,7 +277,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
}
/* Read past delimiter */
buf_ptr = buf;
- if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
+ if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
*buf_ptr == ';') && buf_ptr-buf < buf_size) {
DEBUG(0, ("Error in PReg file.\n"));
ret = WERR_GENERAL_FAILURE;
@@ -297,7 +295,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
/* Check if delimiter is in place (whine if it isn't) */
buf_ptr = buf;
- if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
+ if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
*buf_ptr == ']') && buf_ptr-buf < buf_size) {
DEBUG(0, ("Warning: Missing ']' in PReg file, expected ']', got '%c' 0x%x.\n",
*buf_ptr, *buf_ptr));
diff --git a/source4/libcli/security/tests/bindings.py b/source4/libcli/security/tests/bindings.py
index 5c153050be..f0d55f12ca 100644
--- a/source4/libcli/security/tests/bindings.py
+++ b/source4/libcli/security/tests/bindings.py
@@ -77,6 +77,12 @@ class SecurityDescriptorTests(unittest.TestCase):
self.assertEquals(desc1.sacl, desc2.sacl)
self.assertEquals(desc1.type, desc2.type)
+ def test_domsid_nodomsid_as_sddl(self):
+ dom = security.dom_sid("S-2-0-0")
+ text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
+ desc1 = security.descriptor.from_sddl(text, dom)
+ self.assertNotEqual(desc1.as_sddl(), desc1.as_sddl(dom))
+
class DomSidTests(unittest.TestCase):
def test_parse_sid(self):
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index 43c1d50d66..1b54aab02a 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -198,7 +198,7 @@ static PyObject *py_descriptor_as_sddl(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|O", &py_sid))
return NULL;
- if (py_sid == Py_None)
+ if (py_sid != Py_None)
sid = py_talloc_get_ptr(py_sid);
else
sid = NULL;
diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c
index 7f8eab5aa0..0616d38bee 100644
--- a/source4/ntvfs/posix/pvfs_rename.c
+++ b/source4/ntvfs/posix/pvfs_rename.c
@@ -118,13 +118,13 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
c1 = next_codepoint_convenience(iconv_convenience, p1, &c_size1);
c2 = next_codepoint_convenience(iconv_convenience, p2, &c_size2);
if (c2 == '?') {
- d += push_codepoint(iconv_convenience, d, c1);
+ d += push_codepoint_convenience(iconv_convenience, d, c1);
} else if (c2 == '*') {
memcpy(d, p1, strlen(p1));
d += strlen(p1);
break;
} else {
- d += push_codepoint(iconv_convenience, d, c2);
+ d += push_codepoint_convenience(iconv_convenience, d, c2);
}
p1 += c_size1;