xref: /titanic_52/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c (revision b1d7ec75953cd517f5b7c3d9cb427ff8ec5d7d07)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 /*
27  * Printing and Spooling RPC service.
28  */
29 
30 #include <stdlib.h>
31 #include <strings.h>
32 #include <smbsrv/libsmb.h>
33 #include <smbsrv/libmlrpc.h>
34 #include <smbsrv/libmlsvc.h>
35 #include <smbsrv/ndl/spoolss.ndl>
36 #include <smbsrv/smbinfo.h>
37 #include <smbsrv/nmpipes.h>
38 
39 int spoolss_s_OpenPrinter(void *, ndr_xa_t *);
40 int spoolss_s_stub(void *, ndr_xa_t *);
41 
42 static ndr_stub_table_t spoolss_stub_table[] = {
43 	{ spoolss_s_OpenPrinter,	SPOOLSS_OPNUM_OpenPrinter },
44 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetJob },
45 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinter },
46 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetPrinterDriver },
47 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinterDriver },
48 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPrintProcessor },
49 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetPrintProcessorDirectory },
50 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AbortPrinter },
51 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ReadPrinter },
52 	{ spoolss_s_stub,	SPOOLSS_OPNUM_WaitForPrinterChange },
53 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddForm },
54 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeleteForm },
55 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetForm },
56 	{ spoolss_s_stub,	SPOOLSS_OPNUM_SetForm },
57 	{ spoolss_s_stub,	SPOOLSS_OPNUM_EnumMonitors },
58 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPort },
59 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ConfigurePort },
60 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePort },
61 	{ spoolss_s_stub,	SPOOLSS_OPNUM_CreatePrinterIc },
62 	{ spoolss_s_stub,	SPOOLSS_OPNUM_PlayDescriptionPrinterIc },
63 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinterIc },
64 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPrinterConnection },
65 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinterConnection },
66 	{ spoolss_s_stub,	SPOOLSS_OPNUM_PrinterMessageBox },
67 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddMonitor },
68 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeleteMonitor },
69 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrintProcessor },
70 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPrintProvider },
71 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrintProvider },
72 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ResetPrinter },
73 	{ spoolss_s_stub,	SPOOLSS_OPNUM_FindFirstChangeNotify },
74 	{ spoolss_s_stub,	SPOOLSS_OPNUM_FindNextChangeNotify },
75 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RouterFindFirstNotify },
76 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ReplyOpenPrinter },
77 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RouterReplyPrinter },
78 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ReplyClosePrinter },
79 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPortEx },
80 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RemoteFindFirstChangeNotify },
81 	{ spoolss_s_stub,	SPOOLSS_OPNUM_SpoolerInitialize },
82 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ResetPrinterEx },
83 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RouterRefreshChangeNotify },
84 	{ spoolss_s_OpenPrinter,	SPOOLSS_OPNUM_OpenPrinter2 },
85 	{0}
86 };
87 
88 static ndr_service_t spoolss_service = {
89 	"SPOOLSS",			/* name */
90 	"Print Spool Service",		/* desc */
91 	"\\spoolss",			/* endpoint */
92 	PIPE_SPOOLSS,			/* sec_addr_port */
93 	"12345678-1234-abcd-ef000123456789ab",	1,	/* abstract */
94 	NDR_TRANSFER_SYNTAX_UUID,		2,	/* transfer */
95 	0,				/* no bind_instance_size */
96 	0,				/* no bind_req() */
97 	0,				/* no unbind_and_close() */
98 	0,				/* use generic_call_stub() */
99 	&TYPEINFO(spoolss_interface),	/* interface ti */
100 	spoolss_stub_table		/* stub_table */
101 };
102 
103 void
104 spoolss_initialize(void)
105 {
106 	(void) ndr_svc_register(&spoolss_service);
107 }
108 
109 int
110 spoolss_s_OpenPrinter(void *arg, ndr_xa_t *mxa)
111 {
112 	struct spoolss_OpenPrinter *param = arg;
113 
114 	bzero(param, sizeof (struct spoolss_OpenPrinter));
115 
116 	if (mxa == NULL)
117 		param->status = NT_SC_ERROR(NT_STATUS_INVALID_PARAMETER);
118 	else
119 		param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
120 
121 	return (NDR_DRC_OK);
122 }
123 
124 /*ARGSUSED*/
125 int
126 spoolss_s_stub(void *arg, ndr_xa_t *mxa)
127 {
128 	return (NDR_DRC_FAULT_PARAM_0_UNIMPLEMENTED);
129 }
130