diff options
-rw-r--r-- | source4/ntptr/ntptr.h | 240 | ||||
-rw-r--r-- | source4/ntptr/ntptr_base.c | 153 | ||||
-rw-r--r-- | source4/ntptr/ntptr_interface.c | 604 | ||||
-rw-r--r-- | source4/ntptr/simple_ldb/ntptr_simple_ldb.c | 932 | ||||
-rw-r--r-- | source4/ntptr/wscript_build | 18 | ||||
-rw-r--r-- | source4/rpc_server/spoolss/dcesrv_spoolss.c | 1772 | ||||
-rwxr-xr-x | source4/rpc_server/wscript_build | 10 | ||||
-rw-r--r-- | source4/smbd/server.c | 4 | ||||
-rw-r--r-- | source4/smbd/wscript_build | 2 | ||||
-rw-r--r-- | wscript_build | 1 |
10 files changed, 1 insertions, 3735 deletions
diff --git a/source4/ntptr/ntptr.h b/source4/ntptr/ntptr.h deleted file mode 100644 index 91817a202f2..00000000000 --- a/source4/ntptr/ntptr.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - NTPTR structures and defines - - Copyright (C) Stefan (metze) Metzmacher 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* modules can use the following to determine if the interface has changed */ -#define NTPTR_INTERFACE_VERSION 0 - -struct ntptr_context; - -enum ntptr_HandleType { - NTPTR_HANDLE_SERVER, - NTPTR_HANDLE_PRINTER, - NTPTR_HANDLE_PORT, - NTPTR_HANDLE_MONITOR -}; - -struct ntptr_GenericHandle { - enum ntptr_HandleType type; - struct ntptr_context *ntptr; - const char *object_name; - uint32_t access_mask; - void *private_data; -}; - -struct spoolss_OpenPrinterEx; -struct spoolss_EnumPrinterData; -struct spoolss_DeletePrinterData; -struct spoolss_AddForm; -struct spoolss_GetForm; -struct spoolss_SetForm; -struct spoolss_DeleteForm; -struct spoolss_AddPrinterDriver; -struct spoolss_DeletePrinterDriver; -struct spoolss_GetPrinterDriverDirectory; -struct spoolss_AddPrinter; -struct spoolss_GetPrinter; -struct spoolss_SetPrinter; -struct spoolss_DeletePrinter; -struct spoolss_GetPrinterDriver; -struct spoolss_AddJob; -struct spoolss_EnumJobs; -struct spoolss_SetJob; -struct spoolss_GetJob; -struct spoolss_ScheduleJob; -struct spoolss_ReadPrinter; -struct spoolss_WritePrinter; -struct spoolss_StartDocPrinter; -struct spoolss_EndDocPrinter; -struct spoolss_StartPagePrinter; -struct spoolss_EndPagePrinter; -struct spoolss_GetPrinterData; -struct spoolss_SetPrinterData; -struct spoolss_EnumPrinterDrivers; -struct spoolss_EnumMonitors; -struct spoolss_EnumPrinters; -struct spoolss_EnumForms; -struct spoolss_EnumPorts; -struct spoolss_EnumPrintProcessors; -struct spoolss_XcvData; -struct spoolss_GetPrintProcessorDirectory; - -/* the ntptr operations structure - contains function pointers to - the backend implementations of each operation */ -struct ntptr_ops { - const char *name; - - /* initial setup */ - NTSTATUS (*init_context)(struct ntptr_context *ntptr); - - /* PrintServer functions */ - WERROR (*OpenPrintServer)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *printer_name, - struct ntptr_GenericHandle **server); - WERROR (*XcvDataPrintServer)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r); - - /* PrintServer PrinterData functions */ - WERROR (*EnumPrintServerData)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterData *r); - WERROR (*GetPrintServerData)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterData *r); - WERROR (*SetPrintServerData)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinterData *r); - WERROR (*DeletePrintServerData)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterData *r); - - /* PrintServer Form functions */ - WERROR (*EnumPrintServerForms)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_EnumForms *r); - WERROR (*AddPrintServerForm)(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_AddForm *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, - struct spoolss_DeleteForm *r); - - /* PrintServer Driver functions */ - WERROR (*EnumPrinterDrivers)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterDrivers *r); - WERROR (*AddPrinterDriver)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinterDriver *r); - WERROR (*DeletePrinterDriver)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterDriver *r); - WERROR (*GetPrinterDriverDirectory)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriverDirectory *r); - - /* Port functions */ - WERROR (*EnumPorts)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPorts *r); - WERROR (*OpenPort)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *port_name, - struct ntptr_GenericHandle **port); - WERROR (*XcvDataPort)(struct ntptr_GenericHandle *port, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r); - - /* Monitor functions */ - WERROR (*EnumMonitors)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumMonitors *r); - WERROR (*OpenMonitor)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *monitor_name, - struct ntptr_GenericHandle **monitor); - WERROR (*XcvDataMonitor)(struct ntptr_GenericHandle *monitor, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r); - - /* PrintProcessor functions */ - WERROR (*EnumPrintProcessors)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrintProcessors *r); - WERROR (*GetPrintProcessorDirectory)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrintProcessorDirectory *r); - - /* Printer functions */ - WERROR (*EnumPrinters)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinters *r); - WERROR (*OpenPrinter)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *printer_name, - struct ntptr_GenericHandle **printer); - WERROR (*AddPrinter)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinter *r, - struct ntptr_GenericHandle **printer); - WERROR (*GetPrinter)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinter *r); - WERROR (*SetPrinter)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinter *r); - WERROR (*DeletePrinter)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinter *r); - WERROR (*XcvDataPrinter)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r); - - /* Printer Driver functions */ - WERROR (*GetPrinterDriver)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriver *r); - - /* Printer PrinterData functions */ - WERROR (*EnumPrinterData)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterData *r); - WERROR (*GetPrinterData)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterData *r); - WERROR (*SetPrinterData)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinterData *r); - WERROR (*DeletePrinterData)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterData *r); - - /* Printer Form functions */ - WERROR (*EnumPrinterForms)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EnumForms *r); - WERROR (*AddPrinterForm)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_AddForm *r); - WERROR (*GetPrinterForm)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_GetForm *r); - WERROR (*SetPrinterForm)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_SetForm *r); - WERROR (*DeletePrinterForm)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_DeleteForm *r); - - /* Printer Job functions */ - WERROR (*EnumJobs)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EnumJobs *r); - WERROR (*AddJob)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_AddJob *r); - WERROR (*ScheduleJob)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_ScheduleJob *r); - WERROR (*GetJob)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_GetJob *r); - WERROR (*SetJob)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_SetJob *r); - - /* Printer Printing functions */ - WERROR (*StartDocPrinter)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_StartDocPrinter *r); - WERROR (*EndDocPrinter)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EndDocPrinter *r); - WERROR (*StartPagePrinter)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_StartPagePrinter *r); - WERROR (*EndPagePrinter)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EndPagePrinter *r); - WERROR (*WritePrinter)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_WritePrinter *r); - WERROR (*ReadPrinter)(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_ReadPrinter *r); -}; - -struct ntptr_context { - const struct ntptr_ops *ops; - void *private_data; - struct tevent_context *ev_ctx; - struct loadparm_context *lp_ctx; -}; - -/* this structure is used by backends to determine the size of some critical types */ -struct ntptr_critical_sizes { - int interface_version; - int sizeof_ntptr_critical_sizes; - int sizeof_ntptr_context; - int sizeof_ntptr_ops; -}; - -struct loadparm_context; - -#include "ntptr/ntptr_proto.h" diff --git a/source4/ntptr/ntptr_base.c b/source4/ntptr/ntptr_base.c deleted file mode 100644 index 3fe8960602a..00000000000 --- a/source4/ntptr/ntptr_base.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - NTPTR base code - - Copyright (C) Stefan (metze) Metzmacher 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ -/* - this implements the core code for all NTPTR modules. Backends register themselves here. -*/ - -#include "includes.h" -#include "ntptr/ntptr.h" -#include "param/param.h" -#include "lib/util/samba_modules.h" - -/* the list of currently registered NTPTR backends */ -static struct ntptr_backend { - const struct ntptr_ops *ops; -} *backends = NULL; -static int num_backends; - -/* - register a NTPTR backend. - - The 'name' can be later used by other backends to find the operations - structure for this backend. -*/ -NTSTATUS ntptr_register(const void *_ops) -{ - const struct ntptr_ops *ops = _ops; - struct ntptr_ops *new_ops; - - if (ntptr_backend_byname(ops->name) != NULL) { - /* its already registered! */ - DEBUG(0,("NTPTR backend '%s' already registered\n", - ops->name)); - return NT_STATUS_OBJECT_NAME_COLLISION; - } - - backends = realloc_p(backends, struct ntptr_backend, num_backends+1); - if (!backends) { - smb_panic("out of memory in ntptr_register"); - } - - new_ops = smb_xmemdup(ops, sizeof(*ops)); - new_ops->name = smb_xstrdup(ops->name); - - backends[num_backends].ops = new_ops; - - num_backends++; - - DEBUG(3,("NTPTR backend '%s'\n", - ops->name)); - - return NT_STATUS_OK; -} - -NTSTATUS ntptr_init(void) -{ -#define _MODULE_PROTO(init) extern NTSTATUS init(void); - STATIC_ntptr_MODULES_PROTO; - init_module_fn static_init[] = { STATIC_ntptr_MODULES }; - init_module_fn *shared_init = load_samba_modules(NULL, "ntptr"); - - run_init_functions(static_init); - run_init_functions(shared_init); - - talloc_free(shared_init); - - return NT_STATUS_OK; -} - - -/* - return the operations structure for a named backend -*/ -const struct ntptr_ops *ntptr_backend_byname(const char *name) -{ - int i; - - for (i=0;i<num_backends;i++) { - if (strcmp(backends[i].ops->name, name) == 0) { - return backends[i].ops; - } - } - - return NULL; -} - - -/* - return the NTPTR interface version, and the size of some critical types - This can be used by backends to either detect compilation errors, or provide - multiple implementations for different smbd compilation options in one module -*/ -static const struct ntptr_critical_sizes critical_sizes = { - .interface_version = NTPTR_INTERFACE_VERSION, - .sizeof_ntptr_critical_sizes = sizeof(struct ntptr_critical_sizes), - .sizeof_ntptr_context = sizeof(struct ntptr_context), - .sizeof_ntptr_ops = sizeof(struct ntptr_ops), -}; -const struct ntptr_critical_sizes *ntptr_interface_version(void) -{ - return &critical_sizes; -} - -/* - create a ntptr_context with a specified NTPTR backend -*/ -NTSTATUS ntptr_init_context(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx, - struct loadparm_context *lp_ctx, - const char *providor, struct ntptr_context **_ntptr) -{ - NTSTATUS status; - struct ntptr_context *ntptr; - - if (!providor) { - return NT_STATUS_INTERNAL_ERROR; - } - - ntptr = talloc(mem_ctx, struct ntptr_context); - NT_STATUS_HAVE_NO_MEMORY(ntptr); - ntptr->private_data = NULL; - ntptr->ops = ntptr_backend_byname(providor); - ntptr->ev_ctx = ev_ctx; - ntptr->lp_ctx = lp_ctx; - - if (!ntptr->ops) { - DEBUG(1,("ntptr_init_context: failed to find NTPTR providor='%s'\n", - providor)); - return NT_STATUS_INTERNAL_ERROR; - } - - status = ntptr->ops->init_context(ntptr); - NT_STATUS_NOT_OK_RETURN(status); - - *_ntptr = ntptr; - return NT_STATUS_OK; -} diff --git a/source4/ntptr/ntptr_interface.c b/source4/ntptr/ntptr_interface.c deleted file mode 100644 index b65a2e32cd5..00000000000 --- a/source4/ntptr/ntptr_interface.c +++ /dev/null @@ -1,604 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - NTPTR interface functions - - Copyright (C) Stefan (metze) Metzmacher 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "ntptr/ntptr.h" - - -/* PrintServer functions */ -WERROR ntptr_OpenPrintServer(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *printer_name, - struct ntptr_GenericHandle **server) -{ - if (!ntptr->ops->OpenPrintServer) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->OpenPrintServer(ntptr, mem_ctx, r, printer_name, server); -} - -WERROR ntptr_XcvDataPrintServer(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->XcvDataPrintServer) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->XcvDataPrintServer(server, mem_ctx, r); -} - - -/* PrintServer PrinterData functions */ -WERROR ntptr_EnumPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterData *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->EnumPrintServerData) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->EnumPrintServerData(server, mem_ctx, r); -} - -WERROR ntptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterData *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->GetPrintServerData) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->GetPrintServerData(server, mem_ctx, r); -} - -WERROR ntptr_SetPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinterData *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->SetPrintServerData) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->SetPrintServerData(server, mem_ctx, r); -} - -WERROR ntptr_DeletePrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterData *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->DeletePrintServerData) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->DeletePrintServerData(server, mem_ctx, r); -} - - -/* PrintServer Form functions */ -WERROR ntptr_EnumPrintServerForms(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_EnumForms *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->EnumPrintServerForms) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->EnumPrintServerForms(server, mem_ctx, r); -} - -WERROR ntptr_AddPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_AddForm *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->AddPrintServerForm) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->AddPrintServerForm(server, mem_ctx, r); -} - -WERROR ntptr_SetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_SetForm *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->SetPrintServerForm) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->SetPrintServerForm(server, mem_ctx, r); -} - -WERROR ntptr_DeletePrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_DeleteForm *r) -{ - if (server->type != NTPTR_HANDLE_SERVER) { - return WERR_FOOBAR; - } - if (!server->ntptr->ops->DeletePrintServerForm) { - return WERR_NOT_SUPPORTED; - } - return server->ntptr->ops->DeletePrintServerForm(server, mem_ctx, r); -} - - -/* PrintServer Driver functions */ -WERROR ntptr_EnumPrinterDrivers(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterDrivers *r) -{ - if (!ntptr->ops->EnumPrinterDrivers) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->EnumPrinterDrivers(ntptr, mem_ctx, r); -} - -WERROR ntptr_AddPrinterDriver(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinterDriver *r) -{ - if (!ntptr->ops->AddPrinterDriver) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->AddPrinterDriver(ntptr, mem_ctx, r); -} - -WERROR ntptr_DeletePrinterDriver(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterDriver *r) -{ - if (!ntptr->ops->DeletePrinterDriver) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->DeletePrinterDriver(ntptr, mem_ctx, r); -} - -WERROR ntptr_GetPrinterDriverDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriverDirectory *r) -{ - if (!ntptr->ops->GetPrinterDriverDirectory) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->GetPrinterDriverDirectory(ntptr, mem_ctx, r); -} - - -/* Port functions */ -WERROR ntptr_EnumPorts(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPorts *r) -{ - if (!ntptr->ops->EnumPorts) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->EnumPorts(ntptr, mem_ctx, r); -} - -WERROR ntptr_OpenPort(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *port_name, - struct ntptr_GenericHandle **port) -{ - if (!ntptr->ops->OpenPort) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->OpenPort(ntptr, mem_ctx, r, port_name, port); -} - -WERROR ntptr_XcvDataPort(struct ntptr_GenericHandle *port, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r) -{ - if (port->type != NTPTR_HANDLE_PORT) { - return WERR_FOOBAR; - } - if (!port->ntptr->ops->XcvDataPort) { - return WERR_NOT_SUPPORTED; - } - return port->ntptr->ops->XcvDataPort(port, mem_ctx, r); -} - -/* Monitor functions */ -WERROR ntptr_EnumMonitors(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumMonitors *r) -{ - if (!ntptr->ops->EnumMonitors) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->EnumMonitors(ntptr, mem_ctx, r); -} - -WERROR ntptr_OpenMonitor(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *monitor_name, - struct ntptr_GenericHandle **monitor) -{ - if (!ntptr->ops->OpenMonitor) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->OpenMonitor(ntptr, mem_ctx, r, monitor_name, monitor); -} - -WERROR ntptr_XcvDataMonitor(struct ntptr_GenericHandle *monitor, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r) -{ - if (monitor->type != NTPTR_HANDLE_MONITOR) { - return WERR_FOOBAR; - } - if (!monitor->ntptr->ops->XcvDataMonitor) { - return WERR_NOT_SUPPORTED; - } - return monitor->ntptr->ops->XcvDataMonitor(monitor, mem_ctx, r); -} - - -/* PrintProcessor functions */ -WERROR ntptr_EnumPrintProcessors(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrintProcessors *r) -{ - if (!ntptr->ops->EnumPrintProcessors) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->EnumPrintProcessors(ntptr, mem_ctx, r); -} - -WERROR ntptr_GetPrintProcessorDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrintProcessorDirectory *r) -{ - if (!ntptr->ops->GetPrintProcessorDirectory) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->GetPrintProcessorDirectory(ntptr, mem_ctx, r); -} - - -/* Printer functions */ -WERROR ntptr_EnumPrinters(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinters *r) -{ - if (!ntptr->ops->EnumPrinters) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->EnumPrinters(ntptr, mem_ctx, r); -} - -WERROR ntptr_OpenPrinter(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *printer_name, - struct ntptr_GenericHandle **printer) -{ - if (!ntptr->ops->OpenPrinter) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->OpenPrinter(ntptr, mem_ctx, r, printer_name, printer); -} - -WERROR ntptr_AddPrinter(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinter *r, - struct ntptr_GenericHandle **printer) -{ - if (!ntptr->ops->AddPrinter) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->AddPrinter(ntptr, mem_ctx, r, printer); -} - -WERROR ntptr_GetPrinter(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinter *r) -{ - if (!ntptr->ops->GetPrinter) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->GetPrinter(ntptr, mem_ctx, r); -} - -WERROR ntptr_SetPrinter(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinter *r) -{ - if (!ntptr->ops->SetPrinter) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->SetPrinter(ntptr, mem_ctx, r); -} - -WERROR ntptr_DeletePrinter(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinter *r) -{ - if (!ntptr->ops->DeletePrinter) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->DeletePrinter(ntptr, mem_ctx, r); -} - -WERROR ntptr_XcvDataPrinter(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->XcvDataPrinter) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->XcvDataPrinter(printer, mem_ctx, r); -} - - -/* Printer Driver functions */ -WERROR ntptr_GetPrinterDriver(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriver *r) -{ - if (!ntptr->ops->GetPrinterDriver) { - return WERR_NOT_SUPPORTED; - } - return ntptr->ops->GetPrinterDriver(ntptr, mem_ctx, r); -} - - -/* Printer PrinterData functions */ -WERROR ntptr_EnumPrinterData(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterData *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->EnumPrinterData) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->EnumPrinterData(printer, mem_ctx, r); -} - -WERROR ntptr_GetPrinterData(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterData *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->GetPrinterData) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->GetPrinterData(printer, mem_ctx, r); -} - -WERROR ntptr_SetPrinterData(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinterData *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->SetPrinterData) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->SetPrinterData(printer, mem_ctx, r); -} - -WERROR ntptr_DeletePrinterData(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterData *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->DeletePrinterData) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->DeletePrinterData(printer, mem_ctx, r); -} - - -/* Printer Form functions */ -WERROR ntptr_EnumPrinterForms(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EnumForms *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->EnumPrinterForms) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->EnumPrinterForms(printer, mem_ctx, r); -} - -WERROR ntptr_AddPrinterForm(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_AddForm *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->AddPrinterForm) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->AddPrinterForm(printer, mem_ctx, r); -} - -WERROR ntptr_GetPrinterForm(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_GetForm *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->GetPrinterForm) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->GetPrinterForm(printer, mem_ctx, r); -} - -WERROR ntptr_SetPrinterForm(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_SetForm *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->SetPrinterForm) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->SetPrinterForm(printer, mem_ctx, r); -} - -WERROR ntptr_DeletePrinterForm(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_DeleteForm *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->DeletePrinterForm) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->DeletePrinterForm(printer, mem_ctx, r); -} - - -/* Printer Job functions */ -WERROR ntptr_EnumJobs(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EnumJobs *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->EnumJobs) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->EnumJobs(printer, mem_ctx, r); -} - -WERROR ntptr_AddJob(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_AddJob *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->AddJob) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->AddJob(printer, mem_ctx, r); -} - -WERROR ntptr_ScheduleJob(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_ScheduleJob *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->ScheduleJob) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->ScheduleJob(printer, mem_ctx, r); -} - -WERROR ntptr_GetJob(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_GetJob *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->GetJob) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->GetJob(printer, mem_ctx, r); -} - -WERROR ntptr_SetJob(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_SetJob *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->SetJob) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->SetJob(printer, mem_ctx, r); -} - - -/* Printer Printing functions */ -WERROR ntptr_StartDocPrinter(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_StartDocPrinter *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->StartDocPrinter) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->StartDocPrinter(printer, mem_ctx, r); -} - -WERROR ntptr_EndDocPrinter(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EndDocPrinter *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->EndDocPrinter) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->EndDocPrinter(printer, mem_ctx, r); -} - -WERROR ntptr_StartPagePrinter(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_StartPagePrinter *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->StartPagePrinter) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->StartPagePrinter(printer, mem_ctx, r); -} - -WERROR ntptr_EndPagePrinter(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_EndPagePrinter *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->EndPagePrinter) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->EndPagePrinter(printer, mem_ctx, r); -} - -WERROR ntptr_WritePrinter(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_WritePrinter *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->WritePrinter) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->WritePrinter(printer, mem_ctx, r); -} - -WERROR ntptr_ReadPrinter(struct ntptr_GenericHandle *printer, TALLOC_CTX *mem_ctx, - struct spoolss_ReadPrinter *r) -{ - if (printer->type != NTPTR_HANDLE_PRINTER) { - return WERR_FOOBAR; - } - if (!printer->ntptr->ops->ReadPrinter) { - return WERR_NOT_SUPPORTED; - } - return printer->ntptr->ops->ReadPrinter(printer, mem_ctx, r); -} - diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c deleted file mode 100644 index fe81a0fec72..00000000000 --- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c +++ /dev/null @@ -1,932 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Simple LDB NTPTR backend - - Copyright (C) Stefan (metze) Metzmacher 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ -/* - This implements a NTPTR backend that store - all objects (Printers, Ports, Monitors, PrinterDrivers ...) - in a ldb database, but doesn't do real printing. - - This is just used for testing how some of - the SPOOLSS protocol details should work -*/ - -#include "includes.h" -#include "ntptr/ntptr.h" -#include "librpc/gen_ndr/ndr_spoolss.h" -#include <ldb.h> -#include "auth/auth.h" -#include "dsdb/samdb/samdb.h" -#include "ldb_wrap.h" -#include "../lib/util/util_ldb.h" -#include "librpc/gen_ndr/dcerpc.h" -#include "rpc_server/dcerpc_server.h" -#include "rpc_server/common/common.h" -#include "param/param.h" - -NTSTATUS ntptr_simple_ldb_init(void); - -/* - connect to the SPOOLSS database - return a ldb_context pointer on success, or NULL on failure - */ -static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx, struct loadparm_context *lp_ctx) -{ - return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, "spoolss.ldb", system_session(lp_ctx), - NULL, 0); -} - -static int sptr_db_search(struct ldb_context *ldb, - TALLOC_CTX *mem_ctx, - struct ldb_dn *basedn, - struct ldb_message ***res, - const char * const *attrs, - const char *format, ...) PRINTF_ATTRIBUTE(6,7); - -static int sptr_db_search(struct ldb_context *ldb, - TALLOC_CTX *mem_ctx, - struct ldb_dn *basedn, - struct ldb_message ***res, - const char * const *attrs, - const char *format, ...) -{ - va_list ap; - int count; - - va_start(ap, format); - count = gendb_search_v(ldb, mem_ctx, basedn, res, attrs, format, ap); - va_end(ap); - - return count; -} - -#define SET_STRING(ldb, mod, attr, value) do { \ - if (value == NULL) return WERR_INVALID_PARAM; \ - if (ldb_msg_add_string(mod, attr, value) != LDB_SUCCESS) { \ - return WERR_NOMEM; \ - } \ -} while (0) - -#define SET_UINT(ldb, mod, attr, value) do { \ - if (samdb_msg_add_uint(ldb, (TALLOC_CTX *)mod, mod, attr, value) != LDB_SUCCESS) { \ - return WERR_NOMEM; \ - } \ -} while (0) - -static NTSTATUS sptr_init_context(struct ntptr_context *ntptr) -{ - struct ldb_context *sptr_db = sptr_db_connect(ntptr, ntptr->ev_ctx, ntptr->lp_ctx); - NT_STATUS_HAVE_NO_MEMORY(sptr_db); - - ntptr->private_data = sptr_db; - - return NT_STATUS_OK; -} - -/* PrintServer functions */ -static WERROR sptr_OpenPrintServer(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *server_name, - struct ntptr_GenericHandle **_server) -{ - struct ntptr_GenericHandle *server; - - /* TODO: do access check here! */ - - server = talloc(mem_ctx, struct ntptr_GenericHandle); - W_ERROR_HAVE_NO_MEMORY(server); - - server->type = NTPTR_HANDLE_SERVER; - server->ntptr = ntptr; - 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; - return WERR_OK; -} - -/* - * PrintServer PrinterData functions - */ - -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 = lpcfg_dcerpc_server_info(mem_ctx, server->ntptr->lp_ctx); - if (strcmp("W3SvcInstalled", value_name) == 0) { - *type = REG_DWORD; - r->value = 0; - return WERR_OK; - } else if (strcmp("BeepEnabled", value_name) == 0) { - *type = REG_DWORD; - r->value = 0; - return WERR_OK; - } else if (strcmp("EventLog", value_name) == 0) { - *type = REG_DWORD; - r->value = 0; - return WERR_OK; - } else if (strcmp("NetPopup", value_name) == 0) { - *type = REG_DWORD; - r->value = 0; - return WERR_OK; - } else if (strcmp("NetPopupToComputer", value_name) == 0) { - *type = REG_DWORD; - r->value = 0; - return WERR_OK; - } else if (strcmp("MajorVersion", value_name) == 0) { - *type = REG_DWORD; - r->value = 3; - return WERR_OK; - } else if (strcmp("MinorVersion", value_name) == 0) { - *type = REG_DWORD; - r->value = 0; - return WERR_OK; - } else if (strcmp("DefaultSpoolDirectory", value_name) == 0) { - *type = REG_SZ; - r->string = "C:\\PRINTERS"; - return WERR_OK; - } else if (strcmp("Architecture", value_name) == 0) { - *type = REG_SZ; - r->string = SPOOLSS_ARCHITECTURE_NT_X86; - return WERR_OK; - } else if (strcmp("DsPresent", value_name) == 0) { - *type = REG_DWORD; - r->value = 1; - return WERR_OK; - } else if (strcmp("OSVersion", value_name) == 0) { - DATA_BLOB blob; - enum ndr_err_code ndr_err; - struct spoolss_OSVersion os; - - os.major = server_info->version_major; - os.minor = server_info->version_minor; - os.build = server_info->version_build; - os.extra_string = ""; - - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &os, (ndr_push_flags_fn_t)ndr_push_spoolss_OSVersion); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return WERR_GENERAL_FAILURE; - } - - *type = REG_BINARY; - r->binary = blob; - return WERR_OK; - } else if (strcmp("OSVersionEx", value_name) == 0) { - DATA_BLOB blob; - enum ndr_err_code ndr_err; - struct spoolss_OSVersionEx os_ex; - - os_ex.major = server_info->version_major; - os_ex.minor = server_info->version_minor; - os_ex.build = server_info->version_build; - os_ex.extra_string = ""; - os_ex.service_pack_major= 0; - os_ex.service_pack_minor= 0; - os_ex.suite_mask = 0; - os_ex.product_type = 0; - os_ex.reserved = 0; - - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &os_ex, (ndr_push_flags_fn_t)ndr_push_spoolss_OSVersionEx); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return WERR_GENERAL_FAILURE; - } - - *type = REG_BINARY; - r->binary = blob; - return WERR_OK; - } else if (strcmp("DNSMachineName", value_name) == 0) { - const char *dnsdomain = lpcfg_dnsdomain(server->ntptr->lp_ctx); - - if (dnsdomain == NULL) return WERR_INVALID_PARAM; - - *type = REG_SZ; - r->string = talloc_asprintf(mem_ctx, "%s.%s", - lpcfg_netbios_name(server->ntptr->lp_ctx), - dnsdomain); - 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, - &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) -{ - struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context); - struct ldb_message **msgs; - int count; - int i; - union spoolss_FormInfo *info; - - count = sptr_db_search(sptr_db, mem_ctx, - ldb_dn_new(mem_ctx, sptr_db, "CN=Forms,CN=PrintServer"), - &msgs, NULL, "(&(objectClass=form))"); - - if (count == 0) return WERR_OK; - if (count < 0) return WERR_GENERAL_FAILURE; - - info = talloc_array(mem_ctx, union spoolss_FormInfo, count); - W_ERROR_HAVE_NO_MEMORY(info); - - switch (r->in.level) { - case 1: - for (i=0; i < count; i++) { - info[i].info1.flags = ldb_msg_find_attr_as_uint(msgs[i], "flags", SPOOLSS_FORM_BUILTIN); - - info[i].info1.form_name = ldb_msg_find_attr_as_string(msgs[i], "form-name", NULL); - W_ERROR_HAVE_NO_MEMORY(info[i].info1.form_name); - - info[i].info1.size.width = ldb_msg_find_attr_as_uint(msgs[i], "size-width", 0); - info[i].info1.size.height = ldb_msg_find_attr_as_uint(msgs[i], "size-height", 0); - - info[i].info1.area.left = ldb_msg_find_attr_as_uint(msgs[i], "area-left", 0); - info[i].info1.area.top = ldb_msg_find_attr_as_uint(msgs[i], "area-top", 0); - info[i].info1.area.right = ldb_msg_find_attr_as_uint(msgs[i], "area-right", 0); - info[i].info1.area.bottom = ldb_msg_find_attr_as_uint(msgs[i], "area-bottom", 0); - } - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - *r->out.info = info; - *r->out.count = count; - return WERR_OK; -} - -static WERROR sptr_AddPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_AddForm *r) -{ - struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context); - struct ldb_message *msg,**msgs; - const char * const attrs[] = {"flags", NULL }; - int count, ret; - - /* TODO: do checks access here - * if (!(server->access_mask & desired_access)) { - * return WERR_FOOBAR; - * } - */ - - switch (r->in.info_ctr->level) { - case 1: - if (!r->in.info_ctr->info.info1) { - return WERR_FOOBAR; - } - count = sptr_db_search(sptr_db, mem_ctx, - ldb_dn_new(mem_ctx, sptr_db, "CN=Forms,CN=PrintServer"), - &msgs, attrs, "(&(form-name=%s)(objectClass=form))", - r->in.info_ctr->info.info1->form_name); - - if (count == 1) return WERR_FOOBAR; - if (count > 1) return WERR_FOOBAR; - if (count < 0) return WERR_GENERAL_FAILURE; - - if (r->in.info_ctr->info.info1->flags != SPOOLSS_FORM_USER) { - return WERR_FOOBAR; - } - - msg = ldb_msg_new(mem_ctx); - W_ERROR_HAVE_NO_MEMORY(msg); - - /* add core elements to the ldb_message for the Form */ - msg->dn = ldb_dn_new_fmt(msg, sptr_db, "form-name=%s,CN=Forms,CN=PrintServer", r->in.info_ctr->info.info1->form_name); - SET_STRING(sptr_db, msg, "objectClass", "form"); - - SET_UINT(sptr_db, msg, "flags", r->in.info_ctr->info.info1->flags); - - SET_STRING(sptr_db, msg, "form-name", r->in.info_ctr->info.info1->form_name); - - SET_UINT(sptr_db, msg, "size-width", r->in.info_ctr->info.info1->size.width); - SET_UINT(sptr_db, msg, "size-height", r->in.info_ctr->info.info1->size.height); - - SET_UINT(sptr_db, msg, "area-left", r->in.info_ctr->info.info1->area.left); - SET_UINT(sptr_db, msg, "area-top", r->in.info_ctr->info.info1->area.top); - SET_UINT(sptr_db, msg, "area-right", r->in.info_ctr->info.info1->area.right); - SET_UINT(sptr_db, msg, "area-bottom", r->in.info_ctr->info.info1->area.bottom); - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - ret = ldb_add(sptr_db, msg); - if (ret != 0) { - return WERR_FOOBAR; - } - - return WERR_OK; -} - -static WERROR sptr_SetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_SetForm *r) -{ - struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context); - struct ldb_message *msg,**msgs; - const char * const attrs[] = { "flags", NULL}; - int count, ret; - enum spoolss_FormFlags flags; - - /* TODO: do checks access here - * if (!(server->access_mask & desired_access)) { - * return WERR_FOOBAR; - * } - */ - - switch (r->in.info_ctr->level) { - case 1: - if (!r->in.info_ctr->info.info1) { - return WERR_FOOBAR; - } - - count = sptr_db_search(sptr_db, mem_ctx, - ldb_dn_new(mem_ctx, sptr_db, "CN=Forms,CN=PrintServer"), - &msgs, attrs, "(&(form-name=%s)(objectClass=form))", - r->in.info_ctr->info.info1->form_name); - - if (count == 0) return WERR_FOOBAR; - if (count > 1) return WERR_FOOBAR; - if (count < 0) return WERR_GENERAL_FAILURE; - - flags = ldb_msg_find_attr_as_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); - - /* add core elements to the ldb_message for the user */ - msg->dn = msgs[0]->dn; - - SET_UINT(sptr_db, msg, "flags", r->in.info_ctr->info.info1->flags); - - SET_STRING(sptr_db, msg, "form-name", r->in.info_ctr->info.info1->form_name); - - SET_UINT(sptr_db, msg, "size-width", r->in.info_ctr->info.info1->size.width); - SET_UINT(sptr_db, msg, "size-height", r->in.info_ctr->info.info1->size.height); - - SET_UINT(sptr_db, msg, "area-left", r->in.info_ctr->info.info1->area.left); - SET_UINT(sptr_db, msg, "area-top", r->in.info_ctr->info.info1->area.top); - SET_UINT(sptr_db, msg, "area-right", r->in.info_ctr->info.info1->area.right); - SET_UINT(sptr_db, msg, "area-bottom", r->in.info_ctr->info.info1->area.bottom); - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - ret = dsdb_replace(sptr_db, msg, 0); - if (ret != 0) { - return WERR_FOOBAR; - } - - return WERR_OK; -} - -static WERROR sptr_DeletePrintServerForm(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, - struct spoolss_DeleteForm *r) -{ - struct ldb_context *sptr_db = talloc_get_type(server->ntptr->private_data, struct ldb_context); - struct ldb_message **msgs; - const char * const attrs[] = { "flags", NULL}; - int count, ret; - enum spoolss_FormFlags flags; - - /* TODO: do checks access here - * if (!(server->access_mask & desired_access)) { - * return WERR_FOOBAR; - * } - */ - - if (!r->in.form_name) { - return WERR_FOOBAR; - } - - count = sptr_db_search(sptr_db, mem_ctx, - ldb_dn_new(mem_ctx, sptr_db, "CN=Forms,CN=PrintServer"), - &msgs, attrs, "(&(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; - - flags = ldb_msg_find_attr_as_uint(msgs[0], "flags", SPOOLSS_FORM_BUILTIN); - if (flags != SPOOLSS_FORM_USER) { - return WERR_FOOBAR; - } - - ret = ldb_delete(sptr_db, msgs[0]->dn); - if (ret != 0) { - return WERR_FOOBAR; - } - - return WERR_OK; -} - -/* PrintServer Driver functions */ -static WERROR sptr_EnumPrinterDrivers(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterDrivers *r) -{ - return WERR_OK; -} - -static WERROR sptr_GetPrinterDriverDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriverDirectory *r) -{ - union spoolss_DriverDirectoryInfo *info; - const char *prefix; - const char *postfix; - - /* - * NOTE: normally r->in.level is 1, but both w2k3 and nt4 sp6a - * are ignoring the r->in.level completely, so we do :-) - */ - - /* - * TODO: check the server name is ours - * - if it's a invalid UNC then return WERR_INVALID_NAME - * - if it's the wrong host name return WERR_INVALID_PARAM - * - if it's "" then we need to return a local WINDOWS path - */ - if (!r->in.server || !r->in.server[0]) { - prefix = "C:\\DRIVERS"; - } else { - prefix = talloc_asprintf(mem_ctx, "%s\\print$", r->in.server); - W_ERROR_HAVE_NO_MEMORY(prefix); - } - - if (r->in.environment && strcmp(SPOOLSS_ARCHITECTURE_NT_X86, r->in.environment) == 0) { - postfix = "W32X86"; - } else { - return WERR_INVALID_ENVIRONMENT; - } - - info = talloc(mem_ctx, union spoolss_DriverDirectoryInfo); - W_ERROR_HAVE_NO_MEMORY(info); - - info->info1.directory_name = talloc_asprintf(mem_ctx, "%s\\%s", prefix, postfix); - W_ERROR_HAVE_NO_MEMORY(info->info1.directory_name); - - r->out.info = info; - return WERR_OK; -} - -/* Printer functions */ -static WERROR sptr_EnumPrinters(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinters *r) -{ - struct ldb_context *sptr_db = talloc_get_type(ntptr->private_data, struct ldb_context); - struct ldb_message **msgs; - int count; - int i; - union spoolss_PrinterInfo *info; - - count = sptr_db_search(sptr_db, mem_ctx, NULL, &msgs, NULL, - "(&(objectclass=printer))"); - - if (count == 0) return WERR_OK; - if (count < 0) return WERR_GENERAL_FAILURE; - - info = talloc_array(mem_ctx, union spoolss_PrinterInfo, count); - W_ERROR_HAVE_NO_MEMORY(info); - - switch(r->in.level) { - case 1: - for (i = 0; i < count; i++) { - info[i].info1.flags = ldb_msg_find_attr_as_uint(msgs[i], "flags", 0); - - info[i].info1.name = ldb_msg_find_attr_as_string(msgs[i], "name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info1.name); - - info[i].info1.description = ldb_msg_find_attr_as_string(msgs[i], "description", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info1.description); - - info[i].info1.comment = ldb_msg_find_attr_as_string(msgs[i], "comment", NULL); - } - break; - case 2: - for (i = 0; i < count; i++) { - info[i].info2.servername = ldb_msg_find_attr_as_string(msgs[i], "servername", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.servername); - - info[i].info2.printername = ldb_msg_find_attr_as_string(msgs[i], "printername", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.printername); - - info[i].info2.sharename = ldb_msg_find_attr_as_string(msgs[i], "sharename", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.sharename); - - info[i].info2.portname = ldb_msg_find_attr_as_string(msgs[i], "portname", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.portname); - - info[i].info2.drivername = ldb_msg_find_attr_as_string(msgs[i], "drivername", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.drivername); - - info[i].info2.comment = ldb_msg_find_attr_as_string(msgs[i], "comment", NULL); - - info[i].info2.location = ldb_msg_find_attr_as_string(msgs[i], "location", NULL); - - info[i].info2.devmode = NULL; - - info[i].info2.sepfile = ldb_msg_find_attr_as_string(msgs[i], "sepfile", NULL); - - info[i].info2.printprocessor = ldb_msg_find_attr_as_string(msgs[i], "printprocessor", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.printprocessor); - - info[i].info2.datatype = ldb_msg_find_attr_as_string(msgs[i], "datatype", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.datatype); - - info[i].info2.parameters = ldb_msg_find_attr_as_string(msgs[i], "parameters", NULL); - - info[i].info2.secdesc = NULL; - - info[i].info2.attributes = ldb_msg_find_attr_as_uint(msgs[i], "attributes", 0); - info[i].info2.priority = ldb_msg_find_attr_as_uint(msgs[i], "priority", 0); - info[i].info2.defaultpriority = ldb_msg_find_attr_as_uint(msgs[i], "defaultpriority", 0); - info[i].info2.starttime = ldb_msg_find_attr_as_uint(msgs[i], "starttime", 0); - info[i].info2.untiltime = ldb_msg_find_attr_as_uint(msgs[i], "untiltime", 0); - info[i].info2.status = ldb_msg_find_attr_as_uint(msgs[i], "status", 0); - info[i].info2.cjobs = ldb_msg_find_attr_as_uint(msgs[i], "cjobs", 0); - info[i].info2.averageppm = ldb_msg_find_attr_as_uint(msgs[i], "averageppm", 0); - } - break; - case 4: - for (i = 0; i < count; i++) { - info[i].info4.printername = ldb_msg_find_attr_as_string(msgs[i], "printername", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.printername); - - info[i].info4.servername = ldb_msg_find_attr_as_string(msgs[i], "servername", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.servername); - - info[i].info4.attributes = ldb_msg_find_attr_as_uint(msgs[i], "attributes", 0); - } - break; - case 5: - for (i = 0; i < count; i++) { - info[i].info5.printername = ldb_msg_find_attr_as_string(msgs[i], "name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info5.printername); - - info[i].info5.portname = ldb_msg_find_attr_as_string(msgs[i], "port", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info5.portname); - - info[i].info5.attributes = ldb_msg_find_attr_as_uint(msgs[i], "attributes", 0); - info[i].info5.device_not_selected_timeout = ldb_msg_find_attr_as_uint(msgs[i], "device_not_selected_timeout", 0); - info[i].info5.transmission_retry_timeout = ldb_msg_find_attr_as_uint(msgs[i], "transmission_retry_timeout", 0); - } - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - *r->out.info = info; - *r->out.count = count; - return WERR_OK; -} - -static WERROR sptr_OpenPrinter(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r, - const char *printer_name, - struct ntptr_GenericHandle **printer) -{ - return WERR_INVALID_PRINTER_NAME; -} - -/* port functions */ -static WERROR sptr_EnumPorts(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPorts *r) -{ - struct ldb_context *sptr_db = talloc_get_type(ntptr->private_data, struct ldb_context); - struct ldb_message **msgs; - int count; - int i; - union spoolss_PortInfo *info; - - count = sptr_db_search(sptr_db, mem_ctx, NULL, &msgs, NULL, - "(&(objectclass=port))"); - - if (count == 0) return WERR_OK; - if (count < 0) return WERR_GENERAL_FAILURE; - - info = talloc_array(mem_ctx, union spoolss_PortInfo, count); - W_ERROR_HAVE_NO_MEMORY(info); - - switch (r->in.level) { - case 1: - for (i = 0; i < count; i++) { - info[i].info1.port_name = ldb_msg_find_attr_as_string(msgs[i], "port-name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info1.port_name); - } - break; - case 2: - for (i=0; i < count; i++) { - info[i].info2.port_name = ldb_msg_find_attr_as_string(msgs[i], "port-name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.port_name); - - info[i].info2.monitor_name = ldb_msg_find_attr_as_string(msgs[i], "monitor-name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.monitor_name); - - info[i].info2.description = ldb_msg_find_attr_as_string(msgs[i], "description", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.description); - - info[i].info2.port_type = ldb_msg_find_attr_as_uint(msgs[i], "port-type", SPOOLSS_PORT_TYPE_WRITE); - info[i].info2.reserved = ldb_msg_find_attr_as_uint(msgs[i], "reserved", 0); - } - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - *r->out.info = info; - *r->out.count = count; - return WERR_OK; -} - -/* monitor functions */ -static WERROR sptr_EnumMonitors(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_EnumMonitors *r) -{ - struct ldb_context *sptr_db = talloc_get_type(ntptr->private_data, struct ldb_context); - struct ldb_message **msgs; - int count; - int i; - union spoolss_MonitorInfo *info; - - count = sptr_db_search(sptr_db, mem_ctx, NULL, &msgs, NULL, - "(&(objectclass=monitor))"); - - if (count == 0) return WERR_OK; - if (count < 0) return WERR_GENERAL_FAILURE; - - info = talloc_array(mem_ctx, union spoolss_MonitorInfo, count); - W_ERROR_HAVE_NO_MEMORY(info); - - switch (r->in.level) { - case 1: - for (i = 0; i < count; i++) { - info[i].info1.monitor_name = ldb_msg_find_attr_as_string(msgs[i], "monitor-name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info1.monitor_name); - } - break; - case 2: - for (i=0; i < count; i++) { - info[i].info2.monitor_name = ldb_msg_find_attr_as_string(msgs[i], "monitor-name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.monitor_name); - - info[i].info2.environment = ldb_msg_find_attr_as_string(msgs[i], "environment", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.environment); - - info[i].info2.dll_name = ldb_msg_find_attr_as_string(msgs[i], "dll-name", ""); - W_ERROR_HAVE_NO_MEMORY(info[i].info2.dll_name); - } - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - *r->out.info = info; - *r->out.count = count; - 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; - struct ldb_dn *base_dn; - int count; - union spoolss_FormInfo *info; - - /* TODO: do checks access here - * if (!(printer->access_mask & desired_access)) { - * return WERR_FOOBAR; - * } - */ - - base_dn = ldb_dn_new_fmt(mem_ctx, sptr_db, "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 = ldb_msg_find_attr_as_uint(msgs[0], "flags", SPOOLSS_FORM_BUILTIN); - - info->info1.form_name = ldb_msg_find_attr_as_string(msgs[0], "form-name", NULL); - W_ERROR_HAVE_NO_MEMORY(info->info1.form_name); - - info->info1.size.width = ldb_msg_find_attr_as_uint(msgs[0], "size-width", 0); - info->info1.size.height = ldb_msg_find_attr_as_uint(msgs[0], "size-height", 0); - - info->info1.area.left = ldb_msg_find_attr_as_uint(msgs[0], "area-left", 0); - info->info1.area.top = ldb_msg_find_attr_as_uint(msgs[0], "area-top", 0); - info->info1.area.right = ldb_msg_find_attr_as_uint(msgs[0], "area-right", 0); - info->info1.area.bottom = ldb_msg_find_attr_as_uint(msgs[0], "area-bottom", 0); - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - r->out.info = info; - return WERR_OK; -} - -static WERROR sptr_GetPrintProcessorDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrintProcessorDirectory *r) -{ - union spoolss_PrintProcessorDirectoryInfo *info; - const char *prefix; - const char *postfix; - - /* - * NOTE: normally r->in.level is 1, but both w2k3 and nt4 sp6a - * are ignoring the r->in.level completely, so we do :-) - */ - - /* - * TODO: check the server name is ours - * - if it's a invalid UNC then return WERR_INVALID_NAME - * - if it's the wrong host name return WERR_INVALID_PARAM - * - if it's "" then we need to return a local WINDOWS path - */ - if (!r->in.server || !r->in.server[0]) { - prefix = "C:\\PRTPROCS"; - } else { - prefix = talloc_asprintf(mem_ctx, "%s\\prnproc$", r->in.server); - W_ERROR_HAVE_NO_MEMORY(prefix); - } - - if (r->in.environment && strcmp(SPOOLSS_ARCHITECTURE_NT_X86, r->in.environment) == 0) { - postfix = "W32X86"; - } else { - return WERR_INVALID_ENVIRONMENT; - } - - info = talloc(mem_ctx, union spoolss_PrintProcessorDirectoryInfo); - W_ERROR_HAVE_NO_MEMORY(info); - - info->info1.directory_name = talloc_asprintf(mem_ctx, "%s\\%s", prefix, postfix); - W_ERROR_HAVE_NO_MEMORY(info->info1.directory_name); - - r->out.info = info; - return WERR_OK; -} - - -/* - initialialise the simble ldb backend, registering ourselves with the ntptr subsystem - */ -static const struct ntptr_ops ntptr_simple_ldb_ops = { - .name = "simple_ldb", - .init_context = sptr_init_context, - - /* PrintServer functions */ - .OpenPrintServer = sptr_OpenPrintServer, -/* .XcvDataPrintServer = sptr_XcvDataPrintServer, -*/ - /* PrintServer PrinterData functions */ -/* .EnumPrintServerData = sptr_EnumPrintServerData, -*/ .GetPrintServerData = sptr_GetPrintServerData, -/* .SetPrintServerData = sptr_SetPrintServerData, - .DeletePrintServerData = sptr_DeletePrintServerData, -*/ - /* PrintServer Form functions */ - .EnumPrintServerForms = sptr_EnumPrintServerForms, - .AddPrintServerForm = sptr_AddPrintServerForm, - .SetPrintServerForm = sptr_SetPrintServerForm, - .DeletePrintServerForm = sptr_DeletePrintServerForm, - - /* PrintServer Driver functions */ - .EnumPrinterDrivers = sptr_EnumPrinterDrivers, -/* .AddPrinterDriver = sptr_AddPrinterDriver, - .DeletePrinterDriver = sptr_DeletePrinterDriver, -*/ .GetPrinterDriverDirectory = sptr_GetPrinterDriverDirectory, - - /* Port functions */ - .EnumPorts = sptr_EnumPorts, -/* .OpenPort = sptr_OpenPort, - .XcvDataPort = sptr_XcvDataPort, -*/ - /* Monitor functions */ - .EnumMonitors = sptr_EnumMonitors, -/* .OpenMonitor = sptr_OpenMonitor, - .XcvDataMonitor = sptr_XcvDataMonitor, -*/ - /* PrintProcessor functions */ -/* .EnumPrintProcessors = sptr_EnumPrintProcessors, -*/ - .GetPrintProcessorDirectory = sptr_GetPrintProcessorDirectory, - - /* Printer functions */ - .EnumPrinters = sptr_EnumPrinters, - .OpenPrinter = sptr_OpenPrinter, -/* .AddPrinter = sptr_AddPrinter, - .GetPrinter = sptr_GetPrinter, - .SetPrinter = sptr_SetPrinter, - .DeletePrinter = sptr_DeletePrinter, - .XcvDataPrinter = sptr_XcvDataPrinter, -*/ - /* Printer Driver functions */ -/* .GetPrinterDriver = sptr_GetPrinterDriver, -*/ - /* Printer PrinterData functions */ -/* .EnumPrinterData = sptr_EnumPrinterData, - .GetPrinterData = sptr_GetPrinterData, - .SetPrinterData = sptr_SetPrinterData, - .DeletePrinterData = sptr_DeletePrinterData, -*/ - /* Printer Form functions */ -/* .EnumPrinterForms = sptr_EnumPrinterForms, - .AddPrinterForm = sptr_AddPrinterForm, -*/ .GetPrinterForm = sptr_GetPrinterForm, -/* .SetPrinterForm = sptr_SetPrinterForm, - .DeletePrinterForm = sptr_DeletePrinterForm, -*/ - /* Printer Job functions */ -/* .EnumJobs = sptr_EnumJobs, - .AddJob = sptr_AddJob, - .ScheduleJob = sptr_ScheduleJob, - .GetJob = sptr_GetJob, - .SetJob = sptr_SetJob, -*/ - /* Printer Printing functions */ -/* .StartDocPrinter = sptr_StartDocPrinter, - .EndDocPrinter = sptr_EndDocPrinter, - .StartPagePrinter = sptr_StartPagePrinter, - .EndPagePrinter = sptr_EndPagePrinter, - .WritePrinter = sptr_WritePrinter, - .ReadPrinter = sptr_ReadPrinter, -*/}; - -NTSTATUS ntptr_simple_ldb_init(void) -{ - NTSTATUS ret; - - ret = ntptr_register(&ntptr_simple_ldb_ops); - if (!NT_STATUS_IS_OK(ret)) { - DEBUG(0,("Failed to register NTPTR '%s' backend!\n", - ntptr_simple_ldb_ops.name)); - } - - return ret; -} diff --git a/source4/ntptr/wscript_build b/source4/ntptr/wscript_build deleted file mode 100644 index 32c46fad4e0..00000000000 --- a/source4/ntptr/wscript_build +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -bld.SAMBA_MODULE('ntptr_simple_ldb', - source='simple_ldb/ntptr_simple_ldb.c', - subsystem='ntptr', - init_function='ntptr_simple_ldb_init', - deps='ldb NDR_SPOOLSS DCERPC_COMMON ldbsamba', - enabled=bld.AD_DC_BUILD_IS_ENABLED() - ) - - -bld.SAMBA_SUBSYSTEM('ntptr', - source='ntptr_base.c ntptr_interface.c', - autoproto='ntptr_proto.h', - public_deps='DCERPC_COMMON', - enabled=bld.AD_DC_BUILD_IS_ENABLED() - ) - diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c deleted file mode 100644 index d88a61a85f2..00000000000 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ /dev/null @@ -1,1772 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - endpoint server for the spoolss pipe - - Copyright (C) Tim Potter 2004 - Copyright (C) Stefan Metzmacher 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "rpc_server/dcerpc_server.h" -#include "librpc/gen_ndr/ndr_spoolss.h" -#include "ntptr/ntptr.h" -#include "lib/tsocket/tsocket.h" -#include "librpc/gen_ndr/ndr_spoolss_c.h" -#include "auth/credentials/credentials.h" -#include "param/param.h" - -enum spoolss_handle { - SPOOLSS_NOTIFY -}; - -#define SPOOLSS_BUFFER_UNION(fn,info,level) \ - ((info)?ndr_size_##fn(info, level, 0):0) - -#define SPOOLSS_BUFFER_UNION_ARRAY(fn,info,level,count) \ - ((info)?ndr_size_##fn##_info(dce_call, level, count, info):0) - -#define SPOOLSS_BUFFER_OK(val_true,val_false) ((r->in.offered >= *r->out.needed)?val_true:val_false) - -static WERROR dcesrv_spoolss_parse_printer_name(TALLOC_CTX *mem_ctx, const char *name, - const char **_server_name, - const char **_object_name, - enum ntptr_HandleType *_object_type) -{ - char *p; - char *server = NULL; - char *server_unc = NULL; - const char *object = name; - - /* no printername is there it's like open server */ - if (!name) { - *_server_name = NULL; - *_object_name = NULL; - *_object_type = NTPTR_HANDLE_SERVER; - return WERR_OK; - } - - /* just "\\" is invalid */ - if (strequal("\\\\", name)) { - return WERR_INVALID_PRINTER_NAME; - } - - if (strncmp("\\\\", name, 2) == 0) { - server_unc = talloc_strdup(mem_ctx, name); - W_ERROR_HAVE_NO_MEMORY(server_unc); - server = server_unc + 2; - - /* here we know we have "\\" in front not followed - * by '\0', now see if we have another "\" in the string - */ - p = strchr_m(server, '\\'); - if (!p) { - /* there's no other "\", so it's ("\\%s",server) - */ - *_server_name = server_unc; - *_object_name = NULL; - *_object_type = NTPTR_HANDLE_SERVER; - return WERR_OK; - } - /* here we know that we have ("\\%s\",server), - * if we have '\0' as next then it's an invalid name - * otherwise the printer_name - */ - p[0] = '\0'; - /* everything that follows is the printer name */ - p++; - object = p; - - /* just "" as server is invalid */ - if (strequal(server, "")) { - return WERR_INVALID_PRINTER_NAME; - } - } - - /* just "" is invalid */ - if (strequal(object, "")) { - return WERR_INVALID_PRINTER_NAME; - } - -#define XCV_PORT ",XcvPort " -#define XCV_MONITOR ",XcvMonitor " - if (strncmp(object, XCV_PORT, strlen(XCV_PORT)) == 0) { - object += strlen(XCV_PORT); - - /* just "" is invalid */ - if (strequal(object, "")) { - return WERR_INVALID_PRINTER_NAME; - } - - *_server_name = server_unc; - *_object_name = object; - *_object_type = NTPTR_HANDLE_PORT; - return WERR_OK; - } else if (strncmp(object, XCV_MONITOR, strlen(XCV_MONITOR)) == 0) { - object += strlen(XCV_MONITOR); - - /* just "" is invalid */ - if (strequal(object, "")) { - return WERR_INVALID_PRINTER_NAME; - } - - *_server_name = server_unc; - *_object_name = object; - *_object_type = NTPTR_HANDLE_MONITOR; - return WERR_OK; - } - - *_server_name = server_unc; - *_object_name = object; - *_object_type = NTPTR_HANDLE_PRINTER; - return WERR_OK; -} - -/* - * Check server_name is: - * - "" , functions that don't allow "", - * should check that on their own, before calling this function - * - our name (only netbios yet, TODO: need to test dns name!) - * - our ip address of the current use socket - * otherwise return WERR_INVALID_PRINTER_NAME - */ -static WERROR dcesrv_spoolss_check_server_name(struct dcesrv_call_state *dce_call, - TALLOC_CTX *mem_ctx, - const char *server_name) -{ - bool ret; - const struct tsocket_address *local_address; - char *myaddr; - const char **aliases; - const char *dnsdomain; - unsigned int i; - - /* NULL is ok */ - if (!server_name) return WERR_OK; - - /* "" is ok */ - ret = strequal("",server_name); - if (ret) return WERR_OK; - - /* just "\\" is invalid */ - if (strequal("\\\\", server_name)) { - return WERR_INVALID_PRINTER_NAME; - } - - /* then we need "\\" */ - if (strncmp("\\\\", server_name, 2) != 0) { - return WERR_INVALID_PRINTER_NAME; - } - - server_name += 2; - - /* NETBIOS NAME is ok */ - ret = strequal(lpcfg_netbios_name(dce_call->conn->dce_ctx->lp_ctx), server_name); - if (ret) return WERR_OK; - - aliases = lpcfg_netbios_aliases(dce_call->conn->dce_ctx->lp_ctx); - - for (i=0; aliases && aliases[i]; i++) { - if (strequal(aliases[i], server_name)) { - return WERR_OK; - } - } - - /* DNS NAME is ok - * TODO: we need to check if aliases are also ok - */ - dnsdomain = lpcfg_dnsdomain(dce_call->conn->dce_ctx->lp_ctx); - if (dnsdomain != NULL) { - char *str; - - str = talloc_asprintf(mem_ctx, "%s.%s", - lpcfg_netbios_name(dce_call->conn->dce_ctx->lp_ctx), - dnsdomain); - W_ERROR_HAVE_NO_MEMORY(str); - - ret = strequal(str, server_name); - talloc_free(str); - if (ret) return WERR_OK; - } - - local_address = dcesrv_connection_get_local_address(dce_call->conn); - - myaddr = tsocket_address_inet_addr_string(local_address, mem_ctx); - W_ERROR_HAVE_NO_MEMORY(myaddr); - - ret = strequal(myaddr, server_name); - talloc_free(myaddr); - if (ret) return WERR_OK; - - return WERR_INVALID_PRINTER_NAME; -} - -static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface) -{ - NTSTATUS status; - struct ntptr_context *ntptr; - - status = ntptr_init_context(dce_call->context, dce_call->conn->event_ctx, dce_call->conn->dce_ctx->lp_ctx, - "simple_ldb", &ntptr); - NT_STATUS_NOT_OK_RETURN(status); - - dce_call->context->private_data = ntptr; - - return NT_STATUS_OK; -} - -#define DCESRV_INTERFACE_SPOOLSS_BIND dcerpc_spoolss_bind - -/* - spoolss_EnumPrinters -*/ -static WERROR dcesrv_spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinters *r) -{ - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); - WERROR status; - - status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.server); - W_ERROR_NOT_OK_RETURN(status); - - status = ntptr_EnumPrinters(ntptr, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - - *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinters, *r->out.info, r->in.level, *r->out.count); - *r->out.info = SPOOLSS_BUFFER_OK(*r->out.info, NULL); - *r->out.count = SPOOLSS_BUFFER_OK(*r->out.count, 0); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - -static WERROR dcesrv_spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r); -/* - spoolss_OpenPrinter -*/ -static WERROR dcesrv_spoolss_OpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinter *r) -{ - WERROR status; - struct spoolss_OpenPrinterEx *r2; - - r2 = talloc(mem_ctx, struct spoolss_OpenPrinterEx); - W_ERROR_HAVE_NO_MEMORY(r2); - - r2->in.printername = r->in.printername; - r2->in.datatype = r->in.datatype; - r2->in.devmode_ctr = r->in.devmode_ctr; - r2->in.access_mask = r->in.access_mask; - r2->in.userlevel_ctr.level = 1; - r2->in.userlevel_ctr.user_info.level1 = NULL; - r2->out.handle = r->out.handle; - - /* TODO: we should take care about async replies here, - if spoolss_OpenPrinterEx() would be async! - */ - status = dcesrv_spoolss_OpenPrinterEx(dce_call, mem_ctx, r2); - - r->out.handle = r2->out.handle; - - return status; -} - - -/* - spoolss_SetJob -*/ -static WERROR dcesrv_spoolss_SetJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_SetJob *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetJob -*/ -static WERROR dcesrv_spoolss_GetJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetJob *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumJobs -*/ -static WERROR dcesrv_spoolss_EnumJobs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumJobs *r) -{ - return WERR_OK; -} - - -/* - spoolss_AddPrinter -*/ -static WERROR dcesrv_spoolss_AddPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrinter -*/ -static WERROR dcesrv_spoolss_DeletePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_SetPrinter -*/ -static WERROR dcesrv_spoolss_SetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetPrinter -*/ -static WERROR dcesrv_spoolss_GetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AddPrinterDriver -*/ -static WERROR dcesrv_spoolss_AddPrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinterDriver *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumPrinterDrivers -*/ -static WERROR dcesrv_spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterDrivers *r) -{ - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); - WERROR status; - - status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.server); - W_ERROR_NOT_OK_RETURN(status); - - status = ntptr_EnumPrinterDrivers(ntptr, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - - *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinterDrivers, *r->out.info, r->in.level, *r->out.count); - *r->out.info = SPOOLSS_BUFFER_OK(*r->out.info, NULL); - *r->out.count = SPOOLSS_BUFFER_OK(*r->out.count, 0); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - - -/* - spoolss_GetPrinterDriver -*/ -static WERROR dcesrv_spoolss_GetPrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriver *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetPrinterDriverDirectory -*/ -static WERROR dcesrv_spoolss_GetPrinterDriverDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriverDirectory *r) -{ - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); - WERROR status; - - status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.server); - W_ERROR_NOT_OK_RETURN(status); - - status = ntptr_GetPrinterDriverDirectory(ntptr, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - - *r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_DriverDirectoryInfo, r->out.info, r->in.level); - r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - - -/* - spoolss_DeletePrinterDriver -*/ -static WERROR dcesrv_spoolss_DeletePrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterDriver *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AddPrintProcessor -*/ -static WERROR dcesrv_spoolss_AddPrintProcessor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrintProcessor *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumPrintProcessors -*/ -static WERROR dcesrv_spoolss_EnumPrintProcessors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrintProcessors *r) -{ - return WERR_OK; -} - - -/* - spoolss_GetPrintProcessorDirectory -*/ -static WERROR dcesrv_spoolss_GetPrintProcessorDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrintProcessorDirectory *r) -{ - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); - WERROR status; - - status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.server); - W_ERROR_NOT_OK_RETURN(status); - - status = ntptr_GetPrintProcessorDirectory(ntptr, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - - *r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_PrintProcessorDirectoryInfo, r->out.info, r->in.level); - r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - - -/* - spoolss_StartDocPrinter -*/ -static WERROR dcesrv_spoolss_StartDocPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_StartDocPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_StartPagePrinter -*/ -static WERROR dcesrv_spoolss_StartPagePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_StartPagePrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_WritePrinter -*/ -static WERROR dcesrv_spoolss_WritePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_WritePrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EndPagePrinter -*/ -static WERROR dcesrv_spoolss_EndPagePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EndPagePrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AbortPrinter -*/ -static WERROR dcesrv_spoolss_AbortPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AbortPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_ReadPrinter -*/ -static WERROR dcesrv_spoolss_ReadPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ReadPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EndDocPrinter -*/ -static WERROR dcesrv_spoolss_EndDocPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EndDocPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AddJob -*/ -static WERROR dcesrv_spoolss_AddJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddJob *r) -{ - if (r->in.level != 1) { - return WERR_UNKNOWN_LEVEL; - } - - return WERR_INVALID_PARAM; -} - - -/* - spoolss_ScheduleJob -*/ -static WERROR dcesrv_spoolss_ScheduleJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ScheduleJob *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetPrinterData -*/ -static WERROR dcesrv_spoolss_GetPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterData *r) -{ - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - WERROR status; - - r->out.type = talloc_zero(mem_ctx, enum winreg_Type); - W_ERROR_HAVE_NO_MEMORY(r->out.type); - - r->out.needed = talloc_zero(mem_ctx, uint32_t); - W_ERROR_HAVE_NO_MEMORY(r->out.needed); - - r->out.data = talloc_zero_array(mem_ctx, uint8_t, r->in.offered); - W_ERROR_HAVE_NO_MEMORY(r->out.data); - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - handle = talloc_get_type(h->data, struct ntptr_GenericHandle); - if (!handle) - return WERR_BADFID; - - switch (handle->type) { - case NTPTR_HANDLE_SERVER: - status = ntptr_GetPrintServerData(handle, mem_ctx, r); - break; - default: - status = WERR_FOOBAR; - break; - } - - W_ERROR_NOT_OK_RETURN(status); - - *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); -} - - -/* - spoolss_SetPrinterData -*/ -static WERROR dcesrv_spoolss_SetPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinterData *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_WaitForPrinterChange -*/ -static WERROR dcesrv_spoolss_WaitForPrinterChange(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_WaitForPrinterChange *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_ClosePrinter -*/ -static WERROR dcesrv_spoolss_ClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ClosePrinter *r) -{ - struct dcesrv_handle *h; - - *r->out.handle = *r->in.handle; - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - - talloc_free(h); - - ZERO_STRUCTP(r->out.handle); - - return WERR_OK; -} - - -/* - spoolss_AddForm -*/ -static WERROR dcesrv_spoolss_AddForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddForm *r) -{ - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - WERROR status; - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - handle = talloc_get_type(h->data, struct ntptr_GenericHandle); - if (!handle) - return WERR_BADFID; - - switch (handle->type) { - case NTPTR_HANDLE_SERVER: - status = ntptr_AddPrintServerForm(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PRINTER: - status = ntptr_AddPrinterForm(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - default: - return WERR_FOOBAR; - } - - return WERR_OK; -} - - -/* - spoolss_DeleteForm -*/ -static WERROR dcesrv_spoolss_DeleteForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeleteForm *r) -{ - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - WERROR status; - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - handle = talloc_get_type(h->data, struct ntptr_GenericHandle); - if (!handle) - return WERR_BADFID; - - switch (handle->type) { - case NTPTR_HANDLE_SERVER: - status = ntptr_DeletePrintServerForm(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PRINTER: - status = ntptr_DeletePrinterForm(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - default: - return WERR_FOOBAR; - } - - return WERR_OK; -} - - -/* - spoolss_GetForm -*/ -static WERROR dcesrv_spoolss_GetForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetForm *r) -{ - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - WERROR status; - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - handle = talloc_get_type(h->data, struct ntptr_GenericHandle); - if (!handle) - return WERR_BADFID; - - switch (handle->type) { - case NTPTR_HANDLE_SERVER: - /* - * stupid, but w2k3 returns WERR_BADFID here? - */ - return WERR_BADFID; - case NTPTR_HANDLE_PRINTER: - status = ntptr_GetPrinterForm(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - default: - return WERR_FOOBAR; - } - - *r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_FormInfo, r->out.info, r->in.level); - r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - - -/* - spoolss_SetForm -*/ -static WERROR dcesrv_spoolss_SetForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_SetForm *r) -{ - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - WERROR status; - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - handle = talloc_get_type(h->data, struct ntptr_GenericHandle); - if (!handle) - return WERR_BADFID; - - switch (handle->type) { - case NTPTR_HANDLE_SERVER: - status = ntptr_SetPrintServerForm(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PRINTER: - status = ntptr_SetPrinterForm(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - default: - return WERR_FOOBAR; - } - - return WERR_OK; -} - - -/* - spoolss_EnumForms -*/ -static WERROR dcesrv_spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumForms *r) -{ - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - WERROR status; - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - handle = talloc_get_type(h->data, struct ntptr_GenericHandle); - if (!handle) - return WERR_BADFID; - - switch (handle->type) { - case NTPTR_HANDLE_SERVER: - status = ntptr_EnumPrintServerForms(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PRINTER: - status = ntptr_EnumPrinterForms(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - default: - return WERR_FOOBAR; - } - - *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumForms, *r->out.info, r->in.level, *r->out.count); - *r->out.info = SPOOLSS_BUFFER_OK(*r->out.info, NULL); - *r->out.count = SPOOLSS_BUFFER_OK(*r->out.count, 0); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - - -/* - spoolss_EnumPorts -*/ -static WERROR dcesrv_spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPorts *r) -{ - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); - WERROR status; - - status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.servername); - W_ERROR_NOT_OK_RETURN(status); - - status = ntptr_EnumPorts(ntptr, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - - *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPorts, *r->out.info, r->in.level, *r->out.count); - *r->out.info = SPOOLSS_BUFFER_OK(*r->out.info, NULL); - *r->out.count = SPOOLSS_BUFFER_OK(*r->out.count, 0); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - - -/* - spoolss_EnumMonitors -*/ -static WERROR dcesrv_spoolss_EnumMonitors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumMonitors *r) -{ - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); - WERROR status; - - status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.servername); - W_ERROR_NOT_OK_RETURN(status); - - status = ntptr_EnumMonitors(ntptr, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - - *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumMonitors, *r->out.info, r->in.level, *r->out.count); - *r->out.info = SPOOLSS_BUFFER_OK(*r->out.info, NULL); - *r->out.count = SPOOLSS_BUFFER_OK(*r->out.count, 0); - return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); -} - - -/* - spoolss_AddPort -*/ -static WERROR dcesrv_spoolss_AddPort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPort *r) -{ - return WERR_NOT_SUPPORTED; -} - - -/* - spoolss_ConfigurePort -*/ -static WERROR dcesrv_spoolss_ConfigurePort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ConfigurePort *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePort -*/ -static WERROR dcesrv_spoolss_DeletePort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePort *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_CreatePrinterIC -*/ -static WERROR dcesrv_spoolss_CreatePrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_CreatePrinterIC *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_PlayGDIScriptOnPrinterIC -*/ -static WERROR dcesrv_spoolss_PlayGDIScriptOnPrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_PlayGDIScriptOnPrinterIC *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrinterIC -*/ -static WERROR dcesrv_spoolss_DeletePrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterIC *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AddPrinterConnection -*/ -static WERROR dcesrv_spoolss_AddPrinterConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinterConnection *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrinterConnection -*/ -static WERROR dcesrv_spoolss_DeletePrinterConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterConnection *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_PrinterMessageBox -*/ -static WERROR dcesrv_spoolss_PrinterMessageBox(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_PrinterMessageBox *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AddMonitor -*/ -static WERROR dcesrv_spoolss_AddMonitor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddMonitor *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeleteMonitor -*/ -static WERROR dcesrv_spoolss_DeleteMonitor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeleteMonitor *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrintProcessor -*/ -static WERROR dcesrv_spoolss_DeletePrintProcessor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrintProcessor *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AddPrintProvidor -*/ -static WERROR dcesrv_spoolss_AddPrintProvidor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrintProvidor *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrintProvidor -*/ -static WERROR dcesrv_spoolss_DeletePrintProvidor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrintProvidor *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumPrintProcDataTypes -*/ -static WERROR dcesrv_spoolss_EnumPrintProcDataTypes(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrintProcDataTypes *r) -{ - return WERR_OK; -} - - -/* - spoolss_ResetPrinter -*/ -static WERROR dcesrv_spoolss_ResetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ResetPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetPrinterDriver2 -*/ -static WERROR dcesrv_spoolss_GetPrinterDriver2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriver2 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_FindFirstPrinterChangeNotification -*/ -static WERROR dcesrv_spoolss_FindFirstPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_FindFirstPrinterChangeNotification *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_FindNextPrinterChangeNotification -*/ -static WERROR dcesrv_spoolss_FindNextPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_FindNextPrinterChangeNotification *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_FindClosePrinterNotify -*/ -static WERROR dcesrv_spoolss_FindClosePrinterNotify(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_FindClosePrinterNotify *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RouterFindFirstPrinterChangeNotificationOld -*/ -static WERROR dcesrv_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_ReplyOpenPrinter -*/ -static WERROR dcesrv_spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ReplyOpenPrinter *r) -{ - struct dcesrv_handle *handle; - - handle = dcesrv_handle_new(dce_call->context, SPOOLSS_NOTIFY); - W_ERROR_HAVE_NO_MEMORY(handle); - - /* For now, just return a handle */ - - *r->out.handle = handle->wire_handle; - - return WERR_OK; -} - - -/* - spoolss_RouterReplyPrinter -*/ -static WERROR dcesrv_spoolss_RouterReplyPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RouterReplyPrinter *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_ReplyClosePrinter -*/ -static WERROR dcesrv_spoolss_ReplyClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ReplyClosePrinter *r) -{ - struct dcesrv_handle *handle; - - DCESRV_PULL_HANDLE_WERR(handle, r->in.handle, SPOOLSS_NOTIFY); - - talloc_free(handle); - - ZERO_STRUCTP(r->out.handle); - - return WERR_OK; -} - -/* - spoolss_AddPortEx -*/ -static WERROR dcesrv_spoolss_AddPortEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPortEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RouterFindFirstPrinterChangeNotification -*/ -static WERROR dcesrv_spoolss_RouterFindFirstPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RouterFindFirstPrinterChangeNotification *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_SpoolerInit -*/ -static WERROR dcesrv_spoolss_SpoolerInit(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_SpoolerInit *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_ResetPrinterEx -*/ -static WERROR dcesrv_spoolss_ResetPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_ResetPrinterEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RemoteFindFirstPrinterChangeNotifyEx -*/ -static WERROR dcesrv_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r) -{ - struct dcerpc_pipe *p; - char *binding_string; - struct dcerpc_binding *binding; - NTSTATUS status; - struct spoolss_ReplyOpenPrinter rop; - struct cli_credentials *creds; - struct policy_handle notify_handle; - - DEBUG(2, ("Received RFFPCNex from %s\n", r->in.local_machine)); - - /* - * TODO: for now just open a connection to the client and drop it again - * to keep the w2k3 PrintServer - * happy to allow one to open the Add Printer GUI - * and the torture suite passing - */ - - if (strncmp(r->in.local_machine, "\\\\", 2)) { - return WERR_INVALID_COMPUTERNAME; - } - - binding_string = talloc_asprintf(mem_ctx, "ncacn_np:%s", - r->in.local_machine+2); - if (binding_string == NULL) { - return WERR_NOMEM; - } - - status = dcerpc_parse_binding(mem_ctx, binding_string, &binding); - if (!NT_STATUS_IS_OK(status)) { - return ntstatus_to_werror(status); - } - - creds = cli_credentials_init_anon(mem_ctx); /* FIXME: Use machine credentials instead ? */ - - status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss, - creds, dce_call->event_ctx, - dce_call->conn->dce_ctx->lp_ctx); - - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("unable to call back to %s\n", r->in.local_machine)); - return WERR_SERVER_UNAVAILABLE; - } - - ZERO_STRUCT(rop); - rop.in.server_name = lpcfg_netbios_name(dce_call->conn->dce_ctx->lp_ctx); - W_ERROR_HAVE_NO_MEMORY(rop.in.server_name); - rop.in.printer_local = 0; - rop.in.type = REG_NONE; - rop.in.bufsize = 0; - rop.in.buffer = NULL; - rop.out.handle = ¬ify_handle; - - status = dcerpc_spoolss_ReplyOpenPrinter_r(p->binding_handle, mem_ctx, &rop); - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("unable to open remote printer %s\n", - r->in.local_machine)); - return WERR_SERVER_UNAVAILABLE; - } - - talloc_free(p); - - return WERR_OK; -} - - -/* - spoolss_RouterReplyPrinterEx -*/ -static WERROR dcesrv_spoolss_RouterReplyPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RouterReplyPrinterEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RouterRefreshPrinterChangeNotify -*/ -static WERROR dcesrv_spoolss_RouterRefreshPrinterChangeNotify(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RouterRefreshPrinterChangeNotify *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_44 -*/ -static WERROR dcesrv_spoolss_44(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_44 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - -/* - spoolss_OpenPrinterEx -*/ -static WERROR dcesrv_spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_OpenPrinterEx *r) -{ - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - const char *server; - const char *object; - enum ntptr_HandleType type; - WERROR status; - - ZERO_STRUCTP(r->out.handle); - - status = dcesrv_spoolss_parse_printer_name(mem_ctx, r->in.printername, &server, &object, &type); - W_ERROR_NOT_OK_RETURN(status); - - status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, server); - W_ERROR_NOT_OK_RETURN(status); - - switch (type) { - case NTPTR_HANDLE_SERVER: - status = ntptr_OpenPrintServer(ntptr, mem_ctx, r, server, &handle); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PORT: - status = ntptr_OpenPort(ntptr, mem_ctx, r, object, &handle); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_MONITOR: - status = ntptr_OpenMonitor(ntptr, mem_ctx, r, object, &handle); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PRINTER: - status = ntptr_OpenPrinter(ntptr, mem_ctx, r, object, &handle); - W_ERROR_NOT_OK_RETURN(status); - break; - default: - return WERR_FOOBAR; - } - - h = dcesrv_handle_new(dce_call->context, handle->type); - W_ERROR_HAVE_NO_MEMORY(h); - - h->data = talloc_steal(h, handle); - - *r->out.handle = h->wire_handle; - - return WERR_OK; -} - -/* - spoolss_AddPrinterEx -*/ -static WERROR dcesrv_spoolss_AddPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinterEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_SetPort -*/ -static WERROR dcesrv_spoolss_SetPort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_SetPort *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumPrinterData -*/ -static WERROR dcesrv_spoolss_EnumPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterData *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrinterData -*/ -static WERROR dcesrv_spoolss_DeletePrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterData *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_4a -*/ -static WERROR dcesrv_spoolss_4a(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_4a *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_4b -*/ -static WERROR dcesrv_spoolss_4b(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_4b *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_4c -*/ -static WERROR dcesrv_spoolss_4c(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_4c *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_SetPrinterDataEx -*/ -static WERROR dcesrv_spoolss_SetPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_SetPrinterDataEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetPrinterDataEx -*/ -static WERROR dcesrv_spoolss_GetPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDataEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumPrinterDataEx -*/ -static WERROR dcesrv_spoolss_EnumPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterDataEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumPrinterKey -*/ -static WERROR dcesrv_spoolss_EnumPrinterKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPrinterKey *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrinterDataEx -*/ -static WERROR dcesrv_spoolss_DeletePrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterDataEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrinterKey -*/ -static WERROR dcesrv_spoolss_DeletePrinterKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterKey *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_53 -*/ -static WERROR dcesrv_spoolss_53(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_53 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePrinterDriverEx -*/ -static WERROR dcesrv_spoolss_DeletePrinterDriverEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePrinterDriverEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_AddPerMachineConnection -*/ -static WERROR dcesrv_spoolss_AddPerMachineConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPerMachineConnection *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_DeletePerMachineConnection -*/ -static WERROR dcesrv_spoolss_DeletePerMachineConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_DeletePerMachineConnection *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_EnumPerMachineConnections -*/ -static WERROR dcesrv_spoolss_EnumPerMachineConnections(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_EnumPerMachineConnections *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_XcvData -*/ -static WERROR dcesrv_spoolss_XcvData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_XcvData *r) -{ - struct ntptr_GenericHandle *handle; - struct dcesrv_handle *h; - WERROR status; - - DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - handle = talloc_get_type(h->data, struct ntptr_GenericHandle); - - switch (handle->type) { - case NTPTR_HANDLE_SERVER: - status = ntptr_XcvDataPrintServer(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PRINTER: - status = ntptr_XcvDataPrinter(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_PORT: - status = ntptr_XcvDataPort(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - case NTPTR_HANDLE_MONITOR: - status = ntptr_XcvDataMonitor(handle, mem_ctx, r); - W_ERROR_NOT_OK_RETURN(status); - break; - default: - return WERR_FOOBAR; - } - - /* TODO: handle the buffer sizes here! */ - return WERR_OK; -} - - -/* - spoolss_AddPrinterDriverEx -*/ -static WERROR dcesrv_spoolss_AddPrinterDriverEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_AddPrinterDriverEx *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_5a -*/ -static WERROR dcesrv_spoolss_5a(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_5a *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_5b -*/ -static WERROR dcesrv_spoolss_5b(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_5b *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_5c -*/ -static WERROR dcesrv_spoolss_5c(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_5c *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_5d -*/ -static WERROR dcesrv_spoolss_5d(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_5d *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_5e -*/ -static WERROR dcesrv_spoolss_5e(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_5e *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_5f -*/ -static WERROR dcesrv_spoolss_5f(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_5f *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - -/* - spoolss_60 -*/ -static WERROR dcesrv_spoolss_60(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_60 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RpcSendRecvBidiData -*/ -static WERROR dcesrv_spoolss_RpcSendRecvBidiData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RpcSendRecvBidiData *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_62 -*/ -static WERROR dcesrv_spoolss_62(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_62 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_63 -*/ -static WERROR dcesrv_spoolss_63(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_63 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_64 -*/ -static WERROR dcesrv_spoolss_64(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_64 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_65 -*/ -static WERROR dcesrv_spoolss_65(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_65 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetCorePrinterDrivers -*/ -static WERROR dcesrv_spoolss_GetCorePrinterDrivers(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetCorePrinterDrivers *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_67 -*/ -static WERROR dcesrv_spoolss_67(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_67 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_GetPrinterDriverPackagePath -*/ -static WERROR dcesrv_spoolss_GetPrinterDriverPackagePath(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_GetPrinterDriverPackagePath *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_69 -*/ -static WERROR dcesrv_spoolss_69(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_69 *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_6a -*/ -static WERROR dcesrv_spoolss_6a(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_6a *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_6b -*/ -static WERROR dcesrv_spoolss_6b(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_6b *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_6c -*/ -static WERROR dcesrv_spoolss_6c(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_6c *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_6d -*/ -static WERROR dcesrv_spoolss_6d(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_6d *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RpcGetJobNamedPropertyValue -*/ -static WERROR dcesrv_spoolss_RpcGetJobNamedPropertyValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RpcGetJobNamedPropertyValue *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RpcSetJobNamedProperty -*/ -static WERROR dcesrv_spoolss_RpcSetJobNamedProperty(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RpcSetJobNamedProperty *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - - -/* - spoolss_RpcDeleteJobNamedProperty -*/ -static WERROR dcesrv_spoolss_RpcDeleteJobNamedProperty(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RpcDeleteJobNamedProperty *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - -/* - spoolss_RpcEnumJobNamedProperties -*/ -static WERROR dcesrv_spoolss_RpcEnumJobNamedProperties(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct spoolss_RpcEnumJobNamedProperties *r) -{ - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); -} - -/* include the generated boilerplate */ -#include "librpc/gen_ndr/ndr_spoolss_s.c" diff --git a/source4/rpc_server/wscript_build b/source4/rpc_server/wscript_build index ff2b82ef819..ed7dbf6b173 100755 --- a/source4/rpc_server/wscript_build +++ b/source4/rpc_server/wscript_build @@ -129,16 +129,6 @@ else: ) -bld.SAMBA_MODULE('dcerpc_spoolss', - source='spoolss/dcesrv_spoolss.c', - subsystem='dcerpc_server', - init_function='dcerpc_server_spoolss_init', - deps='DCERPC_COMMON NDR_SPOOLSS ntptr RPC_NDR_SPOOLSS', - internal_module=True, - enabled=bld.CONFIG_SET('WITH_NTVFS_FILESERVER') - ) - - bld.SAMBA_MODULE('dcerpc_drsuapi', source='drsuapi/dcesrv_drsuapi.c drsuapi/updaterefs.c drsuapi/getncchanges.c drsuapi/addentry.c drsuapi/writespn.c drsuapi/drsutil.c', subsystem='dcerpc_server', diff --git a/source4/smbd/server.c b/source4/smbd/server.c index b80f222cdd7..7dc7635414b 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -28,7 +28,6 @@ #include "lib/cmdline/popt_common.h" #include "system/dir.h" #include "system/filesys.h" -#include "ntptr/ntptr.h" #include "auth/gensec/gensec.h" #include "libcli/auth/schannel.h" #include "smbd/process_model.h" @@ -406,9 +405,6 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ gensec_init(); /* FIXME: */ - ntptr_init(); /* FIXME: maybe run this in the initialization function - of the spoolss RPC server instead? */ - process_model_init(cmdline_lp_ctx); shared_init = load_samba_modules(NULL, "service"); diff --git a/source4/smbd/wscript_build b/source4/smbd/wscript_build index 12d842b4bb6..98220d04358 100644 --- a/source4/smbd/wscript_build +++ b/source4/smbd/wscript_build @@ -21,7 +21,7 @@ bld.SAMBA_BINARY('samba', source='server.c', subsystem_name='service', deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA - popt gensec registry ntptr ntvfs share cluster COMMON_SCHANNEL SECRETS''', + popt gensec registry ntvfs share cluster COMMON_SCHANNEL SECRETS''', pyembed=True, install_path='${SBINDIR}', enabled=bld.AD_DC_BUILD_IS_ENABLED() diff --git a/wscript_build b/wscript_build index 3813cffc019..fa3aa60ed42 100644 --- a/wscript_build +++ b/wscript_build @@ -100,7 +100,6 @@ bld.RECURSE('source4/cldap_server') bld.RECURSE('source4/ntp_signd') bld.RECURSE('source4/utils') bld.RECURSE('source4/ntvfs') -bld.RECURSE('source4/ntptr') bld.RECURSE('source4/torture') bld.RECURSE('librpc') bld.RECURSE('source4') |