From: Derrell Lipman Date: Wed, 18 Oct 2006 00:29:26 +0000 (+0000) Subject: r19383: pass only the base filename of an ldb file to be opened; allow server to... X-Git-Url: http://git.samba.org/samba.git/?p=kai%2Fsamba.git;a=commitdiff_plain;h=c111683f31c274a4df388b75e06896c5f7890ace r19383: pass only the base filename of an ldb file to be opened; allow server to prepend path where it's located (private_dir) (This used to be commit 5a21c97b73a896dbba0d814c2226e17a67034802) --- diff --git a/services/samba/ldb.esp b/services/samba/ldb.esp index d886d1a5665..1cd98adc3a9 100644 --- a/services/samba/ldb.esp +++ b/services/samba/ldb.esp @@ -30,7 +30,7 @@ jsonrpc_include("resources.esp"); * * @return * Success: The resource id to be used for future access to the database - * Failure: -1 + * Failure: error event * * @note * Credentials or session_info may be set up first. @@ -52,9 +52,23 @@ function _connect(params, error) return resourceId; } + /* Ensure there are no slashes in the database name */ + var components = split('/', params[0]); + if (components.length > 1) + { + error.setError(1, "Invalid database name (contains '/')"); + return error; + } + + /* Get access to loadparm functions */ + var lp = loadparm_init(); + + /* Determine the private directory */ + var private_dir = lp.get("private dir"); + /* Database was not previously opened. Connect to it. */ ldb = ldb_init(); - var ret = ldb.connect(params[0]); + var ret = ldb.connect(private_dir + "/" + params[0]); if (ret && ldb.db) { return session.resources.set(ldb, "ldb:" + params[0], error);