summaryrefslogtreecommitdiff
path: root/source4/ntptr/simple_ldb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-06-16 20:25:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:17 -0500
commit4f09fce13d16136e96fa05b1c1e3318306dd05b0 (patch)
tree882444c6adac55ef4cb395944f202013abb983ac /source4/ntptr/simple_ldb
parent19c9f032fd65b67529c8b49763a7413899ff5da4 (diff)
downloadsamba-4f09fce13d16136e96fa05b1c1e3318306dd05b0.tar.gz
samba-4f09fce13d16136e96fa05b1c1e3318306dd05b0.tar.bz2
samba-4f09fce13d16136e96fa05b1c1e3318306dd05b0.zip
r7646: - only allow modification of SPOOLSS_FORM_USER Froms
- some minor fixes and comments metze (This used to be commit 87b1f9a2e027f4318a3104d13c091ca8ec5f16f4)
Diffstat (limited to 'source4/ntptr/simple_ldb')
-rw-r--r--source4/ntptr/simple_ldb/ntptr_simple_ldb.c70
1 files changed, 52 insertions, 18 deletions
diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
index 2788489dfe..dc79ba8a1a 100644
--- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
+++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
@@ -185,18 +185,18 @@ static WERROR sptr_EnumPrintServerForms(struct ntptr_GenericHandle *server, TALL
switch (r->in.level) {
case 1:
for (i=0; i < count; i++) {
- info[i].info1.flags = samdb_result_uint(msgs[i], "flags", SPOOLSS_FORM_PRINTER);
+ info[i].info1.flags = samdb_result_uint(msgs[i], "flags", SPOOLSS_FORM_BUILTIN);
- info[i].info1.form_name = samdb_result_string(msgs[i], "form_name", "Letter");
+ info[i].info1.form_name = samdb_result_string(msgs[i], "form_name", NULL);
W_ERROR_HAVE_NO_MEMORY(info[i].info1.form_name);
- info[i].info1.size.width = samdb_result_uint(msgs[i], "size_width", 0x34b5c);
- info[i].info1.size.height = samdb_result_uint(msgs[i], "size_height", 0x44368);
+ info[i].info1.size.width = samdb_result_uint(msgs[i], "size_width", 0);
+ info[i].info1.size.height = samdb_result_uint(msgs[i], "size_height", 0);
info[i].info1.area.left = samdb_result_uint(msgs[i], "area_left", 0);
info[i].info1.area.top = samdb_result_uint(msgs[i], "area_top", 0);
- info[i].info1.area.right = samdb_result_uint(msgs[i], "area_right", 0x34b5c);
- info[i].info1.area.bottom = samdb_result_uint(msgs[i], "area_bottom", 0x44368);
+ info[i].info1.area.right = samdb_result_uint(msgs[i], "area_right", 0);
+ info[i].info1.area.bottom = samdb_result_uint(msgs[i], "area_bottom", 0);
}
break;
default:
@@ -213,10 +213,14 @@ static WERROR sptr_AddPrintServerForm(struct ntptr_GenericHandle *server, TALLOC
{
struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context);
struct ldb_message *msg,**msgs;
- const char * const attrs[] = {"dn", NULL };
+ const char * const attrs[] = {"flags", NULL };
int count, ret;
- /* TODO; do access checks here */
+ /* TODO: do checks access here
+ * if (!(server->access_mask & desired_access)) {
+ * return WERR_FOOBAR;
+ * }
+ */
switch (r->in.level) {
case 1:
@@ -231,6 +235,10 @@ static WERROR sptr_AddPrintServerForm(struct ntptr_GenericHandle *server, TALLOC
if (count > 1) return WERR_FOOBAR;
if (count < 0) return WERR_GENERAL_FAILURE;
+ if (r->in.info.info1->flags != SPOOLSS_FORM_USER) {
+ return WERR_FOOBAR;
+ }
+
msg = ldb_msg_new(mem_ctx);
W_ERROR_HAVE_NO_MEMORY(msg);
@@ -271,6 +279,12 @@ static WERROR sptr_GetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC
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);
@@ -284,18 +298,18 @@ static WERROR sptr_GetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC
switch (r->in.level) {
case 1:
- info->info1.flags = samdb_result_uint(msgs[0], "flags", SPOOLSS_FORM_PRINTER);
+ info->info1.flags = samdb_result_uint(msgs[0], "flags", SPOOLSS_FORM_BUILTIN);
- info->info1.form_name = samdb_result_string(msgs[0], "form_name", "Letter");
+ 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", 0x34b5c);
- info->info1.size.height = samdb_result_uint(msgs[0], "size_height", 0x44368);
+ 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", 0x34b5c);
- info->info1.area.bottom = samdb_result_uint(msgs[0], "area_bottom", 0x44368);
+ 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;
@@ -310,10 +324,15 @@ static WERROR sptr_SetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC
{
struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context);
struct ldb_message *msg,**msgs;
- const char * const attrs[] = { "ntSecurityDescriptor", NULL};
+ const char * const attrs[] = { "flags", NULL};
int count, ret;
+ enum spoolss_FormFlags flags;
- /* TODO: do checks access here */
+ /* TODO: do checks access here
+ * if (!(server->access_mask & desired_access)) {
+ * return WERR_FOOBAR;
+ * }
+ */
switch (r->in.level) {
case 1:
@@ -329,6 +348,11 @@ static WERROR sptr_SetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC
if (count > 1) return WERR_FOOBAR;
if (count < 0) return WERR_GENERAL_FAILURE;
+ flags = samdb_result_uint(msgs[0], "flags", SPOOLSS_FORM_BUILTIN);
+ if (flags != SPOOLSS_FORM_USER) {
+ return WERR_FOOBAR;
+ }
+
msg = ldb_msg_new(mem_ctx);
W_ERROR_HAVE_NO_MEMORY(msg);
@@ -364,10 +388,15 @@ static WERROR sptr_DeletePrintServerForm(struct ntptr_GenericHandle *server, TAL
{
struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context);
struct ldb_message **msgs;
- const char * const attrs[] = { "ntSecurityDescriptor", NULL};
+ const char * const attrs[] = { "flags", NULL};
int count, ret;
+ enum spoolss_FormFlags flags;
- /* TODO: do checks access here */
+ /* TODO: do checks access here
+ * if (!(server->access_mask & desired_access)) {
+ * return WERR_FOOBAR;
+ * }
+ */
if (!r->in.form_name) {
return WERR_FOOBAR;
@@ -381,6 +410,11 @@ static WERROR sptr_DeletePrintServerForm(struct ntptr_GenericHandle *server, TAL
if (count > 1) return WERR_FOOBAR;
if (count < 0) return WERR_GENERAL_FAILURE;
+ flags = samdb_result_uint(msgs[0], "flags", SPOOLSS_FORM_BUILTIN);
+ if (flags != SPOOLSS_FORM_USER) {
+ return WERR_FOOBAR;
+ }
+
ret = samdb_delete(sptr_db, mem_ctx, msgs[0]->dn);
if (ret != 0) {
return WERR_FOOBAR;