summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c3
-rw-r--r--source3/rpc_server/srv_samr_nt.c94
-rw-r--r--source3/rpc_server/srv_spoolss.c88
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c598
4 files changed, 362 insertions, 421 deletions
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index a5d059c06a..fb7aca5c0f 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -1243,7 +1243,8 @@ static void np_write_trigger(struct async_req *req)
req->private_data, struct np_write_state);
struct tevent_req *subreq;
- subreq = writev_send(state, state->ev, state->p->fd, &state->iov, 1);
+ subreq = writev_send(state, state->ev, NULL, state->p->fd,
+ &state->iov, 1);
if (async_req_nomem(subreq, req)) {
return;
}
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 d665ebe244..616eb1dbf0 100644
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -439,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);
}
/****************************************************************************
@@ -577,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);
}
/****************************************************************************
@@ -613,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);
}
/****************************************************************************
@@ -641,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 77f64ae8ae..0a4f5ae05c 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -7446,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;
}
/****************************************************************************
@@ -7456,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;
}
@@ -7530,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;
@@ -7540,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) {
@@ -7572,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) {
@@ -7637,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;
}
@@ -8731,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);
+ *info_p = info;
-out:
- SAFE_FREE(info_1);
-
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
-
- 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 ...
@@ -8802,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);
+ *info_p = info;
-out:
- SAFE_FREE(info_1);
-
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
-
- 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 ...
@@ -9017,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;
}
@@ -10219,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
****************************************************************/
@@ -10274,28 +10329,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p,
}
/****************************************************************
- _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
****************************************************************/
@@ -10450,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
****************************************************************/