summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-03-08 16:16:11 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-03-08 16:16:11 +1100
commit6ac77d19b5a25a53459a58e4828fa9eac0bf11f4 (patch)
treebb504eecdcb94d6c82b522f5de0fd13de130fb41 /source3/rpc_server
parentbb6a2c8076e5e9eabad4ee7f09f6df979616fd13 (diff)
parent46bcb10b5abb21758cf234764b64220ede1b7ab5 (diff)
downloadsamba-6ac77d19b5a25a53459a58e4828fa9eac0bf11f4.tar.gz
samba-6ac77d19b5a25a53459a58e4828fa9eac0bf11f4.tar.bz2
samba-6ac77d19b5a25a53459a58e4828fa9eac0bf11f4.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba into wspp-schema
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_pipe.c6
-rw-r--r--source3/rpc_server/srv_samr_nt.c94
-rw-r--r--source3/rpc_server/srv_spoolss.c110
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c726
4 files changed, 405 insertions, 531 deletions
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index 09b1f66440..f3ee18da5a 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -2113,7 +2113,11 @@ bool api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss
auth_len = p->hdr.auth_len;
- if (auth_len != RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) {
+ if (auth_len < RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN ||
+ auth_len > RPC_HEADER_LEN +
+ RPC_HDR_REQ_LEN +
+ RPC_HDR_AUTH_LEN +
+ auth_len) {
DEBUG(0,("Incorrect auth_len %u.\n", (unsigned int)auth_len ));
return False;
}
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 0b8cb35a84..1128a856cd 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -319,8 +319,8 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid)
* enumerate stuff, so just cache 2 entries.
*/
- static struct disp_info builtin_dispinfo;
- static struct disp_info domain_dispinfo;
+ static struct disp_info *builtin_dispinfo;
+ static struct disp_info *domain_dispinfo;
/* There are two cases to consider here:
1) The SID is a domain SID and we look for an equality match, or
@@ -335,18 +335,32 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid)
/*
* Necessary only once, but it does not really hurt.
*/
- sid_copy(&builtin_dispinfo.sid, &global_sid_Builtin);
+ if (builtin_dispinfo == NULL) {
+ builtin_dispinfo = talloc_zero(
+ talloc_autofree_context(), struct disp_info);
+ if (builtin_dispinfo == NULL) {
+ return NULL;
+ }
+ }
+ sid_copy(&builtin_dispinfo->sid, &global_sid_Builtin);
- return &builtin_dispinfo;
+ return builtin_dispinfo;
}
if (sid_check_is_domain(psid) || sid_check_is_in_our_domain(psid)) {
/*
* Necessary only once, but it does not really hurt.
*/
- sid_copy(&domain_dispinfo.sid, get_global_sam_sid());
+ if (domain_dispinfo == NULL) {
+ domain_dispinfo = talloc_zero(
+ talloc_autofree_context(), struct disp_info);
+ if (domain_dispinfo == NULL) {
+ return NULL;
+ }
+ }
+ sid_copy(&domain_dispinfo->sid, get_global_sam_sid());
- return &domain_dispinfo;
+ return domain_dispinfo;
}
return NULL;
@@ -403,32 +417,11 @@ static void free_samr_cache(DISP_INFO *disp_info)
become_root();
- if (disp_info->users) {
- DEBUG(10,("free_samr_cache: deleting users cache\n"));
- pdb_search_destroy(disp_info->users);
- disp_info->users = NULL;
- }
- if (disp_info->machines) {
- DEBUG(10,("free_samr_cache: deleting machines cache\n"));
- pdb_search_destroy(disp_info->machines);
- disp_info->machines = NULL;
- }
- if (disp_info->groups) {
- DEBUG(10,("free_samr_cache: deleting groups cache\n"));
- pdb_search_destroy(disp_info->groups);
- disp_info->groups = NULL;
- }
- if (disp_info->aliases) {
- DEBUG(10,("free_samr_cache: deleting aliases cache\n"));
- pdb_search_destroy(disp_info->aliases);
- disp_info->aliases = NULL;
- }
- if (disp_info->enum_users) {
- DEBUG(10,("free_samr_cache: deleting enum_users cache\n"));
- pdb_search_destroy(disp_info->enum_users);
- disp_info->enum_users = NULL;
- }
- disp_info->enum_acb_mask = 0;
+ TALLOC_FREE(disp_info->users);
+ TALLOC_FREE(disp_info->machines);
+ TALLOC_FREE(disp_info->groups);
+ TALLOC_FREE(disp_info->aliases);
+ TALLOC_FREE(disp_info->enum_users);
unbecome_root();
}
@@ -524,7 +517,7 @@ static uint32 count_sam_users(struct disp_info *info, uint32 acct_flags)
}
if (info->users == NULL) {
- info->users = pdb_search_users(acct_flags);
+ info->users = pdb_search_users(info, acct_flags);
if (info->users == NULL) {
return 0;
}
@@ -548,7 +541,7 @@ static uint32 count_sam_groups(struct disp_info *info)
}
if (info->groups == NULL) {
- info->groups = pdb_search_groups();
+ info->groups = pdb_search_groups(info);
if (info->groups == NULL) {
return 0;
}
@@ -567,7 +560,7 @@ static uint32 count_sam_aliases(struct disp_info *info)
struct samr_displayentry *entry;
if (info->aliases == NULL) {
- info->aliases = pdb_search_aliases(&info->sid);
+ info->aliases = pdb_search_aliases(info, &info->sid);
if (info->aliases == NULL) {
return 0;
}
@@ -1012,12 +1005,12 @@ NTSTATUS _samr_EnumDomainUsers(pipes_struct *p,
if ((info->disp_info->enum_users != NULL) &&
(info->disp_info->enum_acb_mask != r->in.acct_flags)) {
- pdb_search_destroy(info->disp_info->enum_users);
- info->disp_info->enum_users = NULL;
+ TALLOC_FREE(info->disp_info->enum_users);
}
if (info->disp_info->enum_users == NULL) {
- info->disp_info->enum_users = pdb_search_users(r->in.acct_flags);
+ info->disp_info->enum_users = pdb_search_users(
+ info->disp_info, r->in.acct_flags);
info->disp_info->enum_acb_mask = r->in.acct_flags;
}
@@ -1149,7 +1142,7 @@ NTSTATUS _samr_EnumDomainGroups(pipes_struct *p,
become_root();
if (info->disp_info->groups == NULL) {
- info->disp_info->groups = pdb_search_groups();
+ info->disp_info->groups = pdb_search_groups(info->disp_info);
if (info->disp_info->groups == NULL) {
unbecome_root();
@@ -1216,7 +1209,8 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p,
become_root();
if (info->disp_info->aliases == NULL) {
- info->disp_info->aliases = pdb_search_aliases(&info->sid);
+ info->disp_info->aliases = pdb_search_aliases(
+ info->disp_info, &info->sid);
if (info->disp_info->aliases == NULL) {
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
@@ -1547,7 +1541,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p,
case 0x1:
case 0x4:
if (info->disp_info->users == NULL) {
- info->disp_info->users = pdb_search_users(ACB_NORMAL);
+ info->disp_info->users = pdb_search_users(
+ info->disp_info, ACB_NORMAL);
if (info->disp_info->users == NULL) {
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
@@ -1565,8 +1560,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p,
break;
case 0x2:
if (info->disp_info->machines == NULL) {
- info->disp_info->machines =
- pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST);
+ info->disp_info->machines = pdb_search_users(
+ info->disp_info, ACB_WSTRUST|ACB_SVRTRUST);
if (info->disp_info->machines == NULL) {
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
@@ -1585,7 +1580,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p,
case 0x3:
case 0x5:
if (info->disp_info->groups == NULL) {
- info->disp_info->groups = pdb_search_groups();
+ info->disp_info->groups = pdb_search_groups(
+ info->disp_info);
if (info->disp_info->groups == NULL) {
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
@@ -5632,7 +5628,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p,
switch (r->in.level) {
case 1:
if (info->disp_info->users == NULL) {
- info->disp_info->users = pdb_search_users(ACB_NORMAL);
+ info->disp_info->users = pdb_search_users(
+ info->disp_info, ACB_NORMAL);
if (info->disp_info->users == NULL) {
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
@@ -5651,8 +5648,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p,
break;
case 2:
if (info->disp_info->machines == NULL) {
- info->disp_info->machines =
- pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST);
+ info->disp_info->machines = pdb_search_users(
+ info->disp_info, ACB_WSTRUST|ACB_SVRTRUST);
if (info->disp_info->machines == NULL) {
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
@@ -5671,7 +5668,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p,
break;
case 3:
if (info->disp_info->groups == NULL) {
- info->disp_info->groups = pdb_search_groups();
+ info->disp_info->groups = pdb_search_groups(
+ info->disp_info);
if (info->disp_info->groups == NULL) {
unbecome_root();
return NT_STATUS_ACCESS_DENIED;
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index ee36f04c6d..616eb1dbf0 100644
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -431,27 +431,7 @@ static bool api_spoolss_getform(pipes_struct *p)
static bool api_spoolss_enumforms(pipes_struct *p)
{
- SPOOL_Q_ENUMFORMS q_u;
- SPOOL_R_ENUMFORMS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMFORMS);
}
/****************************************************************************
@@ -459,27 +439,7 @@ static bool api_spoolss_enumforms(pipes_struct *p)
static bool api_spoolss_enumports(pipes_struct *p)
{
- SPOOL_Q_ENUMPORTS q_u;
- SPOOL_R_ENUMPORTS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_enumports("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumports(p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPORTS);
}
/****************************************************************************
@@ -597,27 +557,7 @@ static bool api_spoolss_setform(pipes_struct *p)
static bool api_spoolss_enumprintprocessors(pipes_struct *p)
{
- SPOOL_Q_ENUMPRINTPROCESSORS q_u;
- SPOOL_R_ENUMPRINTPROCESSORS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u);
-
- if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) {
- DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCESSORS);
}
/****************************************************************************
@@ -633,27 +573,7 @@ static bool api_spoolss_addprintprocessor(pipes_struct *p)
static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
{
- SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
- SPOOL_R_ENUMPRINTPROCDATATYPES r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u);
-
- if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) {
- DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCDATATYPES);
}
/****************************************************************************
@@ -661,27 +581,7 @@ static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p)
static bool api_spoolss_enumprintmonitors(pipes_struct *p)
{
- SPOOL_Q_ENUMPRINTMONITORS q_u;
- SPOOL_R_ENUMPRINTMONITORS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) {
- DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMMONITORS);
}
/****************************************************************************
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 814f406e87..0a4f5ae05c 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -7244,21 +7244,6 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS
/****************************************************************************
****************************************************************************/
-static void fill_form_1(FORM_1 *form, nt_forms_struct *list)
-{
- form->flag=list->flag;
- init_unistr(&form->name, list->name);
- form->width=list->width;
- form->length=list->length;
- form->left=list->left;
- form->top=list->top;
- form->right=list->right;
- form->bottom=list->bottom;
-}
-
-/****************************************************************************
-****************************************************************************/
-
static WERROR fill_form_info_1(TALLOC_CTX *mem_ctx,
struct spoolss_FormInfo1 *form,
nt_forms_struct *list)
@@ -7277,73 +7262,65 @@ static WERROR fill_form_info_1(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_EnumForms
+****************************************************************/
-WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u)
+WERROR _spoolss_EnumForms(pipes_struct *p,
+ struct spoolss_EnumForms *r)
{
- uint32 level = q_u->level;
- RPC_BUFFER *buffer = NULL;
- uint32 offered = q_u->offered;
- uint32 *needed = &r_u->needed;
- uint32 *numofforms = &r_u->numofforms;
- uint32 numbuiltinforms;
-
nt_forms_struct *list=NULL;
nt_forms_struct *builtinlist=NULL;
- FORM_1 *forms_1;
- int buffer_size=0;
+ union spoolss_FormInfo *info;
+ uint32_t count;
+ uint32_t numbuiltinforms;
+ size_t buffer_size = 0;
int i;
- /* that's an [in out] buffer */
+ *r->out.count = 0;
- if (!q_u->buffer && (offered!=0) ) {
- return WERR_INVALID_PARAM;
- }
+ /* that's an [in out] buffer */
- if (offered > MAX_RPC_DATA_SIZE) {
+ if (!r->in.buffer && (r->in.offered != 0) ) {
return WERR_INVALID_PARAM;
}
- rpcbuf_move(q_u->buffer, &r_u->buffer);
- buffer = r_u->buffer;
-
- DEBUG(4,("_spoolss_enumforms\n"));
- DEBUGADD(5,("Offered buffer size [%d]\n", offered));
- DEBUGADD(5,("Info level [%d]\n", level));
+ DEBUG(4,("_spoolss_EnumForms\n"));
+ DEBUGADD(5,("Offered buffer size [%d]\n", r->in.offered));
+ DEBUGADD(5,("Info level [%d]\n", r->in.level));
numbuiltinforms = get_builtin_ntforms(&builtinlist);
DEBUGADD(5,("Number of builtin forms [%d]\n", numbuiltinforms));
- *numofforms = get_ntforms(&list);
- DEBUGADD(5,("Number of user forms [%d]\n", *numofforms));
- *numofforms += numbuiltinforms;
+ count = get_ntforms(&list);
+ DEBUGADD(5,("Number of user forms [%d]\n", count));
+ count += numbuiltinforms;
- if (*numofforms == 0) {
+ if (count == 0) {
SAFE_FREE(builtinlist);
SAFE_FREE(list);
return WERR_NO_MORE_ITEMS;
}
- switch (level) {
- case 1:
- if ((forms_1=SMB_MALLOC_ARRAY(FORM_1, *numofforms)) == NULL) {
- SAFE_FREE(builtinlist);
- SAFE_FREE(list);
- *numofforms=0;
- return WERR_NOMEM;
- }
+ info = TALLOC_ARRAY(p->mem_ctx, union spoolss_FormInfo, count);
+ if (!info) {
+ SAFE_FREE(builtinlist);
+ SAFE_FREE(list);
+ return WERR_NOMEM;
+ }
+ switch (r->in.level) {
+ case 1:
/* construct the list of form structures */
for (i=0; i<numbuiltinforms; i++) {
DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&forms_1[i], &builtinlist[i]);
+ fill_form_info_1(info, &info[i].info1, &builtinlist[i]);
}
SAFE_FREE(builtinlist);
- for (; i<*numofforms; i++) {
+ for (; i<count; i++) {
DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&forms_1[i], &list[i-numbuiltinforms]);
+ fill_form_info_1(info, &info[i].info1, &list[i-numbuiltinforms]);
}
SAFE_FREE(list);
@@ -7351,38 +7328,22 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF
/* check the required size. */
for (i=0; i<numbuiltinforms; i++) {
DEBUGADD(6,("adding form [%d]'s size\n",i));
- buffer_size += spoolss_size_form_1(&forms_1[i]);
+ buffer_size += ndr_size_spoolss_FormInfo1(&info[i].info1, NULL, 0);
}
- for (; i<*numofforms; i++) {
+ for (; i<count; i++) {
DEBUGADD(6,("adding form [%d]'s size\n",i));
- buffer_size += spoolss_size_form_1(&forms_1[i]);
+ buffer_size += ndr_size_spoolss_FormInfo1(&info[i].info1, NULL, 0);
}
- *needed=buffer_size;
+ *r->out.needed = buffer_size;
- if (*needed > offered) {
- SAFE_FREE(forms_1);
- *numofforms=0;
+ if (*r->out.needed > r->in.offered) {
+ TALLOC_FREE(info);
return WERR_INSUFFICIENT_BUFFER;
}
- if (!rpcbuf_alloc_size(buffer, buffer_size)){
- SAFE_FREE(forms_1);
- *numofforms=0;
- return WERR_NOMEM;
- }
-
- /* fill the buffer with the form structures */
- for (i=0; i<numbuiltinforms; i++) {
- DEBUGADD(6,("adding form [%d] to buffer\n",i));
- smb_io_form_1("", buffer, &forms_1[i], 0);
- }
- for (; i<*numofforms; i++) {
- DEBUGADD(6,("adding form [%d] to buffer\n",i));
- smb_io_form_1("", buffer, &forms_1[i], 0);
- }
-
- SAFE_FREE(forms_1);
+ *r->out.count = count;
+ *r->out.info = info;
return WERR_OK;
@@ -7485,9 +7446,14 @@ WERROR _spoolss_GetForm(pipes_struct *p,
/****************************************************************************
****************************************************************************/
-static void fill_port_1(PORT_INFO_1 *port, const char *name)
+static WERROR fill_port_1(TALLOC_CTX *mem_ctx,
+ struct spoolss_PortInfo1 *r,
+ const char *name)
{
- init_unistr(&port->port_name, name);
+ r->port_name = talloc_strdup(mem_ctx, name);
+ W_ERROR_HAVE_NO_MEMORY(r->port_name);
+
+ return WERR_OK;
}
/****************************************************************************
@@ -7495,13 +7461,23 @@ static void fill_port_1(PORT_INFO_1 *port, const char *name)
somehow.
****************************************************************************/
-static void fill_port_2(PORT_INFO_2 *port, const char *name)
+static WERROR fill_port_2(TALLOC_CTX *mem_ctx,
+ struct spoolss_PortInfo2 *r,
+ const char *name)
{
- init_unistr(&port->port_name, name);
- init_unistr(&port->monitor_name, "Local Monitor");
- init_unistr(&port->description, SPL_LOCAL_PORT );
- port->port_type=PORT_TYPE_WRITE;
- port->reserved=0x0;
+ r->port_name = talloc_strdup(mem_ctx, name);
+ W_ERROR_HAVE_NO_MEMORY(r->port_name);
+
+ r->monitor_name = talloc_strdup(mem_ctx, "Local Monitor");
+ W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
+
+ r->description = talloc_strdup(mem_ctx, SPL_LOCAL_PORT); /* FIXME */
+ W_ERROR_HAVE_NO_MEMORY(r->description);
+
+ r->port_type = SPOOLSS_PORT_TYPE_WRITE;
+ r->reserved = 0;
+
+ return WERR_OK;
}
@@ -7569,9 +7545,13 @@ WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines )
enumports level 1.
****************************************************************************/
-static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumports_level_1(TALLOC_CTX *mem_ctx,
+ union spoolss_PortInfo **info_p,
+ uint32_t offered,
+ uint32_t *needed,
+ uint32_t *count)
{
- PORT_INFO_1 *ports=NULL;
+ union spoolss_PortInfo *info = NULL;
int i=0;
WERROR result = WERR_OK;
char **qlines = NULL;
@@ -7579,31 +7559,31 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need
result = enumports_hook(talloc_tos(), &numlines, &qlines );
if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(qlines);
- return result;
+ goto out;
}
- if(numlines) {
- if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) {
- DEBUG(10,("Returning WERR_NOMEM [%s]\n",
- win_errstr(WERR_NOMEM)));
- TALLOC_FREE(qlines);
- return WERR_NOMEM;
+ if (numlines) {
+ info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines);
+ if (!info) {
+ DEBUG(10,("Returning WERR_NOMEM\n"));
+ result = WERR_NOMEM;
+ goto out;
}
for (i=0; i<numlines; i++) {
DEBUG(6,("Filling port number [%d] with port [%s]\n", i, qlines[i]));
- fill_port_1(&ports[i], qlines[i]);
+ result = fill_port_1(info, &info[i].info1, qlines[i]);
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
}
}
TALLOC_FREE(qlines);
- *returned = numlines;
-
/* check the required size. */
- for (i=0; i<*returned; i++) {
+ for (i=0; i<numlines; i++) {
DEBUGADD(6,("adding port [%d]'s size\n", i));
- *needed += spoolss_size_port_info_1(&ports[i]);
+ *needed += ndr_size_spoolss_PortInfo1(&info[i].info1, NULL, 0);
}
if (*needed > offered) {
@@ -7611,64 +7591,64 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need
goto out;
}
- if (!rpcbuf_alloc_size(buffer, *needed)) {
- result = WERR_NOMEM;
- goto out;
- }
-
- /* fill the buffer with the ports structures */
- for (i=0; i<*returned; i++) {
- DEBUGADD(6,("adding port [%d] to buffer\n", i));
- smb_io_port_1("", buffer, &ports[i], 0);
- }
-
out:
- SAFE_FREE(ports);
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(info);
+ TALLOC_FREE(qlines);
+ *count = 0;
+ *info_p = NULL;
+ return result;
+ }
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
+ *count = numlines;
- return result;
+ return WERR_OK;
}
/****************************************************************************
enumports level 2.
****************************************************************************/
-static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumports_level_2(TALLOC_CTX *mem_ctx,
+ union spoolss_PortInfo **info_p,
+ uint32_t offered,
+ uint32_t *needed,
+ uint32_t *count)
{
- PORT_INFO_2 *ports=NULL;
+ union spoolss_PortInfo *info = NULL;
int i=0;
WERROR result = WERR_OK;
char **qlines = NULL;
int numlines = 0;
result = enumports_hook(talloc_tos(), &numlines, &qlines );
- if ( !W_ERROR_IS_OK(result)) {
- TALLOC_FREE(qlines);
- return result;
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
}
- if(numlines) {
- if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) {
- TALLOC_FREE(qlines);
- return WERR_NOMEM;
+ if (numlines) {
+ info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines);
+ if (!info) {
+ DEBUG(10,("Returning WERR_NOMEM\n"));
+ result = WERR_NOMEM;
+ goto out;
}
for (i=0; i<numlines; i++) {
DEBUG(6,("Filling port number [%d] with port [%s]\n", i, qlines[i]));
- fill_port_2(&(ports[i]), qlines[i]);
+ result = fill_port_2(info, &info[i].info2, qlines[i]);
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
}
}
-
TALLOC_FREE(qlines);
- *returned = numlines;
-
/* check the required size. */
- for (i=0; i<*returned; i++) {
+ for (i=0; i<numlines; i++) {
DEBUGADD(6,("adding port [%d]'s size\n", i));
- *needed += spoolss_size_port_info_2(&ports[i]);
+ *needed += ndr_size_spoolss_PortInfo2(&info[i].info2, NULL, 0);
}
if (*needed > offered) {
@@ -7676,61 +7656,49 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need
goto out;
}
- if (!rpcbuf_alloc_size(buffer, *needed)) {
- result = WERR_NOMEM;
- goto out;
- }
-
- /* fill the buffer with the ports structures */
- for (i=0; i<*returned; i++) {
- DEBUGADD(6,("adding port [%d] to buffer\n", i));
- smb_io_port_2("", buffer, &ports[i], 0);
- }
-
out:
- SAFE_FREE(ports);
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(info);
+ TALLOC_FREE(qlines);
+ *count = 0;
+ *info_p = NULL;
+ return result;
+ }
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
+ *count = numlines;
- return result;
+ return WERR_OK;
}
-/****************************************************************************
- enumports.
-****************************************************************************/
+/****************************************************************
+ _spoolss_EnumPorts
+****************************************************************/
-WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u)
+WERROR _spoolss_EnumPorts(pipes_struct *p,
+ struct spoolss_EnumPorts *r)
{
- uint32 level = q_u->level;
- RPC_BUFFER *buffer = NULL;
- uint32 offered = q_u->offered;
- uint32 *needed = &r_u->needed;
- uint32 *returned = &r_u->returned;
-
/* that's an [in out] buffer */
- if (!q_u->buffer && (offered!=0)) {
- return WERR_INVALID_PARAM;
- }
-
- if (offered > MAX_RPC_DATA_SIZE) {
+ if (!r->in.buffer && (r->in.offered != 0)) {
return WERR_INVALID_PARAM;
}
- rpcbuf_move(q_u->buffer, &r_u->buffer);
- buffer = r_u->buffer;
-
- DEBUG(4,("_spoolss_enumports\n"));
+ DEBUG(4,("_spoolss_EnumPorts\n"));
- *returned=0;
- *needed=0;
+ *r->out.count = 0;
+ *r->out.needed = 0;
+ *r->out.info = NULL;
- switch (level) {
+ switch (r->in.level) {
case 1:
- return enumports_level_1(buffer, offered, needed, returned);
+ return enumports_level_1(p->mem_ctx, r->out.info,
+ r->in.offered, r->out.needed,
+ r->out.count);
case 2:
- return enumports_level_2(buffer, offered, needed, returned);
+ return enumports_level_2(p->mem_ctx, r->out.info,
+ r->in.offered, r->out.needed,
+ r->out.count);
default:
return WERR_UNKNOWN_LEVEL;
}
@@ -8770,69 +8738,75 @@ done:
}
/****************************************************************************
+ fill_print_processor1
+****************************************************************************/
+
+static WERROR fill_print_processor1(TALLOC_CTX *mem_ctx,
+ struct spoolss_PrintProcessorInfo1 *r,
+ const char *print_processor_name)
+{
+ r->print_processor_name = talloc_strdup(mem_ctx, print_processor_name);
+ W_ERROR_HAVE_NO_MEMORY(r->print_processor_name);
+
+ return WERR_OK;
+}
+
+/****************************************************************************
enumprintprocessors level 1.
****************************************************************************/
-static WERROR enumprintprocessors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumprintprocessors_level_1(TALLOC_CTX *mem_ctx,
+ union spoolss_PrintProcessorInfo **info_p,
+ uint32_t offered,
+ uint32_t *needed,
+ uint32_t *count)
{
- PRINTPROCESSOR_1 *info_1=NULL;
- WERROR result = WERR_OK;
+ union spoolss_PrintProcessorInfo *info;
+ WERROR result;
- if((info_1 = SMB_MALLOC_P(PRINTPROCESSOR_1)) == NULL)
- return WERR_NOMEM;
+ info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcessorInfo, 1);
+ W_ERROR_HAVE_NO_MEMORY(info);
- (*returned) = 0x1;
+ *count = 1;
- init_unistr(&info_1->name, "winprint");
+ result = fill_print_processor1(info, &info[0].info1, "winprint");
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
- *needed += spoolss_size_printprocessor_info_1(info_1);
+ *needed += ndr_size_spoolss_PrintProcessorInfo1(&info[0].info1, NULL, 0);
if (*needed > offered) {
result = WERR_INSUFFICIENT_BUFFER;
goto out;
}
- if (!rpcbuf_alloc_size(buffer, *needed)) {
- result = WERR_NOMEM;
- goto out;
+ out:
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(info);
+ *count = 0;
+ return result;
}
- smb_io_printprocessor_info_1("", buffer, info_1, 0);
-
-out:
- SAFE_FREE(info_1);
-
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
- return result;
+ return WERR_OK;
}
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_EnumPrintProcessors
+****************************************************************/
-WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u)
+WERROR _spoolss_EnumPrintProcessors(pipes_struct *p,
+ struct spoolss_EnumPrintProcessors *r)
{
- uint32 level = q_u->level;
- RPC_BUFFER *buffer = NULL;
- uint32 offered = q_u->offered;
- uint32 *needed = &r_u->needed;
- uint32 *returned = &r_u->returned;
-
/* that's an [in out] buffer */
- if (!q_u->buffer && (offered!=0)) {
- return WERR_INVALID_PARAM;
- }
-
- if (offered > MAX_RPC_DATA_SIZE) {
+ if (!r->in.buffer && (r->in.offered != 0)) {
return WERR_INVALID_PARAM;
}
- rpcbuf_move(q_u->buffer, &r_u->buffer);
- buffer = r_u->buffer;
-
- DEBUG(5,("spoolss_enumprintprocessors\n"));
+ DEBUG(5,("_spoolss_EnumPrintProcessors\n"));
/*
* Enumerate the print processors ...
@@ -8841,213 +8815,261 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS
* and I can use my nice printer checker.
*/
- *returned=0;
- *needed=0;
+ *r->out.count = 0;
+ *r->out.needed = 0;
+ *r->out.info = NULL;
- switch (level) {
+ switch (r->in.level) {
case 1:
- return enumprintprocessors_level_1(buffer, offered, needed, returned);
+ return enumprintprocessors_level_1(p->mem_ctx, r->out.info,
+ r->in.offered, r->out.needed,
+ r->out.count);
default:
return WERR_UNKNOWN_LEVEL;
}
}
/****************************************************************************
+ fill_printprocdatatype1
+****************************************************************************/
+
+static WERROR fill_printprocdatatype1(TALLOC_CTX *mem_ctx,
+ struct spoolss_PrintProcDataTypesInfo1 *r,
+ const char *name_array)
+{
+ r->name_array = talloc_strdup(mem_ctx, name_array);
+ W_ERROR_HAVE_NO_MEMORY(r->name_array);
+
+ return WERR_OK;
+}
+
+/****************************************************************************
enumprintprocdatatypes level 1.
****************************************************************************/
-static WERROR enumprintprocdatatypes_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumprintprocdatatypes_level_1(TALLOC_CTX *mem_ctx,
+ union spoolss_PrintProcDataTypesInfo **info_p,
+ uint32_t offered,
+ uint32_t *needed,
+ uint32_t *count)
{
- PRINTPROCDATATYPE_1 *info_1=NULL;
- WERROR result = WERR_OK;
+ WERROR result;
+ union spoolss_PrintProcDataTypesInfo *info;
- if((info_1 = SMB_MALLOC_P(PRINTPROCDATATYPE_1)) == NULL)
- return WERR_NOMEM;
+ info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcDataTypesInfo, 1);
+ W_ERROR_HAVE_NO_MEMORY(info);
- (*returned) = 0x1;
+ *count = 1;
- init_unistr(&info_1->name, "RAW");
+ result = fill_printprocdatatype1(info, &info[0].info1, "RAW");
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
- *needed += spoolss_size_printprocdatatype_info_1(info_1);
+ *needed += ndr_size_spoolss_PrintProcDataTypesInfo1(&info[0].info1, NULL, 0);
if (*needed > offered) {
result = WERR_INSUFFICIENT_BUFFER;
goto out;
}
- if (!rpcbuf_alloc_size(buffer, *needed)) {
- result = WERR_NOMEM;
- goto out;
+ out:
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(info);
+ *count = 0;
+ return result;
}
- smb_io_printprocdatatype_info_1("", buffer, info_1, 0);
-
-out:
- SAFE_FREE(info_1);
-
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
- return result;
+ return WERR_OK;
}
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_EnumPrintProcDataTypes
+****************************************************************/
-WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u)
+WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p,
+ struct spoolss_EnumPrintProcDataTypes *r)
{
- uint32 level = q_u->level;
- RPC_BUFFER *buffer = NULL;
- uint32 offered = q_u->offered;
- uint32 *needed = &r_u->needed;
- uint32 *returned = &r_u->returned;
-
/* that's an [in out] buffer */
- if (!q_u->buffer && (offered!=0)) {
- return WERR_INVALID_PARAM;
- }
-
- if (offered > MAX_RPC_DATA_SIZE) {
+ if (!r->in.buffer && (r->in.offered != 0)) {
return WERR_INVALID_PARAM;
}
- rpcbuf_move(q_u->buffer, &r_u->buffer);
- buffer = r_u->buffer;
-
- DEBUG(5,("_spoolss_enumprintprocdatatypes\n"));
+ DEBUG(5,("_spoolss_EnumPrintProcDataTypes\n"));
- *returned=0;
- *needed=0;
+ *r->out.count = 0;
+ *r->out.needed = 0;
+ *r->out.info = NULL;
- switch (level) {
+ switch (r->in.level) {
case 1:
- return enumprintprocdatatypes_level_1(buffer, offered, needed, returned);
+ return enumprintprocdatatypes_level_1(p->mem_ctx, r->out.info,
+ r->in.offered, r->out.needed,
+ r->out.count);
default:
return WERR_UNKNOWN_LEVEL;
}
}
/****************************************************************************
+ fill_monitor_1
+****************************************************************************/
+
+static WERROR fill_monitor_1(TALLOC_CTX *mem_ctx,
+ struct spoolss_MonitorInfo1 *r,
+ const char *monitor_name)
+{
+ r->monitor_name = talloc_strdup(mem_ctx, monitor_name);
+ W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
+
+ return WERR_OK;
+}
+
+/****************************************************************************
+ fill_monitor_2
+****************************************************************************/
+
+static WERROR fill_monitor_2(TALLOC_CTX *mem_ctx,
+ struct spoolss_MonitorInfo2 *r,
+ const char *monitor_name,
+ const char *environment,
+ const char *dll_name)
+{
+ r->monitor_name = talloc_strdup(mem_ctx, monitor_name);
+ W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
+ r->environment = talloc_strdup(mem_ctx, environment);
+ W_ERROR_HAVE_NO_MEMORY(r->environment);
+ r->dll_name = talloc_strdup(mem_ctx, dll_name);
+ W_ERROR_HAVE_NO_MEMORY(r->dll_name);
+
+ return WERR_OK;
+}
+
+/****************************************************************************
enumprintmonitors level 1.
****************************************************************************/
-static WERROR enumprintmonitors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumprintmonitors_level_1(TALLOC_CTX *mem_ctx,
+ union spoolss_MonitorInfo **info_p,
+ uint32_t offered,
+ uint32_t *needed,
+ uint32_t *count)
{
- PRINTMONITOR_1 *info_1;
+ union spoolss_MonitorInfo *info;
WERROR result = WERR_OK;
int i;
- if((info_1 = SMB_MALLOC_ARRAY(PRINTMONITOR_1, 2)) == NULL)
- return WERR_NOMEM;
-
- *returned = 2;
+ info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2);
+ W_ERROR_HAVE_NO_MEMORY(info);
- init_unistr(&(info_1[0].name), SPL_LOCAL_PORT );
- init_unistr(&(info_1[1].name), SPL_TCPIP_PORT );
+ *count = 2;
- for ( i=0; i<*returned; i++ ) {
- *needed += spoolss_size_printmonitor_info_1(&info_1[i]);
+ result = fill_monitor_1(info, &info[0].info1,
+ SPL_LOCAL_PORT /* FIXME */);
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
}
- if (*needed > offered) {
- result = WERR_INSUFFICIENT_BUFFER;
+ result = fill_monitor_1(info, &info[1].info1,
+ SPL_TCPIP_PORT /* FIXME */);
+ if (!W_ERROR_IS_OK(result)) {
goto out;
}
- if (!rpcbuf_alloc_size(buffer, *needed)) {
- result = WERR_NOMEM;
- goto out;
+ for (i=0; i<*count; i++) {
+ *needed += ndr_size_spoolss_MonitorInfo1(&info[i].info1, NULL, 0);
}
- for ( i=0; i<*returned; i++ ) {
- smb_io_printmonitor_info_1("", buffer, &info_1[i], 0);
+ if (*needed > offered) {
+ result = WERR_INSUFFICIENT_BUFFER;
+ goto out;
}
out:
- SAFE_FREE(info_1);
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(info);
+ *count = 0;
+ return result;
+ }
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
- return result;
+ return WERR_OK;
}
/****************************************************************************
enumprintmonitors level 2.
****************************************************************************/
-static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
+static WERROR enumprintmonitors_level_2(TALLOC_CTX *mem_ctx,
+ union spoolss_MonitorInfo **info_p,
+ uint32_t offered,
+ uint32_t *needed,
+ uint32_t *count)
{
- PRINTMONITOR_2 *info_2;
+ union spoolss_MonitorInfo *info;
WERROR result = WERR_OK;
int i;
- if((info_2 = SMB_MALLOC_ARRAY(PRINTMONITOR_2, 2)) == NULL)
- return WERR_NOMEM;
-
- *returned = 2;
-
- init_unistr( &(info_2[0].name), SPL_LOCAL_PORT );
- init_unistr( &(info_2[0].environment), "Windows NT X86" );
- init_unistr( &(info_2[0].dll_name), "localmon.dll" );
+ info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2);
+ W_ERROR_HAVE_NO_MEMORY(info);
- init_unistr( &(info_2[1].name), SPL_TCPIP_PORT );
- init_unistr( &(info_2[1].environment), "Windows NT X86" );
- init_unistr( &(info_2[1].dll_name), "tcpmon.dll" );
+ *count = 2;
- for ( i=0; i<*returned; i++ ) {
- *needed += spoolss_size_printmonitor_info_2(&info_2[i]);
+ result = fill_monitor_2(info, &info[0].info2,
+ SPL_LOCAL_PORT, /* FIXME */
+ "Windows NT X86", /* FIXME */
+ "localmon.dll");
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
}
- if (*needed > offered) {
- result = WERR_INSUFFICIENT_BUFFER;
+ result = fill_monitor_2(info, &info[1].info2,
+ SPL_TCPIP_PORT, /* FIXME */
+ "Windows NT X86", /* FIXME */
+ "tcpmon.dll");
+ if (!W_ERROR_IS_OK(result)) {
goto out;
}
- if (!rpcbuf_alloc_size(buffer, *needed)) {
- result = WERR_NOMEM;
- goto out;
+ for (i=0; i<*count; i++) {
+ *needed += ndr_size_spoolss_MonitorInfo2(&info[i].info2, NULL, 0);
}
- for ( i=0; i<*returned; i++ ) {
- smb_io_printmonitor_info_2("", buffer, &info_2[i], 0);
+ if (*needed > offered) {
+ result = WERR_INSUFFICIENT_BUFFER;
+ goto out;
}
out:
- SAFE_FREE(info_2);
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(info);
+ *count = 0;
+ return result;
+ }
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
- return result;
+ return WERR_OK;
}
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_EnumMonitors
+****************************************************************/
-WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u)
+WERROR _spoolss_EnumMonitors(pipes_struct *p,
+ struct spoolss_EnumMonitors *r)
{
- uint32 level = q_u->level;
- RPC_BUFFER *buffer = NULL;
- uint32 offered = q_u->offered;
- uint32 *needed = &r_u->needed;
- uint32 *returned = &r_u->returned;
-
/* that's an [in out] buffer */
- if (!q_u->buffer && (offered!=0)) {
- return WERR_INVALID_PARAM;
- }
-
- if (offered > MAX_RPC_DATA_SIZE) {
+ if (!r->in.buffer && (r->in.offered != 0)) {
return WERR_INVALID_PARAM;
}
- rpcbuf_move(q_u->buffer, &r_u->buffer);
- buffer = r_u->buffer;
-
- DEBUG(5,("spoolss_enumprintmonitors\n"));
+ DEBUG(5,("_spoolss_EnumMonitors\n"));
/*
* Enumerate the print monitors ...
@@ -9056,14 +9078,19 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_
* and I can use my nice printer checker.
*/
- *returned=0;
- *needed=0;
+ *r->out.count = 0;
+ *r->out.needed = 0;
+ *r->out.info = NULL;
- switch (level) {
+ switch (r->in.level) {
case 1:
- return enumprintmonitors_level_1(buffer, offered, needed, returned);
+ return enumprintmonitors_level_1(p->mem_ctx, r->out.info,
+ r->in.offered, r->out.needed,
+ r->out.count);
case 2:
- return enumprintmonitors_level_2(buffer, offered, needed, returned);
+ return enumprintmonitors_level_2(p->mem_ctx, r->out.info,
+ r->in.offered, r->out.needed,
+ r->out.count);
default:
return WERR_UNKNOWN_LEVEL;
}
@@ -10103,7 +10130,7 @@ WERROR _spoolss_XcvData(pipes_struct *p,
struct spoolss_XcvData *r)
{
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
- DATA_BLOB out_data;
+ DATA_BLOB out_data = data_blob_null;
WERROR werror;
if (!Printer) {
@@ -10258,17 +10285,6 @@ WERROR _spoolss_GetPrinterDriver(pipes_struct *p,
}
/****************************************************************
- _spoolss_EnumPrintProcessors
-****************************************************************/
-
-WERROR _spoolss_EnumPrintProcessors(pipes_struct *p,
- struct spoolss_EnumPrintProcessors *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
_spoolss_ReadPrinter
****************************************************************/
@@ -10313,39 +10329,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p,
}
/****************************************************************
- _spoolss_EnumForms
-****************************************************************/
-
-WERROR _spoolss_EnumForms(pipes_struct *p,
- struct spoolss_EnumForms *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
- _spoolss_EnumPorts
-****************************************************************/
-
-WERROR _spoolss_EnumPorts(pipes_struct *p,
- struct spoolss_EnumPorts *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
- _spoolss_EnumMonitors
-****************************************************************/
-
-WERROR _spoolss_EnumMonitors(pipes_struct *p,
- struct spoolss_EnumMonitors *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
_spoolss_AddPort
****************************************************************/
@@ -10500,17 +10483,6 @@ WERROR _spoolss_DeletePrintProvidor(pipes_struct *p,
}
/****************************************************************
- _spoolss_EnumPrintProcDataTypes
-****************************************************************/
-
-WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p,
- struct spoolss_EnumPrintProcDataTypes *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
_spoolss_GetPrinterDriver2
****************************************************************/