diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-01-03 19:39:53 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:49:41 -0500 |
commit | 34be0772d2a24c3836cfe7a335184ba2d8902e81 (patch) | |
tree | 57f98d05c06fe97ddf4e300b6ef9b6499647474f | |
parent | 769eb7d3fe4ac96cedc6582626010d421b40b80f (diff) | |
download | samba-34be0772d2a24c3836cfe7a335184ba2d8902e81.tar.gz samba-34be0772d2a24c3836cfe7a335184ba2d8902e81.tar.bz2 samba-34be0772d2a24c3836cfe7a335184ba2d8902e81.zip |
r12699: correctly escape invalid DN characters (reported by Steinar H. Gunderson).
this still doesn't work as a bug in ldb causes it to not understand
escaped characters in DNs when parsing DNs
(This used to be commit 10da56fb6cc57b6c0650a8dc81ded5faa643a96e)
-rw-r--r-- | source4/scripting/ejs/smbcalls_ldb.c | 31 | ||||
-rw-r--r-- | source4/scripting/libjs/upgrade.js | 2 |
2 files changed, 31 insertions, 2 deletions
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c index e9dba94eaa..78063ed6b4 100644 --- a/source4/scripting/ejs/smbcalls_ldb.c +++ b/source4/scripting/ejs/smbcalls_ldb.c @@ -322,7 +322,35 @@ static int ejs_base64decode(MprVarHandle eid, int argc, struct MprVar **argv) return 0; } - + +/* + escape a DN + usage: + dataout = ldb.dn_escape(datain) + */ +static int ejs_dn_escape(MprVarHandle eid, int argc, struct MprVar **argv) +{ + char *ret; + struct ldb_val val; + + if (argc != 1) { + ejsSetErrorMsg(eid, "ldb.dn_escape invalid argument count"); + return -1; + } + + val.data = mprToString(argv[0]); + val.length = strlen((const char *)val.data); + + ret = ldb_dn_escape_value(mprMemCtx(), val); + if (ret == NULL) { + mpr_Return(eid, mprCreateUndefinedVar()); + } else { + mpr_Return(eid, mprString(ret)); + talloc_free(ret); + } + + return 0; +} /* perform an ldb add @@ -511,6 +539,7 @@ static int ejs_ldb_init(MprVarHandle eid, int argc, struct MprVar **argv) mprSetCFunction(ldb, "errstring", ejs_ldbErrstring); mprSetCFunction(ldb, "encode", ejs_base64encode); mprSetCFunction(ldb, "decode", ejs_base64decode); + mprSetCFunction(ldb, "dn_escape", ejs_dn_escape); mprSetCFunction(ldb, "close", ejs_ldbClose); mprSetCFunction(ldb, "transaction_start", ejs_ldbTransactionStart); mprSetCFunction(ldb, "transaction_cancel", ejs_ldbTransactionCancel); diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js index 4ac6b6db34..0ffb790d5f 100644 --- a/source4/scripting/libjs/upgrade.js +++ b/source4/scripting/libjs/upgrade.js @@ -151,7 +151,7 @@ objectSid: %s-%d lmPwdHash:: %s ntPwdHash:: %s -", acc.fullname, domaindn, acc.logon_time, acc.logoff_time, acc.username, acc.nt_username, acc.nt_username, +", ldb.dn_escape(acc.fullname), domaindn, acc.logon_time, acc.logoff_time, acc.username, acc.nt_username, acc.nt_username, acc.fullname, acc.acct_desc, acc.group_rid, acc.bad_password_count, acc.logon_count, acc.domain, acc.dir_drive, acc.munged_dial, acc.homedir, acc.logon_script, |