xref: /titanic_52/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
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  * Message Service
28  */
29 
30 #include <syslog.h>
31 #include <stdlib.h>
32 
33 #include <smbsrv/libsmb.h>
34 #include <smbsrv/libmlrpc.h>
35 #include <smbsrv/libmlsvc.h>
36 #include <smbsrv/ndl/msgsvc.ndl>
37 #include <smbsrv/nterror.h>
38 #include <smbsrv/smbinfo.h>
39 #include <smbsrv/nmpipes.h>
40 
41 static int msgsvcsend_NetrSendMessage(void *, ndr_xa_t *);
42 
43 static ndr_stub_table_t msgsvcsend_stub_table[] = {
44 	{ msgsvcsend_NetrSendMessage, MSGSVCSEND_OPNUM_NetrSendMessage },
45 	{0}
46 };
47 
48 static ndr_service_t msgsvcsend_service = {
49 	"MSGSVC",			/* name */
50 	"Message Service",		/* desc */
51 	"\\msgsvc",			/* endpoint */
52 	PIPE_NTSVCS,			/* sec_addr_port */
53 	"5a7b91f8-ff00-11d0-a9b200c04fb6e6fc",	0,	/* abstract */
54 	NDR_TRANSFER_SYNTAX_UUID,		2,	/* transfer */
55 	0,				/* no bind_instance_size */
56 	0,				/* no bind_req() */
57 	0,				/* no unbind_and_close() */
58 	0,				/* use generic_call_stub() */
59 	&TYPEINFO(msgsvcsend_interface),	/* interface ti */
60 	msgsvcsend_stub_table		/* stub_table */
61 };
62 
63 void
64 msgsvcsend_initialize(void)
65 {
66 	(void) ndr_svc_register(&msgsvcsend_service);
67 }
68 
69 static int
70 msgsvcsend_NetrSendMessage(void *arg, ndr_xa_t *mxa)
71 {
72 	msgsvcsend_NetrSendMessage_t *param = arg;
73 
74 	if (!ndr_is_admin(mxa)) {
75 		param->status = ERROR_ACCESS_DENIED;
76 		return (NDR_DRC_OK);
77 	}
78 
79 	if (param->from == NULL || param->to == NULL || param->text == NULL) {
80 		param->status = ERROR_INVALID_PARAMETER;
81 		return (NDR_DRC_OK);
82 	}
83 
84 	syslog(LOG_INFO, "%s to %s: %s", param->from,  param->to, param->text);
85 	param->status = ERROR_SUCCESS;
86 	return (NDR_DRC_OK);
87 }
88