1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-12 01:49:28 +03:00

Refactored open_pipe_creds() function to remove unused parameter.

This commit is contained in:
Tim Potter
-
parent e4cc7e2d52
commit 36ed06cb50
8 changed files with 38 additions and 46 deletions

View File

@ -118,16 +118,20 @@ PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw)
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);
@ -151,7 +155,7 @@ struct cli_state *open_pipe_creds(char *system_name, PyObject *creds,
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
@ -165,14 +169,14 @@ struct cli_state *open_pipe_creds(char *system_name, PyObject *creds,
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 */

View File

@ -23,7 +23,7 @@
#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)(

View File

@ -13,8 +13,7 @@ PyObject *get_debuglevel(PyObject *self, PyObject *args);
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 */

View File

@ -66,8 +66,7 @@ static PyObject *lsa_open_policy(PyObject *self, PyObject *args,
&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;
}

View File

@ -287,13 +287,8 @@ static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
&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,

View File

@ -34,7 +34,7 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args,
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,
@ -44,8 +44,8 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args,
/* 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;
}
@ -244,12 +244,12 @@ PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args,
/* 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;
@ -311,8 +311,7 @@ PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args,
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"))) {
@ -337,9 +336,9 @@ PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args,
PyErr_SetString(spoolss_error, "no info level present");
goto done;
}
ZERO_STRUCT(ctr);
switch(level) {
case 3:
ctr.info3 = &dinfo.driver_3;
@ -369,19 +368,20 @@ PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args,
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)
{

View File

@ -45,7 +45,7 @@ PyObject *spoolss_enumports(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 */

View File

@ -50,13 +50,9 @@ PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw)
*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,
@ -294,7 +290,7 @@ PyObject *spoolss_enumprinters(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 */
@ -386,14 +382,13 @@ PyObject *spoolss_addprinterex(PyObject *self, PyObject *args, PyObject *kw)
&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)) {