xref: /titanic_44/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c (revision 269473047d747f7815af570197e4ef7322d3632c)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
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/nterror.h>
37 #include <smbsrv/smbinfo.h>
38 #include <smbsrv/nmpipes.h>
39 
40 int spoolss_s_OpenPrinter(void *, ndr_xa_t *);
41 int spoolss_s_stub(void *, ndr_xa_t *);
42 
43 static ndr_stub_table_t spoolss_stub_table[] = {
44 	{ spoolss_s_OpenPrinter,	SPOOLSS_OPNUM_OpenPrinter },
45 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetJob },
46 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinter },
47 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetPrinterDriver },
48 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinterDriver },
49 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPrintProcessor },
50 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetPrintProcessorDirectory },
51 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AbortPrinter },
52 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ReadPrinter },
53 	{ spoolss_s_stub,	SPOOLSS_OPNUM_WaitForPrinterChange },
54 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddForm },
55 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeleteForm },
56 	{ spoolss_s_stub,	SPOOLSS_OPNUM_GetForm },
57 	{ spoolss_s_stub,	SPOOLSS_OPNUM_SetForm },
58 	{ spoolss_s_stub,	SPOOLSS_OPNUM_EnumMonitors },
59 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPort },
60 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ConfigurePort },
61 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePort },
62 	{ spoolss_s_stub,	SPOOLSS_OPNUM_CreatePrinterIc },
63 	{ spoolss_s_stub,	SPOOLSS_OPNUM_PlayDescriptionPrinterIc },
64 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinterIc },
65 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPrinterConnection },
66 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrinterConnection },
67 	{ spoolss_s_stub,	SPOOLSS_OPNUM_PrinterMessageBox },
68 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddMonitor },
69 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeleteMonitor },
70 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrintProcessor },
71 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPrintProvider },
72 	{ spoolss_s_stub,	SPOOLSS_OPNUM_DeletePrintProvider },
73 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ResetPrinter },
74 	{ spoolss_s_stub,	SPOOLSS_OPNUM_FindFirstChangeNotify },
75 	{ spoolss_s_stub,	SPOOLSS_OPNUM_FindNextChangeNotify },
76 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RouterFindFirstNotify },
77 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ReplyOpenPrinter },
78 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RouterReplyPrinter },
79 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ReplyClosePrinter },
80 	{ spoolss_s_stub,	SPOOLSS_OPNUM_AddPortEx },
81 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RemoteFindFirstChangeNotify },
82 	{ spoolss_s_stub,	SPOOLSS_OPNUM_SpoolerInitialize },
83 	{ spoolss_s_stub,	SPOOLSS_OPNUM_ResetPrinterEx },
84 	{ spoolss_s_stub,	SPOOLSS_OPNUM_RouterRefreshChangeNotify },
85 	{ spoolss_s_OpenPrinter,	SPOOLSS_OPNUM_OpenPrinter2 },
86 	{0}
87 };
88 
89 static ndr_service_t spoolss_service = {
90 	"SPOOLSS",			/* name */
91 	"Print Spool Service",		/* desc */
92 	"\\spoolss",			/* endpoint */
93 	PIPE_SPOOLSS,			/* sec_addr_port */
94 	"12345678-1234-abcd-ef000123456789ab",	1,	/* abstract */
95 	NDR_TRANSFER_SYNTAX_UUID,		2,	/* transfer */
96 	0,				/* no bind_instance_size */
97 	0,				/* no bind_req() */
98 	0,				/* no unbind_and_close() */
99 	0,				/* use generic_call_stub() */
100 	&TYPEINFO(spoolss_interface),	/* interface ti */
101 	spoolss_stub_table		/* stub_table */
102 };
103 
104 void
105 spoolss_initialize(void)
106 {
107 	(void) ndr_svc_register(&spoolss_service);
108 }
109 
110 int
111 spoolss_s_OpenPrinter(void *arg, ndr_xa_t *mxa)
112 {
113 	struct spoolss_OpenPrinter *param = arg;
114 
115 	bzero(param, sizeof (struct spoolss_OpenPrinter));
116 
117 	if (mxa == NULL)
118 		param->status = NT_SC_ERROR(NT_STATUS_INVALID_PARAMETER);
119 	else
120 		param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED);
121 
122 	return (NDR_DRC_OK);
123 }
124 
125 /*ARGSUSED*/
126 int
127 spoolss_s_stub(void *arg, ndr_xa_t *mxa)
128 {
129 	return (NDR_DRC_FAULT_PARAM_0_UNIMPLEMENTED);
130 }
131