1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

r8256: - allow rpc calls from non-command line ejs contexts by creating a set

of null credentials to use if cmdline_credentials is not setup

- hide the length and size elements of a lsa_String from js scripts,
  so you can use a lsa_String just as an ordinary string without
  knowing its a structure. We won't do this with all structures, just
  a few core ones that are used often enough to warrant it.

- make sure returned ldb arrays have a length property
This commit is contained in:
Andrew Tridgell 2005-07-09 05:28:42 +00:00 committed by Gerald (Jerry) Carter
parent 354cdf893d
commit 12d2092dd8
5 changed files with 35 additions and 3 deletions

View File

@ -13,7 +13,7 @@
depends(security)
] interface lsarpc
{
typedef [public] struct {
typedef [public,noejs] struct {
[value(2*strlen_m(string))] uint16 length;
[value(2*strlen_m(string))] uint16 size;
unistr_noterm *string;

View File

@ -22,8 +22,9 @@
#include "includes.h"
#include "lib/ejs/ejs.h"
#include "scripting/ejs/ejsrpc.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/ndr_lsa.h"
#include "scripting/ejs/ejsrpc.h"
NTSTATUS ejs_pull_rpc(int eid, const char *callname,
struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull)
@ -423,3 +424,21 @@ BOOL ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
}
return False;
}
/*
pull a lsa_String
*/
NTSTATUS ejs_pull_lsa_String(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, struct lsa_String *r)
{
return ejs_pull_string(ejs, v, name, &r->string);
}
/*
push a lsa_String
*/
NTSTATUS ejs_push_lsa_String(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const struct lsa_String *r)
{
return ejs_push_string(ejs, v, name, r->string);
}

View File

@ -90,6 +90,7 @@ NTSTATUS ejs_push_dom_sid(struct ejs_rpc *ejs,
NTSTATUS ejs_push_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name);
BOOL ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name);
#define EJS_ALLOC_SIZE(ejs, s, size) do { \
(s) = talloc_size(ejs, size); \
if (!(s)) return ejs_panic(ejs, "out of memory"); \

View File

@ -119,6 +119,7 @@ struct MprVar mprLdbArray(struct ldb_message **msg, int count, const char *name)
for (i=0;i<count;i++) {
mprAddArray(&res, i, mprLdbMessage(msg[i]));
}
mprSetPropertyValue(&res, "length", mprCreateIntegerVar(i));
return res;
}

View File

@ -39,6 +39,8 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
NTSTATUS status;
struct dcerpc_pipe *p;
struct MprVar *conn;
struct cli_credentials *creds = cmdline_credentials;
struct event_context *ev;
/* validate arguments */
if (argc != 3 ||
@ -59,9 +61,18 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, struct MprVar **argv)
goto done;
}
if (creds == NULL) {
creds = cli_credentials_init(mprMemCtx());
cli_credentials_guess(creds);
cli_credentials_set_username(creds, "", CRED_GUESSED);
cli_credentials_set_password(creds, "", CRED_GUESSED);
}
ev = talloc_find_parent_bytype(mprMemCtx(), struct event_context);
status = dcerpc_pipe_connect(mprMemCtx(), &p, binding,
iface->uuid, iface->if_version,
cmdline_credentials, NULL);
creds, ev);
if (!NT_STATUS_IS_OK(status)) goto done;
/* callers don't allocate ref vars in the ejs interface */