xref: /illumos-gate/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c (revision f17620a4f72a29025a22655ba8735ccd20ae174f)
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  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 /*
28  * Message Service
29  */
30 
31 #include <syslog.h>
32 #include <stdlib.h>
33 
34 #include <libmlrpc/libmlrpc.h>
35 #include <smbsrv/libsmb.h>
36 #include <smbsrv/libmlsvc.h>
37 #include <smbsrv/ndl/msgsvc.ndl>
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