summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/com/dcom/dcom.h4
-rw-r--r--source4/lib/com/dcom/main.c20
-rw-r--r--source4/lib/credentials.c24
-rw-r--r--source4/lib/registry/reg_backend_rpc.c6
-rw-r--r--source4/lib/registry/tools/regdiff.c5
-rw-r--r--source4/lib/registry/tools/regpatch.c2
-rw-r--r--source4/lib/registry/tools/regshell.c2
-rw-r--r--source4/lib/registry/tools/regtree.c2
8 files changed, 37 insertions, 28 deletions
diff --git a/source4/lib/com/dcom/dcom.h b/source4/lib/com/dcom/dcom.h
index 668d952124..1e15daf830 100644
--- a/source4/lib/com/dcom/dcom.h
+++ b/source4/lib/com/dcom/dcom.h
@@ -22,9 +22,7 @@
#define _DCOM_H
struct dcom_client_context {
- const char *domain;
- const char *user;
- const char *password;
+ struct cli_credentials *credentials;
struct dcom_object_exporter {
uint64_t oxid;
struct DUALSTRINGARRAY bindings;
diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c
index d3d44edc71..be350c32f5 100644
--- a/source4/lib/com/dcom/main.c
+++ b/source4/lib/com/dcom/main.c
@@ -30,12 +30,10 @@
#define DCOM_NEGOTIATED_PROTOCOLS { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NCALRPC }
-struct dcom_client_context *dcom_client_init(struct com_context *ctx, const char *domain, const char *user, const char *password)
+struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli_credentials *credentials)
{
ctx->dcom = talloc(ctx, struct dcom_client_context);
- ctx->dcom->domain = domain;
- ctx->dcom->user = user;
- ctx->dcom->password = password;
+ ctx->dcom->credentials = credentials;
return ctx->dcom;
}
@@ -86,8 +84,7 @@ static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **
return dcerpc_pipe_connect(p, "ncalrpc",
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- lp_netbios_name(),
- ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password);
+ ctx->dcom->credentials);
}
/* Allow server name to contain a binding string */
@@ -95,8 +92,7 @@ static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **
status = dcerpc_pipe_connect_b(p, bd,
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- lp_netbios_name(),
- ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password);
+ ctx->dcom->credentials);
talloc_free(mem_ctx);
return status;
@@ -113,8 +109,7 @@ static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **
status = dcerpc_pipe_connect(p, binding,
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- lp_netbios_name(),
- ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password);
+ ctx->dcom->credentials);
if (NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
@@ -308,10 +303,7 @@ NTSTATUS dcom_get_pipe (struct IUnknown *iface, struct dcerpc_pipe **pp)
} else {
status = dcerpc_pipe_connect_b(&p, binding,
uuid, 0.0,
- lp_netbios_name(),
- iface->ctx->dcom->domain,
- iface->ctx->dcom->user,
- iface->ctx->dcom->password);
+ iface->ctx->dcom->credentials);
}
talloc_free(binding);
i++;
diff --git a/source4/lib/credentials.c b/source4/lib/credentials.c
index 5c78d2b2e6..1c65bd2aff 100644
--- a/source4/lib/credentials.c
+++ b/source4/lib/credentials.c
@@ -24,6 +24,10 @@
const char *cli_credentials_get_username(struct cli_credentials *cred)
{
+ if (cred == NULL) {
+ return NULL;
+ }
+
if (cred->username_obtained == CRED_CALLBACK) {
cred->username = cred->username_cb(cred);
cred->username_obtained = CRED_SPECIFIED;
@@ -45,6 +49,10 @@ BOOL cli_credentials_set_username(struct cli_credentials *cred, const char *val,
const char *cli_credentials_get_password(struct cli_credentials *cred)
{
+ if (cred == NULL) {
+ return NULL;
+ }
+
if (cred->password_obtained == CRED_CALLBACK) {
cred->password = cred->password_cb(cred);
cred->password_obtained = CRED_SPECIFIED;
@@ -66,6 +74,10 @@ BOOL cli_credentials_set_password(struct cli_credentials *cred, const char *val,
const char *cli_credentials_get_domain(struct cli_credentials *cred)
{
+ if (cred == NULL) {
+ return NULL;
+ }
+
if (cred->domain_obtained == CRED_CALLBACK) {
cred->domain = cred->domain_cb(cred);
cred->domain_obtained = CRED_SPECIFIED;
@@ -87,7 +99,11 @@ BOOL cli_credentials_set_domain(struct cli_credentials *cred, const char *val, e
}
const char *cli_credentials_get_realm(struct cli_credentials *cred)
-{
+{
+ if (cred == NULL) {
+ return NULL;
+ }
+
if (cred->realm_obtained == CRED_CALLBACK) {
cred->realm = cred->realm_cb(cred);
cred->realm_obtained = CRED_SPECIFIED;
@@ -109,6 +125,10 @@ BOOL cli_credentials_set_realm(struct cli_credentials *cred, const char *val, en
const char *cli_credentials_get_workstation(struct cli_credentials *cred)
{
+ if (cred == NULL) {
+ return NULL;
+ }
+
if (cred->workstation_obtained == CRED_CALLBACK) {
cred->workstation = cred->workstation_cb(cred);
cred->workstation_obtained = CRED_SPECIFIED;
@@ -246,7 +266,7 @@ void cli_credentials_parse_string(struct cli_credentials *credentials, const cha
uname = talloc_strdup(credentials, data);
cli_credentials_set_username(credentials, uname, obtained);
- if ((p = strchr_m(uname,'\\'))) {
+ if ((p = strchr_m(uname,'\\')) || (p = strchr_m(uname, '/'))) {
*p = 0;
cli_credentials_set_domain(credentials, uname, obtained);
credentials->username = uname = p+1;
diff --git a/source4/lib/registry/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc.c
index 4a285262c6..a72d104521 100644
--- a/source4/lib/registry/reg_backend_rpc.c
+++ b/source4/lib/registry/reg_backend_rpc.c
@@ -369,7 +369,7 @@ static struct hive_operations reg_backend_rpc = {
.num_values = rpc_num_values,
};
-WERROR reg_open_remote (struct registry_context **ctx, const char *user, const char *pass, const char *location)
+WERROR reg_open_remote (struct registry_context **ctx, struct cli_credentials *credentials, const char *location)
{
NTSTATUS status;
struct dcerpc_pipe *p;
@@ -384,9 +384,7 @@ WERROR reg_open_remote (struct registry_context **ctx, const char *user, const c
status = dcerpc_pipe_connect(&p, location,
DCERPC_WINREG_UUID,
DCERPC_WINREG_VERSION,
- lp_netbios_name(),
- lp_workgroup(),
- user, pass);
+ credentials);
(*ctx)->backend_data = p;
if(NT_STATUS_IS_ERR(status)) {
diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c
index 7206e1e44d..dfc8be13ca 100644
--- a/source4/lib/registry/tools/regdiff.c
+++ b/source4/lib/registry/tools/regdiff.c
@@ -146,8 +146,9 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey,
else if (!h2) error = reg_open_local(&h2);
break;
case 'R':
- if (!h1 && !from_null) error = reg_open_remote(&h1, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), poptGetOptArg(pc));
- else if (!h2) error = reg_open_remote(&h2, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), poptGetOptArg(pc));
+ if (!h1 && !from_null)
+ error = reg_open_remote(&h1, cmdline_credentials, poptGetOptArg(pc));
+ else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, poptGetOptArg(pc));
break;
}
diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c
index ce3d9a7e1b..2462fd8241 100644
--- a/source4/lib/registry/tools/regpatch.c
+++ b/source4/lib/registry/tools/regpatch.c
@@ -769,7 +769,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd
setup_logging(argv[0], True);
if (remote) {
- error = reg_open_remote (&h, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), remote);
+ error = reg_open_remote (&h, cmdline_credentials, remote);
} else {
error = reg_open_local (&h);
}
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index cab2c5e34b..bb7533e55e 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -395,7 +395,7 @@ static char **reg_completion(const char *text, int start, int end)
setup_logging("regtree", True);
if (remote) {
- error = reg_open_remote (&h, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), remote);
+ error = reg_open_remote (&h, cmdline_credentials, remote);
} else if (backend) {
error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey);
} else {
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index 81a7fb7f99..72cb0670de 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -105,7 +105,7 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
setup_logging("regtree", True);
if (remote) {
- error = reg_open_remote(&h, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), remote);
+ error = reg_open_remote(&h, cmdline_credentials, remote);
} else if (backend) {
error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &root);
} else {