return Py_None;
}
+/* Return a cli_state to a RPC pipe on the given server. Use the
+ credentials passed if not NULL. Set an exception and return NULL if
+ there was an error creating the connection. */
+
struct cli_state *open_pipe_creds(char *system_name, PyObject *creds,
- cli_pipe_fn *connect_fn,
- struct cli_state *cli)
+ cli_pipe_fn *connect_fn)
{
struct ntuser_creds nt_creds;
-
+ struct cli_state *cli;
+
+ cli = (struct cli_state *)malloc(sizeof(struct cli_state));
if (!cli) {
- cli = (struct cli_state *)malloc(sizeof(struct cli_state));
- if (!cli)
- return NULL;
+ PyErr_SetString(PyExc_RuntimeError, "out of memory");
+ return NULL;
}
ZERO_STRUCTP(cli);
password_obj = PyDict_GetItemString(creds, "password");
if (!username_obj || !domain_obj || !password_obj) {
- error:
+ creds_error:
/* TODO: Either pass in the exception for the
module calling open_pipe_creds() or have a
if (!PyString_Check(username_obj) ||
!PyString_Check(domain_obj) ||
!PyString_Check(password_obj))
- goto error;
+ goto creds_error;
username = PyString_AsString(username_obj);
domain = PyString_AsString(domain_obj);
password = PyString_AsString(password_obj);
if (!username || !domain || !password)
- goto error;
+ goto creds_error;
/* Initialise nt_creds structure with passed creds */
#include "includes.h"
-/* Return a cli_state struct opened on the SPOOLSS pipe. If credentials
+/* Return a cli_state struct opened on the specified pipe. If credentials
are passed use them. */
typedef struct cli_state *(cli_pipe_fn)(
PyObject *set_debuglevel(PyObject *self, PyObject *args);
PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw);
struct cli_state *open_pipe_creds(char *system_name, PyObject *creds,
- cli_pipe_fn *connect_fn,
- struct cli_state *cli);
+ cli_pipe_fn *connect_fn);
/* The following definitions come from python/py_ntsec.c */
&creds, &desired_access))
return NULL;
- if (!(cli = open_pipe_creds(server_name, creds, cli_lsa_initialise,
- NULL))) {
+ if (!(cli = open_pipe_creds(server_name, creds, cli_lsa_initialise))) {
fprintf(stderr, "could not initialise cli state\n");
return NULL;
}
&creds, &desired_access))
return NULL;
- if (!(cli = open_pipe_creds(server_name, creds, cli_samr_initialise,
- NULL))) {
-
- /* Error state set in open_pipe_creds() */
-
+ if (!(cli = open_pipe_creds(server_name, creds, cli_samr_initialise)))
goto done;
- }
if (!(mem_ctx = talloc_init())) {
PyErr_SetString(samr_ntstatus,
static char *kwlist[] = {"server", "creds", "level", "arch", NULL};
struct cli_state *cli = NULL;
TALLOC_CTX *mem_ctx = NULL;
-
+
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|O!is", kwlist,
/* Call rpc function */
- if (!(cli = open_pipe_creds(server_name, creds,
- cli_spoolss_initialise, NULL))) {
+ if (!(cli = open_pipe_creds(
+ server_name, creds, cli_spoolss_initialise))) {
fprintf(stderr, "could not initialise cli state\n");
goto done;
}
/* Call rpc function */
- if (!(cli = open_pipe_creds(server_name, creds,
- cli_spoolss_initialise, NULL))) {
+ if (!(cli = open_pipe_creds(
+ server_name, creds, cli_spoolss_initialise))) {
fprintf(stderr, "could not initialise cli state\n");
goto done;
}
-
+
if (!(mem_ctx = talloc_init())) {
fprintf(stderr, "unable to initialise talloc context\n");
goto done;
mem_ctx = talloc_init();
- if (!(cli = open_pipe_creds(server, creds, cli_spoolss_initialise,
- NULL)))
+ if (!(cli = open_pipe_creds(server, creds, cli_spoolss_initialise)))
goto done;
if ((level_obj = PyDict_GetItemString(info, "level"))) {
PyErr_SetString(spoolss_error, "no info level present");
goto done;
}
-
+
ZERO_STRUCT(ctr);
-
+
switch(level) {
case 3:
ctr.info3 = &dinfo.driver_3;
done:
cli_shutdown(cli);
talloc_destroy(mem_ctx);
-
+
return result;
+
}
PyObject *spoolss_addprinterdriverex(PyObject *self, PyObject *args,
- PyObject *kw)
+ PyObject *kw)
{
/* Not supported by Samba server */
-
+
PyErr_SetString(spoolss_error, "Not implemented");
return NULL;
}
-
+
PyObject *spoolss_deleteprinterdriver(PyObject *self, PyObject *args,
PyObject *kw)
{
server += 2;
mem_ctx = talloc_init();
- cli = open_pipe_creds(server, creds, cli_spoolss_initialise, NULL);
+ cli = open_pipe_creds(server, creds, cli_spoolss_initialise);
/* Call rpc function */
*c = 0;
}
- if (!(cli = open_pipe_creds(computer_name, creds,
- cli_spoolss_initialise, NULL))) {
-
- /* Error state set in open_pipe_creds() */
-
+ if (!(cli = open_pipe_creds(
+ computer_name, creds, cli_spoolss_initialise)))
goto done;
- }
if (!(mem_ctx = talloc_init())) {
PyErr_SetString(spoolss_error,
server += 2;
mem_ctx = talloc_init();
- cli = open_pipe_creds(server, creds, cli_spoolss_initialise, NULL);
+ cli = open_pipe_creds(server, creds, cli_spoolss_initialise);
/* Call rpc function */
&PyDict_Type, &info, &PyDict_Type, &creds))
return NULL;
- if (!(cli = open_pipe_creds(server, creds,
- cli_spoolss_initialise, NULL)))
+ if (!(cli = open_pipe_creds(
+ server, creds, cli_spoolss_initialise)))
goto done;
mem_ctx = talloc_init();
- if (!(cli = open_pipe_creds(server, creds, cli_spoolss_initialise,
- NULL)))
+ if (!(cli = open_pipe_creds(server, creds, cli_spoolss_initialise)))
goto done;
if (!py_to_PRINTER_INFO_2(&info2, info, mem_ctx)) {