struct policy_handle *handle)
{
union spoolss_PrinterInfo info;
- union spoolss_PrinterInfo info_2;
struct security_descriptor *sd1, *sd2;
int i;
- /* level 2 */
+ /* just compare level 2 and level 3 */
torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
- sd1 = security_descriptor_copy(tctx, info.info2.secdesc);
+ sd1 = info.info2.secdesc;
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 3, &info), "");
+
+ sd2 = info.info3.secdesc;
+
+ torture_assert(tctx, test_security_descriptor_equal(tctx, sd1, sd2), "");
- torture_assert(tctx, test_sd_set_level(tctx, p, handle, 2, sd1), "");
- torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info_2), "");
+ /* query level 2, set level 2, query level 2 */
- sd2 = security_descriptor_copy(tctx, info_2.info2.secdesc);
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
+
+ sd1 = info.info2.secdesc;
+
+ torture_assert(tctx, test_sd_set_level(tctx, p, handle, 2, sd1), "");
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
+ sd2 = info.info2.secdesc;
if (sd1->type & SEC_DESC_DACL_DEFAULTED) {
- torture_comment(tctx, "removing SEC_DESC_DACL_DEFAULTED from 1st for comparison\n");
+ torture_comment(tctx, "removing SEC_DESC_DACL_DEFAULTED\n");
sd1->type &= ~SEC_DESC_DACL_DEFAULTED;
}
torture_assert(tctx, test_security_descriptor_equal(tctx, sd1, sd2), "");
- /* level 3 */
- sd1 = sd2;
+ /* query level 2, set level 3, query level 2 */
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
+
+ sd1 = info.info2.secdesc;
+
+ torture_assert(tctx, test_sd_set_level(tctx, p, handle, 3, sd1), "");
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
+
+ sd2 = info.info2.secdesc;
+
+ torture_assert(tctx, test_security_descriptor_equal(tctx, sd1, sd2), "");
+
+
+ /* set modified sd level 3, query level 2 */
for (i=0; i < 93; i++) {
struct security_ace a;
torture_assert(tctx, test_sd_set_level(tctx, p, handle, 3, sd1), "");
- torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info_2), "");
- sd2 = security_descriptor_copy(tctx, info_2.info2.secdesc);
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
+ sd2 = info.info2.secdesc;
+
+ if (sd1->type & SEC_DESC_DACL_DEFAULTED) {
+ torture_comment(tctx, "removing SEC_DESC_DACL_DEFAULTED\n");
+ sd1->type &= ~SEC_DESC_DACL_DEFAULTED;
+ }
torture_assert(tctx, test_security_descriptor_equal(tctx, sd1, sd2), "");
return true;
}
+static bool call_OpenPrinterEx(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ const char *name,
+ struct spoolss_DeviceMode *devmode,
+ struct policy_handle *handle);
+
+static bool test_ClosePrinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle);
+
static bool test_PrinterInfo_DevModes(struct torture_context *tctx,
struct dcerpc_pipe *p,
- struct policy_handle *handle)
+ struct policy_handle *handle,
+ const char *name)
{
union spoolss_PrinterInfo info;
struct spoolss_DeviceMode *devmode;
struct spoolss_DeviceMode *devmode2;
+ struct policy_handle handle_devmode;
+
+ /* simply compare level8 and level2 devmode */
torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 8, &info), "");
torture_assert(tctx, test_devicemode_equal(tctx, devmode, devmode2), "");
+
+ /* change formname upon open and see if it persists in getprinter calls */
+
+ devmode->formname = talloc_strdup(tctx, "A4");
+
+ torture_assert(tctx, call_OpenPrinterEx(tctx, p, name, devmode, &handle_devmode),
+ "failed to open printer handle");
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, &handle_devmode, 8, &info), "");
+
+ devmode2 = info.info8.devmode;
+
+ if (strequal(devmode->devicename, devmode2->devicename)) {
+ torture_fail(tctx, "devicename is the same");
+ }
+
+ if (strequal(devmode->formname, devmode2->formname)) {
+ torture_fail(tctx, "formname is the same");
+ }
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, &handle_devmode, 2, &info), "");
+
+ devmode2 = info.info2.devmode;
+
+ if (strequal(devmode->devicename, devmode2->devicename)) {
+ torture_fail(tctx, "devicename is the same");
+ }
+
+ if (strequal(devmode->formname, devmode2->formname)) {
+ torture_fail(tctx, "formname is the same");
+ }
+
+ test_ClosePrinter(tctx, p, &handle_devmode);
+
+
+ /* set devicemode and see if it persists */
+
+ devmode->copies = 93;
+ devmode->formname = talloc_strdup(tctx, "Legal");
+
+ {
+ struct spoolss_SetPrinterInfoCtr info_ctr;
+ struct spoolss_SetPrinterInfo8 info8;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
+
+ info8.devmode_ptr = 0;
+
+ info_ctr.level = 8;
+ info_ctr.info.info8 = &info8;
+
+ devmode_ctr.devmode = devmode;
+
+ ZERO_STRUCT(secdesc_ctr);
+
+ torture_assert(tctx,
+ test_SetPrinter(tctx, p, handle, &info_ctr, &devmode_ctr, &secdesc_ctr, 0), "");
+ }
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 8, &info), "");
+
+ devmode2 = info.info8.devmode;
+
+ torture_assert(tctx, test_devicemode_equal(tctx, devmode, devmode2), "");
+
+ torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
+
+ devmode2 = info.info2.devmode;
+
+ torture_assert(tctx, test_devicemode_equal(tctx, devmode, devmode2), "");
+
return true;
}
static bool test_PrinterInfo_DevMode(struct torture_context *tctx,
struct dcerpc_pipe *p,
- struct policy_handle *handle)
+ struct policy_handle *handle,
+ const char *name)
{
union spoolss_PrinterInfo info;
struct spoolss_SetPrinterInfo8 info8;
/* run tests */
- ret = test_PrinterInfo_DevModes(tctx, p, handle);
+ ret = test_PrinterInfo_DevModes(tctx, p, handle, name);
/* restore original devmode */
static bool call_OpenPrinterEx(struct torture_context *tctx,
struct dcerpc_pipe *p,
- const char *name, struct policy_handle *handle)
+ const char *name,
+ struct spoolss_DeviceMode *devmode,
+ struct policy_handle *handle)
{
struct spoolss_OpenPrinterEx r;
struct spoolss_UserLevel1 userlevel1;
}
r.in.datatype = NULL;
- r.in.devmode_ctr.devmode= NULL;
+ r.in.devmode_ctr.devmode= devmode;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r.in.level = 1;
r.in.userlevel.level1 = &userlevel1;
struct policy_handle handle;
bool ret = true;
- if (!call_OpenPrinterEx(tctx, p, name, &handle)) {
+ if (!call_OpenPrinterEx(tctx, p, name, NULL, &handle)) {
return false;
}
if (W_ERROR_EQUAL(result, WERR_PRINTER_ALREADY_EXISTS)) {
struct policy_handle printer_handle;
- torture_assert(tctx, call_OpenPrinterEx(tctx, p, printername, &printer_handle),
+ torture_assert(tctx, call_OpenPrinterEx(tctx, p, printername, NULL, &printer_handle),
"failed to open printer handle");
torture_assert(tctx, test_DeletePrinter(tctx, p, &printer_handle),
ret = false;
}
- if (!test_PrinterInfo_DevMode(tctx, p, &handle[0])) {
+ if (!test_PrinterInfo_DevMode(tctx, p, &handle[0], TORTURE_PRINTER)) {
ret = false;
}