mirror of
https://github.com/samba-team/samba.git
synced 2025-07-31 20:22:15 +03:00
s4-libnet: Remove libnet_Join and create libnet_Join_member
libnet_Join conflicts with a function in the source3 netapi of the same name, and the ability to join as a DC via this particular method is unused. Andrew Bartlett
This commit is contained in:
@ -889,9 +889,9 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
|
NTSTATUS libnet_Join_member(struct libnet_context *ctx,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
struct libnet_Join *r)
|
struct libnet_Join_member *r)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
TALLOC_CTX *tmp_mem;
|
TALLOC_CTX *tmp_mem;
|
||||||
@ -916,15 +916,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
|
|||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->in.join_type == SEC_CHAN_BDC) {
|
acct_type = ACB_WSTRUST;
|
||||||
acct_type = ACB_SVRTRUST;
|
|
||||||
} else if (r->in.join_type == SEC_CHAN_WKSTA) {
|
|
||||||
acct_type = ACB_WSTRUST;
|
|
||||||
} else {
|
|
||||||
r->out.error_string = NULL;
|
|
||||||
talloc_free(tmp_mem);
|
|
||||||
return NT_STATUS_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r->in.netbios_name != NULL) {
|
if (r->in.netbios_name != NULL) {
|
||||||
netbios_name = r->in.netbios_name;
|
netbios_name = r->in.netbios_name;
|
||||||
@ -972,7 +964,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
|
|||||||
set_secrets->domain_name = r2->out.domain_name;
|
set_secrets->domain_name = r2->out.domain_name;
|
||||||
set_secrets->realm = r2->out.realm;
|
set_secrets->realm = r2->out.realm;
|
||||||
set_secrets->netbios_name = netbios_name;
|
set_secrets->netbios_name = netbios_name;
|
||||||
set_secrets->secure_channel_type = r->in.join_type;
|
set_secrets->secure_channel_type = SEC_CHAN_WKSTA;
|
||||||
set_secrets->machine_password = r2->out.join_password;
|
set_secrets->machine_password = r2->out.join_password;
|
||||||
set_secrets->key_version_number = r2->out.kvno;
|
set_secrets->key_version_number = r2->out.kvno;
|
||||||
set_secrets->domain_sid = r2->out.domain_sid;
|
set_secrets->domain_sid = r2->out.domain_sid;
|
||||||
@ -996,21 +988,3 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
|
|||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS libnet_Join(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_Join *r)
|
|
||||||
{
|
|
||||||
switch (r->in.join_type) {
|
|
||||||
case SEC_CHAN_WKSTA:
|
|
||||||
return libnet_Join_primary_domain(ctx, mem_ctx, r);
|
|
||||||
case SEC_CHAN_BDC:
|
|
||||||
return libnet_Join_primary_domain(ctx, mem_ctx, r);
|
|
||||||
case SEC_CHAN_DOMAIN:
|
|
||||||
case SEC_CHAN_DNS_DOMAIN:
|
|
||||||
case SEC_CHAN_NULL:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
r->out.error_string = talloc_asprintf(mem_ctx,
|
|
||||||
"Invalid join type specified (%08X) attempting to join domain %s",
|
|
||||||
r->in.join_type, r->in.domain_name);
|
|
||||||
return NT_STATUS_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
@ -63,11 +63,10 @@ struct libnet_JoinDomain {
|
|||||||
} out;
|
} out;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libnet_Join {
|
struct libnet_Join_member {
|
||||||
struct {
|
struct {
|
||||||
const char *domain_name;
|
const char *domain_name;
|
||||||
const char *netbios_name;
|
const char *netbios_name;
|
||||||
enum netr_SchannelType join_type;
|
|
||||||
enum libnet_Join_level level;
|
enum libnet_Join_level level;
|
||||||
} in;
|
} in;
|
||||||
|
|
||||||
|
@ -41,17 +41,17 @@ typedef struct {
|
|||||||
struct tevent_context *ev;
|
struct tevent_context *ev;
|
||||||
} py_net_Object;
|
} py_net_Object;
|
||||||
|
|
||||||
static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwargs)
|
static PyObject *py_net_join_member(py_net_Object *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
struct libnet_Join r;
|
struct libnet_Join_member r;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
TALLOC_CTX *mem_ctx;
|
TALLOC_CTX *mem_ctx;
|
||||||
const char *kwnames[] = { "domain_name", "netbios_name", "join_type", "level", NULL };
|
const char *kwnames[] = { "domain_name", "netbios_name", "level", NULL };
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssii:Join", discard_const_p(char *, kwnames),
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssi:Join", discard_const_p(char *, kwnames),
|
||||||
&r.in.domain_name, &r.in.netbios_name,
|
&r.in.domain_name, &r.in.netbios_name,
|
||||||
&r.in.join_type, &r.in.level))
|
&r.in.level))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
mem_ctx = talloc_new(self->mem_ctx);
|
mem_ctx = talloc_new(self->mem_ctx);
|
||||||
@ -60,7 +60,7 @@ static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwar
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = libnet_Join(self->libnet_ctx, mem_ctx, &r);
|
status = libnet_Join_member(self->libnet_ctx, mem_ctx, &r);
|
||||||
if (NT_STATUS_IS_ERR(status)) {
|
if (NT_STATUS_IS_ERR(status)) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
|
PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
|
||||||
talloc_free(mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
@ -76,7 +76,7 @@ static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char py_net_join_doc[] = "join(domain_name, netbios_name, join_type, level) -> (join_password, domain_sid, domain_name)\n\n" \
|
static const char py_net_join_member_doc[] = "join_member(domain_name, netbios_name, level) -> (join_password, domain_sid, domain_name)\n\n" \
|
||||||
"Join the domain with the specified name.";
|
"Join the domain with the specified name.";
|
||||||
|
|
||||||
static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObject *kwargs)
|
static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObject *kwargs)
|
||||||
@ -526,7 +526,7 @@ static const char py_net_finddc_doc[] = "finddc(domain, server_type)\n"
|
|||||||
"find a DC with the specified server_type bits. Return the DNS name";
|
"find a DC with the specified server_type bits. Return the DNS name";
|
||||||
|
|
||||||
static PyMethodDef net_obj_methods[] = {
|
static PyMethodDef net_obj_methods[] = {
|
||||||
{"join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS, py_net_join_doc},
|
{"join_member", (PyCFunction)py_net_join_member, METH_VARARGS|METH_KEYWORDS, py_net_join_member_doc},
|
||||||
{"set_password", (PyCFunction)py_net_set_password, METH_VARARGS|METH_KEYWORDS, py_net_set_password_doc},
|
{"set_password", (PyCFunction)py_net_set_password, METH_VARARGS|METH_KEYWORDS, py_net_set_password_doc},
|
||||||
{"export_keytab", (PyCFunction)py_net_export_keytab, METH_VARARGS|METH_KEYWORDS, py_net_export_keytab_doc},
|
{"export_keytab", (PyCFunction)py_net_export_keytab, METH_VARARGS|METH_KEYWORDS, py_net_export_keytab_doc},
|
||||||
{"time", (PyCFunction)py_net_time, METH_VARARGS|METH_KEYWORDS, py_net_time_doc},
|
{"time", (PyCFunction)py_net_time, METH_VARARGS|METH_KEYWORDS, py_net_time_doc},
|
||||||
|
@ -59,7 +59,13 @@ class cmd_join(Command):
|
|||||||
role = role.upper()
|
role = role.upper()
|
||||||
|
|
||||||
if role is None or role == "MEMBER":
|
if role is None or role == "MEMBER":
|
||||||
secure_channel_type = SEC_CHAN_WKSTA
|
(join_password, sid, domain_name) = net.join_member(domain,
|
||||||
|
netbios_name,
|
||||||
|
LIBNET_JOIN_AUTOMATIC)
|
||||||
|
|
||||||
|
self.outf.write("Joined domain %s (%s)\n" % (domain_name, sid))
|
||||||
|
return
|
||||||
|
|
||||||
elif role == "DC":
|
elif role == "DC":
|
||||||
join_DC(server=server, creds=creds, lp=lp, domain=domain,
|
join_DC(server=server, creds=creds, lp=lp, domain=domain,
|
||||||
site=site, netbios_name=netbios_name, targetdir=targetdir)
|
site=site, netbios_name=netbios_name, targetdir=targetdir)
|
||||||
@ -70,10 +76,3 @@ class cmd_join(Command):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
raise CommandError("Invalid role %s (possible values: MEMBER, BDC, RODC)" % role)
|
raise CommandError("Invalid role %s (possible values: MEMBER, BDC, RODC)" % role)
|
||||||
|
|
||||||
(join_password, sid, domain_name) = net.join(domain,
|
|
||||||
netbios_name,
|
|
||||||
secure_channel_type,
|
|
||||||
LIBNET_JOIN_AUTOMATIC)
|
|
||||||
|
|
||||||
self.outf.write("Joined domain %s (%s)\n" % (domain_name, sid))
|
|
||||||
|
Reference in New Issue
Block a user