diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-07-01 09:05:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:19:02 -0500 |
commit | fe94ba6e71eb8d3273d593763f6b6d03fa90113d (patch) | |
tree | cc1076eb2a6edfbe80dda981d627835ffc8bc1f1 /source4/ntptr | |
parent | cee17efc7c3897182765d457cce98043f7a7b94f (diff) | |
download | samba-fe94ba6e71eb8d3273d593763f6b6d03fa90113d.tar.gz samba-fe94ba6e71eb8d3273d593763f6b6d03fa90113d.tar.bz2 samba-fe94ba6e71eb8d3273d593763f6b6d03fa90113d.zip |
r8046: - add somemore failure checks in the RPC-SPOOLSS test
- test AddForm on the PrintServer object
- GetForm() isn't allowed on the PrintServer object so remove NTPTR
function for it
- accept the dns name as servername in the spoolss server
metze
(This used to be commit d8c308a4653d59514915021607fe55c5f2b38749)
Diffstat (limited to 'source4/ntptr')
-rw-r--r-- | source4/ntptr/ntptr.h | 3 | ||||
-rw-r--r-- | source4/ntptr/ntptr_interface.c | 12 | ||||
-rw-r--r-- | source4/ntptr/simple_ldb/ntptr_simple_ldb.c | 113 |
3 files changed, 61 insertions, 67 deletions
diff --git a/source4/ntptr/ntptr.h b/source4/ntptr/ntptr.h index 847cef97c3..0f07f26cbb 100644 --- a/source4/ntptr/ntptr.h +++ b/source4/ntptr/ntptr.h @@ -35,6 +35,7 @@ enum ntptr_HandleType { struct ntptr_GenericHandle { enum ntptr_HandleType type; struct ntptr_context *ntptr; + const char *object_name; uint32_t access_mask; void *private_data; }; @@ -68,8 +69,6 @@ struct ntptr_ops { struct spoolss_EnumForms *r); WERROR (*AddPrintServerForm)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, struct spoolss_AddForm *r); - WERROR (*GetPrintServerForm)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_GetForm *r); WERROR (*SetPrintServerForm)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, struct spoolss_SetForm *r); WERROR (*DeletePrintServerForm)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, diff --git a/source4/ntptr/ntptr_interface.c b/source4/ntptr/ntptr_interface.c index b389a5b894..1920b37f21 100644 --- a/source4/ntptr/ntptr_interface.c +++ b/source4/ntptr/ntptr_interface.c @@ -112,18 +112,6 @@ WERROR ntptr_AddPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX * return server->ntptr->ops->AddPrintServerForm(server, mem_ctx, r); } -WERROR ntptr_GetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_GetForm *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->GetPrintServerForm) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->GetPrintServerForm(server, mem_ctx, r); -} - WERROR ntptr_SetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, struct spoolss_SetForm *r) { diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c index dc79ba8a1a..c83cac4440 100644 --- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c +++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c @@ -105,7 +105,9 @@ static WERROR sptr_OpenPrintServer(struct ntptr_context *ntptr, TALLOC_CTX *mem_ server->type = NTPTR_HANDLE_SERVER; server->ntptr = ntptr; - server->access_mask = r->in.access_mask; + server->object_name = talloc_strdup(server, server_name); + W_ERROR_HAVE_NO_MEMORY(server->object_name); + server->access_mask = 0; server->private_data = NULL; *_server = server; @@ -174,7 +176,7 @@ static WERROR sptr_EnumPrintServerForms(struct ntptr_GenericHandle *server, TALL union spoolss_FormInfo *info; count = sptr_db_search(sptr_db, mem_ctx, "CN=Forms,CN=PrintServer", &msgs, NULL, - "(&(objectclass=form))"); + "(&(objectClass=form))"); if (count == 0) return WERR_OK; if (count < 0) return WERR_GENERAL_FAILURE; @@ -271,54 +273,6 @@ static WERROR sptr_AddPrintServerForm(struct ntptr_GenericHandle *server, TALLOC return WERR_OK; } -static WERROR sptr_GetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_GetForm *r) -{ - struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context); - struct ldb_message **msgs; - int count; - union spoolss_FormInfo *info; - - /* TODO: do checks access here - * if (!(server->access_mask & desired_access)) { - * return WERR_FOOBAR; - * } - */ - - count = sptr_db_search(sptr_db, mem_ctx, "CN=Forms,CN=PrintServer", &msgs, NULL, - "(&(form_name=%s)(objectClass=form))", - r->in.form_name); - - if (count == 0) return WERR_FOOBAR; - if (count > 1) return WERR_FOOBAR; - if (count < 0) return WERR_GENERAL_FAILURE; - - info = talloc(mem_ctx, union spoolss_FormInfo); - W_ERROR_HAVE_NO_MEMORY(info); - - switch (r->in.level) { - case 1: - info->info1.flags = samdb_result_uint(msgs[0], "flags", SPOOLSS_FORM_BUILTIN); - - info->info1.form_name = samdb_result_string(msgs[0], "form_name", NULL); - W_ERROR_HAVE_NO_MEMORY(info->info1.form_name); - - info->info1.size.width = samdb_result_uint(msgs[0], "size_width", 0); - info->info1.size.height = samdb_result_uint(msgs[0], "size_height", 0); - - info->info1.area.left = samdb_result_uint(msgs[0], "area_left", 0); - info->info1.area.top = samdb_result_uint(msgs[0], "area_top", 0); - info->info1.area.right = samdb_result_uint(msgs[0], "area_right", 0); - info->info1.area.bottom = samdb_result_uint(msgs[0], "area_bottom", 0); - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - r->out.info = info; - return WERR_OK; -} - static WERROR sptr_SetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, struct spoolss_SetForm *r) { @@ -688,6 +642,60 @@ static WERROR sptr_EnumMonitors(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx return WERR_OK; } +/* Printer Form functions */ +static WERROR sptr_GetPrinterForm(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, + struct spoolss_GetForm *r) +{ + struct ldb_context *sptr_db = talloc_get_type(printer->ntptr->private_data, struct ldb_context); + struct ldb_message **msgs; + const char *base_dn; + int count; + union spoolss_FormInfo *info; + + /* TODO: do checks access here + * if (!(printer->access_mask & desired_access)) { + * return WERR_FOOBAR; + * } + */ + + base_dn = talloc_asprintf(mem_ctx, "CN=Forms,CN=%s,CN=Printers", printer->object_name); + W_ERROR_HAVE_NO_MEMORY(base_dn); + + count = sptr_db_search(sptr_db, mem_ctx, base_dn, &msgs, NULL, + "(&(form_name=%s)(objectClass=form))", + r->in.form_name); + + if (count == 0) return WERR_FOOBAR; + if (count > 1) return WERR_FOOBAR; + if (count < 0) return WERR_GENERAL_FAILURE; + + info = talloc(mem_ctx, union spoolss_FormInfo); + W_ERROR_HAVE_NO_MEMORY(info); + + switch (r->in.level) { + case 1: + info->info1.flags = samdb_result_uint(msgs[0], "flags", SPOOLSS_FORM_BUILTIN); + + info->info1.form_name = samdb_result_string(msgs[0], "form_name", NULL); + W_ERROR_HAVE_NO_MEMORY(info->info1.form_name); + + info->info1.size.width = samdb_result_uint(msgs[0], "size_width", 0); + info->info1.size.height = samdb_result_uint(msgs[0], "size_height", 0); + + info->info1.area.left = samdb_result_uint(msgs[0], "area_left", 0); + info->info1.area.top = samdb_result_uint(msgs[0], "area_top", 0); + info->info1.area.right = samdb_result_uint(msgs[0], "area_right", 0); + info->info1.area.bottom = samdb_result_uint(msgs[0], "area_bottom", 0); + break; + default: + return WERR_UNKNOWN_LEVEL; + } + + r->out.info = info; + return WERR_OK; +} + + /* initialialise the simble ldb backend, registering ourselves with the ntptr subsystem */ @@ -707,7 +715,6 @@ static const struct ntptr_ops ntptr_simple_ldb_ops = { /* PrintServer Form functions */ .EnumPrintServerForms = sptr_EnumPrintServerForms, .AddPrintServerForm = sptr_AddPrintServerForm, - .GetPrintServerForm = sptr_GetPrintServerForm, .SetPrintServerForm = sptr_SetPrintServerForm, .DeletePrintServerForm = sptr_DeletePrintServerForm, @@ -748,8 +755,8 @@ static const struct ntptr_ops ntptr_simple_ldb_ops = { /* Printer Form functions */ /* .EnumPrinterForms = sptr_EnumPrinterForms, .AddPrinterForm = sptr_AddPrinterForm, - .GetPrinterForm = sptr_GetPrinterForm, - .SetPrinterForm = sptr_SetPrinterForm, +*/ .GetPrinterForm = sptr_GetPrinterForm, +/* .SetPrinterForm = sptr_SetPrinterForm, .DeletePrinterForm = sptr_DeletePrinterForm, */ /* Printer Job functions */ |