X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source%2Fpython%2Fpy_common.c;h=d4230998ddd02f4f10cbaaa6b7359ff3c55df0ac;hb=ba8c48244e140403b728d9a2ca297b40e8888964;hp=e21858e07226f47911396ba5ce3879f147bd7f91;hpb=fff081d3440373071d8859b7a7d71cf6489126a4;p=samba.git diff --git a/source/python/py_common.c b/source/python/py_common.c index e21858e0722..d4230998ddd 100644 --- a/source/python/py_common.c +++ b/source/python/py_common.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,14 +14,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ -#include "includes.h" -#include "Python.h" - -#include "python/py_common_proto.h" +#include "python/py_common.h" /* Return a tuple of (error code, error string) from a WERROR */ @@ -45,25 +41,20 @@ static BOOL initialised; void py_samba_init(void) { - extern pstring global_myname; - char *p; - if (initialised) return; + load_case_tables(); + /* Load configuration file */ - if (!lp_load(dyn_CONFIGFILE, True, False, False)) + if (!lp_load(dyn_CONFIGFILE, True, False, False, True)) fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE); /* Misc other stuff */ load_interfaces(); - - fstrcpy(global_myname, myhostname()); - p = strchr(global_myname, '.'); - if (p) - *p = 0; + init_names(); initialised = True; } @@ -154,34 +145,34 @@ BOOL py_parse_creds(PyObject *creds, char **username, char **domain, password_obj = PyDict_GetItemString(creds, "password"); if (!username_obj) { - *errstr = strdup("no username field in credential"); + *errstr = SMB_STRDUP("no username field in credential"); return False; } if (!domain_obj) { - *errstr = strdup("no domain field in credential"); + *errstr = SMB_STRDUP("no domain field in credential"); return False; } if (!password_obj) { - *errstr = strdup("no password field in credential"); + *errstr = SMB_STRDUP("no password field in credential"); return False; } /* Check type of required fields */ if (!PyString_Check(username_obj)) { - *errstr = strdup("username field is not string type"); + *errstr = SMB_STRDUP("username field is not string type"); return False; } if (!PyString_Check(domain_obj)) { - *errstr = strdup("domain field is not string type"); + *errstr = SMB_STRDUP("domain field is not string type"); return False; } if (!PyString_Check(password_obj)) { - *errstr = strdup("password field is not string type"); + *errstr = SMB_STRDUP("password field is not string type"); return False; } @@ -218,10 +209,11 @@ BOOL py_parse_creds(PyObject *creds, char **username, char **domain, be freed by calling free(). */ struct cli_state *open_pipe_creds(char *server, PyObject *creds, - char *pipe_name, char **errstr) + int pipe_idx, char **errstr) { char *username, *password, *domain; struct cli_state *cli; + struct rpc_pipe_client *pipe_hnd; NTSTATUS result; /* Extract credentials from the python dictionary */ @@ -233,17 +225,17 @@ struct cli_state *open_pipe_creds(char *server, PyObject *creds, result = cli_full_connection( &cli, NULL, server, NULL, 0, "IPC$", "IPC", - username, domain, password, 0); + username, domain, password, 0, Undefined, NULL); if (!NT_STATUS_IS_OK(result)) { - *errstr = strdup("error connecting to IPC$ pipe"); + *errstr = SMB_STRDUP("error connecting to IPC$ pipe"); return NULL; } - if (!cli_nt_session_open(cli, pipe_name)) { + pipe_hnd = cli_rpc_pipe_open_noauth(cli, pipe_idx, &result); + if (!pipe_hnd) { cli_shutdown(cli); - free(cli); - asprintf(errstr, "error opening %s", pipe_name); + asprintf(errstr, "error opening pipe index %d", pipe_idx); return NULL; }