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