1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00

s3-rpc_server: Migrated spoolss to dcerpc_winreg_set_sz..

Signed-off-by: Günther Deschner <gd@samba.org>
This commit is contained in:
Andreas Schneider 2011-02-01 14:48:11 +01:00 committed by Günther Deschner
parent 8238732330
commit 460aedc4b1

View File

@ -655,46 +655,6 @@ done:
return result; return result;
} }
static WERROR winreg_printer_write_sz(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *winreg_handle,
struct policy_handle *key_handle,
const char *value,
const char *data)
{
struct winreg_String wvalue;
DATA_BLOB blob;
WERROR result = WERR_OK;
NTSTATUS status;
wvalue.name = value;
if (data == NULL) {
blob = data_blob_string_const("");
} else {
if (!push_reg_sz(mem_ctx, &blob, data)) {
DEBUG(0, ("winreg_printer_write_sz: Could not marshall string %s for %s\n",
data, wvalue.name));
return WERR_NOMEM;
}
}
status = dcerpc_winreg_SetValue(winreg_handle,
mem_ctx,
key_handle,
wvalue,
REG_SZ,
blob.data,
blob.length,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) {
DEBUG(0, ("winreg_printer_write_sz: Could not set value %s: %s\n",
wvalue.name, win_errstr(result)));
}
return result;
}
static WERROR winreg_printer_write_dword(TALLOC_CTX *mem_ctx, static WERROR winreg_printer_write_dword(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *winreg_handle, struct dcerpc_binding_handle *winreg_handle,
struct policy_handle *key_handle, struct policy_handle *key_handle,
@ -1310,20 +1270,28 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
const char *longname; const char *longname;
const char *uncname; const char *uncname;
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
SPOOL_REG_PRINTERNAME, SPOOL_REG_PRINTERNAME,
sharename); sharename,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
SPOOL_REG_SHORTSERVERNAME, SPOOL_REG_SHORTSERVERNAME,
global_myname()); global_myname(),
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -1343,11 +1311,15 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
SPOOL_REG_SERVERNAME, SPOOL_REG_SERVERNAME,
longname); longname,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -1359,11 +1331,15 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
SPOOL_REG_UNCNAME, SPOOL_REG_UNCNAME,
uncname); uncname,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -1514,6 +1490,7 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
DATA_BLOB blob; DATA_BLOB blob;
char *path; char *path;
WERROR result = WERR_OK; WERROR result = WERR_OK;
NTSTATUS status;
TALLOC_CTX *tmp_ctx; TALLOC_CTX *tmp_ctx;
tmp_ctx = talloc_stackframe(); tmp_ctx = talloc_stackframe();
@ -1571,22 +1548,30 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
#endif #endif
if (info2_mask & SPOOLSS_PRINTER_INFO_COMMENT) { if (info2_mask & SPOOLSS_PRINTER_INFO_COMMENT) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Description", "Description",
info2->comment); info2->comment,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_DATATYPE) { if (info2_mask & SPOOLSS_PRINTER_INFO_DATATYPE) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Datatype", "Datatype",
info2->datatype); info2->datatype,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -1642,44 +1627,60 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_DRIVERNAME) { if (info2_mask & SPOOLSS_PRINTER_INFO_DRIVERNAME) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Printer Driver", "Printer Driver",
info2->drivername); info2->drivername,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_LOCATION) { if (info2_mask & SPOOLSS_PRINTER_INFO_LOCATION) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Location", "Location",
info2->location); info2->location,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_PARAMETERS) { if (info2_mask & SPOOLSS_PRINTER_INFO_PARAMETERS) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Parameters", "Parameters",
info2->parameters); info2->parameters,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_PORTNAME) { if (info2_mask & SPOOLSS_PRINTER_INFO_PORTNAME) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Port", "Port",
info2->portname); info2->portname,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -1703,22 +1704,30 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
} else { } else {
p++; p++;
} }
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Name", "Name",
p); p,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_PRINTPROCESSOR) { if (info2_mask & SPOOLSS_PRINTER_INFO_PRINTPROCESSOR) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Print Processor", "Print Processor",
info2->printprocessor); info2->printprocessor,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -1757,22 +1766,30 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_SEPFILE) { if (info2_mask & SPOOLSS_PRINTER_INFO_SEPFILE) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Separator File", "Separator File",
info2->sepfile); info2->sepfile,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
} }
if (info2_mask & SPOOLSS_PRINTER_INFO_SHARENAME) { if (info2_mask & SPOOLSS_PRINTER_INFO_SHARENAME) {
result = winreg_printer_write_sz(tmp_ctx, status = dcerpc_winreg_set_sz(tmp_ctx,
winreg_handle, winreg_handle,
&key_hnd, &key_hnd,
"Share Name", "Share Name",
info2->sharename); info2->sharename,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -3648,6 +3665,7 @@ WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
struct policy_handle hive_hnd, key_hnd; struct policy_handle hive_hnd, key_hnd;
struct spoolss_DriverInfo8 info8; struct spoolss_DriverInfo8 info8;
TALLOC_CTX *tmp_ctx = NULL; TALLOC_CTX *tmp_ctx = NULL;
NTSTATUS status;
WERROR result; WERROR result;
ZERO_STRUCT(hive_hnd); ZERO_STRUCT(hive_hnd);
@ -3691,30 +3709,54 @@ WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Driver", winreg_handle,
info8.driver_path); &key_hnd,
"Driver",
info8.driver_path,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Data File", winreg_handle,
info8.data_file); &key_hnd,
"Data File",
info8.data_file,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Configuration File", winreg_handle,
info8.config_file); &key_hnd,
"Configuration File",
info8.config_file,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Help File", winreg_handle,
info8.help_file); &key_hnd,
"Help File",
info8.help_file,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -3726,16 +3768,28 @@ WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Monitor", winreg_handle,
info8.monitor_name); &key_hnd,
"Monitor",
info8.monitor_name,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Datatype", winreg_handle,
info8.default_datatype); &key_hnd,
"Datatype",
info8.default_datatype,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -3761,44 +3815,80 @@ WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Manufacturer", winreg_handle,
info8.manufacturer_name); &key_hnd,
"Manufacturer",
info8.manufacturer_name,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "OEM URL", winreg_handle,
info8.manufacturer_url); &key_hnd,
"OEM URL",
info8.manufacturer_url,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "HardwareID", winreg_handle,
info8.hardware_id); &key_hnd,
"HardwareID",
info8.hardware_id,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Provider", winreg_handle,
info8.provider); &key_hnd,
"Provider",
info8.provider,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "Print Processor", winreg_handle,
info8.print_processor); &key_hnd,
"Print Processor",
info8.print_processor,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "VendorSetup", winreg_handle,
info8.vendor_setup); &key_hnd,
"VendorSetup",
info8.vendor_setup,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }
@ -3810,9 +3900,15 @@ WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
goto done; goto done;
} }
result = winreg_printer_write_sz(tmp_ctx, winreg_handle, status = dcerpc_winreg_set_sz(tmp_ctx,
&key_hnd, "InfPath", winreg_handle,
info8.inf_path); &key_hnd,
"InfPath",
info8.inf_path,
&result);
if (!NT_STATUS_IS_OK(status)) {
result = ntstatus_to_werror(status);
}
if (!W_ERROR_IS_OK(result)) { if (!W_ERROR_IS_OK(result)) {
goto done; goto done;
} }