xref: /titanic_50/usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h (revision 4944376cd5de3dcd3b4feeaad9cbedbc024d1474)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBMLSVC_H
27 #define	_LIBMLSVC_H
28 
29 #include <uuid/uuid.h>
30 #include <sys/param.h>
31 #include <sys/types.h>
32 #include <sys/uio.h>
33 #include <sys/ksynch.h>
34 #include <stdio.h>
35 #include <string.h>
36 #include <smbsrv/wintypes.h>
37 #include <smbsrv/hash_table.h>
38 #include <smbsrv/smb_token.h>
39 #include <smbsrv/smb_privilege.h>
40 #include <smbsrv/smb_share.h>
41 #include <smbsrv/smb_xdr.h>
42 #include <smbsrv/libsmb.h>
43 #include <smbsrv/libsmbrdr.h>
44 #include <smbsrv/libmlrpc.h>
45 #include <smbsrv/ndl/lsarpc.ndl>
46 
47 #ifdef	__cplusplus
48 extern "C" {
49 #endif
50 
51 extern uint32_t mlsvc_lookup_name(char *, smb_sid_t **, uint16_t *);
52 extern uint32_t mlsvc_lookup_sid(smb_sid_t *, char **);
53 
54 /*
55  * SMB domain API to discover a domain controller and obtain domain
56  * information.
57  */
58 
59 typedef struct smb_domain {
60 	char	d_dc[MAXHOSTNAMELEN];
61 	char	d_nbdomain[NETBIOS_NAME_SZ];
62 	char	d_fqdomain[MAXHOSTNAMELEN];
63 	char	d_forest[MAXHOSTNAMELEN];
64 	char	d_guid[UUID_PRINTABLE_STRING_LENGTH];
65 } smb_domain_t;
66 extern boolean_t smb_locate_dc(char *, char *, smb_domain_t *);
67 extern boolean_t smb_domain_getinfo(smb_domain_t *);
68 
69 
70 extern int mlsvc_get_door_fd(void);
71 extern uint64_t mlsvc_get_num_users(void);
72 extern int mlsvc_get_user_list(int, smb_dr_ulist_t *);
73 extern void dssetup_clear_domain_info(void);
74 extern int mlsvc_init(void);
75 extern void mlsvc_set_door_fd(int);
76 extern int mlsvc_set_share(int, char *, char *);
77 extern DWORD mlsvc_netlogon(char *, char *);
78 extern DWORD mlsvc_join(smb_domain_t *, char *, char *);
79 
80 
81 /*
82  * The maximum number of domains (NT limit).
83  */
84 #define	MLSVC_DOMAIN_MAX		32
85 
86 /*
87  * Status code returned from enumeration RPCs to indicate
88  * that the server has no more data. Normally returned at
89  * severity level ERROR_SEVERITY_WARNING.
90  */
91 #define	MLSVC_NO_MORE_DATA		0x1A
92 
93 #define	MLSVC_ANON_USER			"IPC$"
94 
95 char *mlsvc_ipc_name(int ipc_type, char *username);
96 
97 /*
98  * Passthrough negotiation and authentication interface.
99  *
100  * NT supports two forms of password: a Lanman (case-insensitive)
101  * password and an NT (case-sensitive) password. If either of the
102  * passwords is not available its pointer and length should be set
103  * to zero. The session key and vc number are required to validate
104  * the encrypted passwords.
105  */
106 
107 void mlsvc_nt_password_hash(char *result, char *password);
108 int mlsvc_encrypt_nt_password(char *password, char *key, int keylen, char *out,
109     int outmax);
110 
111 #define	SMB_AUTOHOME_FILE	"smbautohome"
112 #define	SMB_AUTOHOME_PATH	"/etc"
113 
114 typedef struct smb_autohome {
115 	struct smb_autohome *ah_next;
116 	uint32_t ah_hits;
117 	time_t ah_timestamp;
118 	char *ah_name;		/* User account name */
119 	char *ah_path;		/* Home directory path */
120 	char *ah_container;	/* ADS container distinguished name */
121 } smb_autohome_t;
122 
123 extern void smb_autohome_add(const char *);
124 extern void smb_autohome_remove(const char *);
125 
126 /*
127  * A local unique id (LUID) is an opaque id used by servers to identify
128  * local resources, such as privileges.  A client will use lookup
129  * functions to translate the LUID to a more general, machine independent
130  * form; such as a string.
131  */
132 typedef struct ms_luid {
133 	uint32_t low_part;
134 	uint32_t high_part;
135 } ms_luid_t;
136 
137 /*
138  * A client_t is created while binding a client connection to hold the
139  * context for calls made using that connection.
140  *
141  * Handles are RPC call specific and we use an inheritance mechanism to
142  * ensure that each handle has a pointer to the client_t.  When the top
143  * level (bind) handle is released, we close the connection.
144  */
145 typedef struct mlsvc_handle {
146 	ndr_hdid_t			handle;
147 	ndr_client_t			*clnt;
148 	int				remote_os;
149 } mlsvc_handle_t;
150 
151 int ndr_rpc_bind(mlsvc_handle_t *, char *, char *, char *, const char *);
152 void ndr_rpc_unbind(mlsvc_handle_t *);
153 int ndr_rpc_call(mlsvc_handle_t *, int, void *);
154 int ndr_rpc_server_os(mlsvc_handle_t *);
155 void *ndr_rpc_malloc(mlsvc_handle_t *, size_t);
156 ndr_heap_t *ndr_rpc_get_heap(mlsvc_handle_t *);
157 void ndr_rpc_release(mlsvc_handle_t *);
158 boolean_t ndr_is_null_handle(mlsvc_handle_t *);
159 boolean_t ndr_is_bind_handle(mlsvc_handle_t *);
160 void ndr_inherit_handle(mlsvc_handle_t *, mlsvc_handle_t *);
161 void ndr_rpc_status(mlsvc_handle_t *, int, uint32_t);
162 
163 #ifdef	__cplusplus
164 }
165 #endif
166 
167 #endif	/* _LIBMLSVC_H */
168