summaryrefslogtreecommitdiffstats
path: root/source/rpc_client
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2000-07-18 05:07:28 +0000
committerGerald Carter <jerry@samba.org>2000-07-18 05:07:28 +0000
commit84349394a988213724ca138e9692b3bc44fa0cb8 (patch)
tree3e0118d5d16e7feda55cb75b5b7eb14cde97db0a /source/rpc_client
parent15b35912713557119aba5d0cd59605997d6b5ee9 (diff)
downloadsamba-84349394a988213724ca138e9692b3bc44fa0cb8.tar.gz
samba-84349394a988213724ca138e9692b3bc44fa0cb8.tar.xz
samba-84349394a988213724ca138e9692b3bc44fa0cb8.zip
Fixed some more client SPOOLSS functions. The following
functions work now: - spoolenum - spoolopen - spoolgetprinter - spoolgetprinterdriver Items todo: - track down memory bug with spoolenumdata - fix spoolgetprinterdriverdir - fix spoolgetdata - fix display_job_info_ctr in spooljobs All part of the rpcclient work. Jeremy, this check includes emthods for associating POLICY_HNDs and client states. See the RpcHndList_...() function calls (implemented in lib/util_list.c) --jerry
Diffstat (limited to 'source/rpc_client')
-rw-r--r--source/rpc_client/cli_connect.c51
-rw-r--r--source/rpc_client/cli_spoolss.c70
-rw-r--r--source/rpc_client/msrpc_spoolss.c35
3 files changed, 80 insertions, 76 deletions
diff --git a/source/rpc_client/cli_connect.c b/source/rpc_client/cli_connect.c
index e34968987e1..16279488e82 100644
--- a/source/rpc_client/cli_connect.c
+++ b/source/rpc_client/cli_connect.c
@@ -26,19 +26,6 @@
#include "rpc_parse.h"
#include "rpc_client.h"
-struct cli_connection
-{
- uint32 num_connections;
- char *srv_name;
- char *pipe_name;
- struct user_creds usr_creds;
-
- struct cli_state *pCli_state;
-
- cli_auth_fns *auth;
- void *auth_info;
- void *auth_creds;
-};
static struct cli_connection **con_list = NULL;
static uint32 num_cons = 0;
@@ -48,6 +35,31 @@ vuser_key *user_key = NULL;
extern int DEBUGLEVEL;
extern pstring global_myname;
+/*
+ * needed for the struct cli_connection
+ * none of these functions are implemented in HEAD currently
+ * rpc_client/cli_connect.c for details
+ *
+ * the 'typedef struct _cli_auth_fns cli_auth_fns;' is in
+ * rpc_misc.h
+ */
+struct _cli_auth_fns {
+
+ /* these three will do for now. they *should* match with server-side */
+ BOOL (*create_bind_req) (struct cli_connection *, prs_struct *,
+ uint32, RPC_IFACE *, RPC_IFACE *);
+ BOOL (*decode_bind_resp) (struct cli_connection *, prs_struct *);
+ BOOL (*create_bind_cont) (struct cli_connection *, prs_struct *, uint32);
+
+ /* creates an authenticated PDU */
+ BOOL (*cli_create_pdu) (struct cli_connection *, uint8, prs_struct *,
+ int, int *, prs_struct *, uint8 *);
+
+ /* decodes an authenticated PDU */
+ BOOL (*cli_decode_pdu) (struct cli_connection *, prs_struct *, int, int);
+
+};
+
cli_auth_fns cli_noauth_fns =
{
NULL,
@@ -139,6 +151,9 @@ static struct cli_connection *cli_con_get(const char *srv_name,
pNcacn = ncacn_np_use_add(pipe_name, user_key, srv_name,
ntc, reuse,
&is_new_connection);
+ if (pNcacn == NULL)
+ return NULL;
+
con->pCli_state = pNcacn->smb;
if (con->pCli_state == NULL)
@@ -310,7 +325,7 @@ BOOL cli_connection_init_auth(const char *srv_name, const char *pipe_name,
/****************************************************************************
get auth functions associated with an msrpc session.
****************************************************************************/
-struct cli_auth_fns *cli_conn_get_authfns(struct cli_connection *con)
+struct _cli_auth_fns *cli_conn_get_authfns(struct cli_connection *con)
{
return con != NULL ? con->auth : NULL;
}
@@ -333,17 +348,11 @@ BOOL rpc_hnd_pipe_req(const POLICY_HND * hnd, uint8 op_num,
{
struct cli_connection *con = NULL;
-#if 0 /* temporary disable by JERRY */
/* we need this to locate the cli_connection associated
with the POLICY_HND */
- if (!cli_connection_get(hnd, &con))
- {
+ if ((con=RpcHndList_get_connection(hnd)) == NULL)
return False;
- }
-#endif /* temporary disable by JERRY */
- /* always will return False until I fix cli_connection_get()
- --jerry */
if (!rpc_con_ok(con)) return False;
return rpc_con_pipe_req(con, op_num, data, rdata);
diff --git a/source/rpc_client/cli_spoolss.c b/source/rpc_client/cli_spoolss.c
index 2bbfb25bc61..0f89399bebd 100644
--- a/source/rpc_client/cli_spoolss.c
+++ b/source/rpc_client/cli_spoolss.c
@@ -48,8 +48,8 @@ uint32 spoolss_enum_printerdrivers(const char * srv_name,
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
return False;
- prs_init(&buf , 0, 4, False);
- prs_init(&rbuf, 0, 4, True );
+ prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
+ prs_init(&rbuf, 0, 4, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
@@ -176,8 +176,8 @@ uint32 spoolss_enum_jobs(const POLICY_HND *hnd, uint32 firstjob, uint32 numofjob
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , 0, 4, False);
- prs_init(&rbuf, 0, 4, True );
+ prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
+ prs_init(&rbuf, 0, 4, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
@@ -231,8 +231,8 @@ uint32 spoolss_enum_printerdata(const POLICY_HND *hnd, uint32 idx,
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , 0, 4, False);
- prs_init(&rbuf, 0, 4, True );
+ prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
+ prs_init(&rbuf, 0, 4, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
@@ -288,8 +288,8 @@ uint32 spoolss_getprinter(const POLICY_HND *hnd, uint32 level,
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , 0, 4, False);
- prs_init(&rbuf, 0, 4, True );
+ prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
+ prs_init(&rbuf, 0, 4, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
@@ -343,8 +343,8 @@ uint32 spoolss_getprinterdriver(const POLICY_HND *hnd,
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , 0, 4, False);
- prs_init(&rbuf, 0, 4, True );
+ prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
+ prs_init(&rbuf, 0, 4, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
@@ -397,7 +397,7 @@ BOOL spoolss_open_printer_ex( const char *printername,
SPOOL_Q_OPEN_PRINTER_EX q_o;
BOOL valid_pol = False;
fstring srv_name;
- char *s;
+ char *s = NULL;
struct cli_connection *con = NULL;
@@ -405,9 +405,8 @@ BOOL spoolss_open_printer_ex( const char *printername,
fstrcpy(srv_name, printername);
s = strchr(&srv_name[2], '\\');
-
- if (s != NULL)
- *s = 0;
+ if (s != NULL)
+ *s = '\0';
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
return False;
@@ -444,21 +443,15 @@ BOOL spoolss_open_printer_ex( const char *printername,
{
/* ok, at last: we're happy. return the policy handle */
*hnd = r_o.handle;
- valid_pol = True;
-
-#if 0 /* JERRY */
- /* *hnd should be valid at this point */
- valid_pol = register_policy_hnd(get_global_hnd_cache(),
- cli_con_sec_ctx(con),
- hnd, access_required) &&
- set_policy_con(get_global_hnd_cache(),
- hnd, con,
- cli_connection_unlink);
-#endif /* JERRY */
+
+ /* associate the handle returned with the current
+ state of the clienjt connection */
+ valid_pol = RpcHndList_set_connection(hnd, con);
+
}
}
- prs_mem_free(&rbuf);
+ prs_mem_free(&rbuf);
prs_mem_free(&buf );
return valid_pol;
@@ -474,7 +467,8 @@ BOOL spoolss_closeprinter(POLICY_HND *hnd)
SPOOL_Q_CLOSEPRINTER q_c;
BOOL valid_close = False;
- if (hnd == NULL) return False;
+ if (hnd == NULL)
+ return False;
/* create and send a MSRPC command with api SPOOLSS_CLOSEPRINTER */
@@ -499,19 +493,15 @@ BOOL spoolss_closeprinter(POLICY_HND *hnd)
/* report error code */
DEBUG(0,("SPOOL_CLOSEPRINTER: %s\n", get_nt_error_msg(r_c.status)));
}
+ else
+ valid_close = True;
}
prs_mem_free(&rbuf);
prs_mem_free(&buf );
- if ( hnd != NULL )
- {
- free (hnd);
- hnd = NULL;
- }
-
- /* commented out by JERRY - merge from TNG */
- /* close_policy_hnd(get_global_hnd_cache(), hnd); */
+ /* disassociate with the cli_connection */
+ RpcHndList_del_connection(hnd);
return valid_close;
}
@@ -534,8 +524,8 @@ uint32 spoolss_getprinterdata(const POLICY_HND *hnd, const UNISTR2 *valuename,
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , 0, 4, False);
- prs_init(&rbuf, 0, 4, True );
+ prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
+ prs_init(&rbuf, 0, 4, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_GETPRINTERDATA */
@@ -549,7 +539,7 @@ uint32 spoolss_getprinterdata(const POLICY_HND *hnd, const UNISTR2 *valuename,
prs_mem_free(&buf );
}
- if(!rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTERDATA, &buf, &rbuf)) {
+ if (!rpc_hnd_pipe_req(hnd, SPOOLSS_GETPRINTERDATA, &buf, &rbuf)) {
prs_mem_free(&rbuf);
prs_mem_free(&buf );
}
@@ -590,8 +580,8 @@ uint32 spoolss_getprinterdriverdir(fstring srv_name, fstring env_name, uint32 le
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
return False;
- prs_init(&buf , 0, 4, False);
- prs_init(&rbuf, 0, 4, True );
+ prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
+ prs_init(&rbuf, 0, 4, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
diff --git a/source/rpc_client/msrpc_spoolss.c b/source/rpc_client/msrpc_spoolss.c
index be0f59a8fef..d8379048cf4 100644
--- a/source/rpc_client/msrpc_spoolss.c
+++ b/source/rpc_client/msrpc_spoolss.c
@@ -209,21 +209,26 @@ BOOL msrpc_spoolss_enum_printers(char* srv_name, uint32 flags,
if (status!=NT_STATUS_NO_PROBLEMO)
return False;
- switch (level) {
- case 1:
- decode_printer_info_1(&buffer, returned, &(ctr.printers_1));
- break;
- case 2:
- decode_printer_info_2(&buffer, returned, &(ctr.printers_2));
- break;
- case 3:
- decode_printer_info_3(&buffer, returned, &(ctr.printers_3));
- break;
- }
-
- display_printer_info_ctr(out_hnd, ACTION_HEADER , level, returned, ctr);
- display_printer_info_ctr(out_hnd, ACTION_ENUMERATE, level, returned, ctr);
- display_printer_info_ctr(out_hnd, ACTION_FOOTER , level, returned, ctr);
+ /* is there anything to process? */
+ if (returned != 0)
+ {
+ switch (level) {
+ case 1:
+ decode_printer_info_1(&buffer, returned, &(ctr.printers_1));
+ break;
+ case 2:
+ decode_printer_info_2(&buffer, returned, &(ctr.printers_2));
+ break;
+ case 3:
+ decode_printer_info_3(&buffer, returned, &(ctr.printers_3));
+ break;
+ }
+
+ display_printer_info_ctr(out_hnd, ACTION_HEADER , level, returned, ctr);
+ display_printer_info_ctr(out_hnd, ACTION_ENUMERATE, level, returned, ctr);
+ display_printer_info_ctr(out_hnd, ACTION_FOOTER , level, returned, ctr);
+ }
+
return True;
}