summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-05-27 06:32:11 +0000
committerTim Potter <tpot@samba.org>2002-05-27 06:32:11 +0000
commitf2cbcec5a4cd6dc6656b4966450c211be3ec451b (patch)
treebc04fafe4b0dfd0a86e280180d99c2f9b75720eb
parentbf7ca61cb4af4b156d954098ffa04cfa14a25641 (diff)
downloadsamba-f2cbcec5a4cd6dc6656b4966450c211be3ec451b.tar.gz
samba-f2cbcec5a4cd6dc6656b4966450c211be3ec451b.tar.bz2
samba-f2cbcec5a4cd6dc6656b4966450c211be3ec451b.zip
Convert open_pipe_creds() to use new cli_full_connection() interface.
Initialise global_myname in py_samba_init() function. (This used to be commit e5dcd3c7ccf0060d86a484b8307f747805b20c5f)
-rw-r--r--source3/python/py_common.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/source3/python/py_common.c b/source3/python/py_common.c
index 85305d027e..d81e141e9c 100644
--- a/source3/python/py_common.c
+++ b/source3/python/py_common.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "Python.h"
-#include "python/py_common.h"
+#include "python/py_common_proto.h"
/* Return a tuple of (error code, error string) from a WERROR */
@@ -45,6 +45,9 @@ static BOOL initialised;
void py_samba_init(void)
{
+ extern pstring global_myname;
+ char *p;
+
if (initialised)
return;
@@ -57,6 +60,11 @@ void py_samba_init(void)
load_interfaces();
+ fstrcpy(global_myname, myhostname());
+ p = strchr(global_myname, '.');
+ if (p)
+ *p = 0;
+
initialised = True;
}
@@ -124,27 +132,17 @@ PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw)
be freed by calling free(). */
struct cli_state *open_pipe_creds(char *server, PyObject *creds,
- cli_pipe_fn *connect_fn, char **errstr)
+ char *pipe_name, char **errstr)
{
- struct ntuser_creds nt_creds;
+ char *username = "", *password = "", *domain = "";
struct cli_state *cli;
+ NTSTATUS result;
+ struct in_addr server_ip;
+ extern pstring global_myname;
- cli = (struct cli_state *)malloc(sizeof(struct cli_state));
- if (!cli) {
- *errstr = strdup("out of memory");
- return NULL;
- }
-
- ZERO_STRUCTP(cli);
-
- /* Extract credentials from the python dictionary and initialise
- the ntuser_creds struct from them. */
-
- ZERO_STRUCT(nt_creds);
- nt_creds.pwd.null_pwd = True;
+ /* Extract credentials from the python dictionary */
if (creds && PyDict_Size(creds) > 0) {
- char *username, *password, *domain;
PyObject *username_obj, *password_obj, *domain_obj;
/* Check credentials passed are valid. This means the
@@ -172,24 +170,23 @@ struct cli_state *open_pipe_creds(char *server, PyObject *creds,
if (!username || !domain || !password)
goto creds_error;
-
- /* Initialise nt_creds structure with passed creds */
-
- fstrcpy(nt_creds.user_name, username);
- fstrcpy(nt_creds.domain, domain);
-
- if (lp_encrypted_passwords())
- pwd_make_lm_nt_16(&nt_creds.pwd, password);
- else
- pwd_set_cleartext(&nt_creds.pwd, password);
-
- nt_creds.pwd.null_pwd = False;
}
/* Now try to connect */
- if (!connect_fn(cli, server, &nt_creds)) {
- *errstr = strdup("error connecting to RPC pipe");
+ if (!resolve_name(server, &server_ip, 0x20)) {
+ asprintf(errstr, "unable to resolve %s", server);
+ return NULL;
+ }
+
+ result = cli_full_connection(
+ &cli, global_myname, server, &server_ip, 0, "IPC$", "IPC",
+ username, domain, password, strlen(password));
+
+ if (!NT_STATUS_IS_OK(result) || !cli_nt_session_open(cli, pipe_name)) {
+ cli_shutdown(cli);
+ free(cli);
+ *errstr = strdup("pipe not available");
return NULL;
}