summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-03-04 18:21:50 +0100
committerGünther Deschner <gd@samba.org>2010-03-05 15:18:00 +0100
commit8e499ec847fb2d342a544edf705bb9398967ca24 (patch)
treee3797ab835dee25ff9fa10e2a7cc5c8f85ec87ab /source4
parent7643afa70e879efc059c75b8309bf89dbb3c459b (diff)
downloadsamba-8e499ec847fb2d342a544edf705bb9398967ca24.tar.gz
samba-8e499ec847fb2d342a544edf705bb9398967ca24.tar.bz2
samba-8e499ec847fb2d342a544edf705bb9398967ca24.zip
s4-spoolss: fix spoolss_GetPrinterData implementation after IDL change.
Guenther
Diffstat (limited to 'source4')
-rw-r--r--source4/ntptr/simple_ldb/ntptr_simple_ldb.c116
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c3
2 files changed, 75 insertions, 44 deletions
diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
index 33632aa0fc..32d1332cce 100644
--- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
+++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
@@ -122,51 +122,55 @@ static WERROR sptr_OpenPrintServer(struct ntptr_context *ntptr, TALLOC_CTX *mem_
/*
* PrintServer PrinterData functions
*/
-static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx,
- struct spoolss_GetPrinterData *r)
+
+static WERROR sptr_PrintServerData(struct ntptr_GenericHandle *server,
+ TALLOC_CTX *mem_ctx,
+ const char *value_name,
+ union spoolss_PrinterData *r,
+ enum winreg_Type *type)
{
struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, server->ntptr->lp_ctx);
- if (strcmp("W3SvcInstalled", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 0;
+ if (strcmp("W3SvcInstalled", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 0;
return WERR_OK;
- } else if (strcmp("BeepEnabled", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 0;
+ } else if (strcmp("BeepEnabled", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 0;
return WERR_OK;
- } else if (strcmp("EventLog", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 0;
+ } else if (strcmp("EventLog", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 0;
return WERR_OK;
- } else if (strcmp("NetPopup", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 0;
+ } else if (strcmp("NetPopup", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 0;
return WERR_OK;
- } else if (strcmp("NetPopupToComputer", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 0;
+ } else if (strcmp("NetPopupToComputer", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 0;
return WERR_OK;
- } else if (strcmp("MajorVersion", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 3;
+ } else if (strcmp("MajorVersion", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 3;
return WERR_OK;
- } else if (strcmp("MinorVersion", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 0;
+ } else if (strcmp("MinorVersion", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 0;
return WERR_OK;
- } else if (strcmp("DefaultSpoolDirectory", r->in.value_name) == 0) {
- *r->out.type = REG_SZ;
- r->out.data->string = "C:\\PRINTERS";
+ } else if (strcmp("DefaultSpoolDirectory", value_name) == 0) {
+ *type = REG_SZ;
+ r->string = "C:\\PRINTERS";
return WERR_OK;
- } else if (strcmp("Architecture", r->in.value_name) == 0) {
- *r->out.type = REG_SZ;
- r->out.data->string = SPOOLSS_ARCHITECTURE_NT_X86;
+ } else if (strcmp("Architecture", value_name) == 0) {
+ *type = REG_SZ;
+ r->string = SPOOLSS_ARCHITECTURE_NT_X86;
return WERR_OK;
- } else if (strcmp("DsPresent", r->in.value_name) == 0) {
- *r->out.type = REG_DWORD;
- r->out.data->value = 1;
+ } else if (strcmp("DsPresent", value_name) == 0) {
+ *type = REG_DWORD;
+ r->value = 1;
return WERR_OK;
- } else if (strcmp("OSVersion", r->in.value_name) == 0) {
+ } else if (strcmp("OSVersion", value_name) == 0) {
DATA_BLOB blob;
enum ndr_err_code ndr_err;
struct spoolss_OSVersion os;
@@ -181,10 +185,10 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
return WERR_GENERAL_FAILURE;
}
- *r->out.type = REG_BINARY;
- r->out.data->binary = blob;
+ *type = REG_BINARY;
+ r->binary = blob;
return WERR_OK;
- } else if (strcmp("OSVersionEx", r->in.value_name) == 0) {
+ } else if (strcmp("OSVersionEx", value_name) == 0) {
DATA_BLOB blob;
enum ndr_err_code ndr_err;
struct spoolss_OSVersionEx os_ex;
@@ -204,25 +208,53 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
return WERR_GENERAL_FAILURE;
}
- *r->out.type = REG_BINARY;
- r->out.data->binary = blob;
+ *type = REG_BINARY;
+ r->binary = blob;
return WERR_OK;
- } else if (strcmp("DNSMachineName", r->in.value_name) == 0) {
+ } else if (strcmp("DNSMachineName", value_name) == 0) {
const char *dnsdomain = lp_dnsdomain(server->ntptr->lp_ctx);
if (dnsdomain == NULL) return WERR_INVALID_PARAM;
- *r->out.type = REG_SZ;
- r->out.data->string = talloc_asprintf(mem_ctx, "%s.%s",
+ *type = REG_SZ;
+ r->string = talloc_asprintf(mem_ctx, "%s.%s",
lp_netbios_name(server->ntptr->lp_ctx),
dnsdomain);
- W_ERROR_HAVE_NO_MEMORY(r->out.data->string);
+ W_ERROR_HAVE_NO_MEMORY(r->string);
return WERR_OK;
}
return WERR_INVALID_PARAM;
}
+static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx,
+ struct spoolss_GetPrinterData *r)
+{
+ WERROR result;
+ union spoolss_PrinterData data;
+ DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
+
+ result = sptr_PrintServerData(server, mem_ctx, r->in.value_name, &data, r->out.type);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ ndr_err = ndr_push_union_blob(&blob, mem_ctx, lp_iconv_convenience(server->ntptr->lp_ctx),
+ &data, *r->out.type, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterData);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return WERR_GENERAL_FAILURE;
+ }
+
+ *r->out.needed = blob.length;
+
+ if (r->in.offered >= *r->out.needed) {
+ memcpy(r->out.data, blob.data, blob.length);
+ }
+
+ return WERR_OK;
+}
+
/* PrintServer Form functions */
static WERROR sptr_EnumPrintServerForms(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx,
struct spoolss_EnumForms *r)
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 2921b6b596..30ed721b12 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -581,7 +581,7 @@ static WERROR dcesrv_spoolss_GetPrinterData(struct dcesrv_call_state *dce_call,
r->out.needed = talloc_zero(mem_ctx, uint32_t);
W_ERROR_HAVE_NO_MEMORY(r->out.needed);
- r->out.data = talloc_zero(mem_ctx, union spoolss_PrinterData);
+ r->out.data = talloc_zero_array(mem_ctx, uint8_t, r->in.needed);
W_ERROR_HAVE_NO_MEMORY(r->out.data);
DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
@@ -600,7 +600,6 @@ static WERROR dcesrv_spoolss_GetPrinterData(struct dcesrv_call_state *dce_call,
W_ERROR_NOT_OK_RETURN(status);
- *r->out.needed = ndr_size_spoolss_PrinterData(r->out.data, *r->out.type, ic, 0);
*r->out.type = SPOOLSS_BUFFER_OK(*r->out.type, REG_NONE);
r->out.data = SPOOLSS_BUFFER_OK(r->out.data, r->out.data);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_MORE_DATA);