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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
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 <time.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <netdb.h>
38 #include <libuutil.h>
39 #include <smbsrv/wintypes.h>
40 #include <smbsrv/hash_table.h>
41 #include <smbsrv/smb_token.h>
42 #include <smbsrv/smb_privilege.h>
43 #include <smbsrv/smb_share.h>
44 #include <smbsrv/smb_xdr.h>
45 #include <smbsrv/smb_dfs.h>
46 #include <smbsrv/libsmb.h>
47 #include <smbsrv/libmlrpc.h>
48 #include <smbsrv/ndl/lsarpc.ndl>
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 uint32_t lsa_lookup_name(char *, uint16_t, smb_account_t *);
55 uint32_t lsa_lookup_sid(smb_sid_t *, smb_account_t *);
56
57 /*
58 * SMB domain API to discover a domain controller and obtain domain
59 * information.
60 */
61
62 extern boolean_t smb_locate_dc(char *, smb_domainex_t *);
63 uint32_t smb_ddiscover_dns(char *, smb_domainex_t *);
64 extern void smb_ddiscover_bad_dc(char *);
65 extern void smb_ddiscover_refresh(void);
66 extern int smb_ddiscover_wait(void);
67
68 extern int dssetup_check_service(void);
69 extern void dssetup_clear_domain_info(void);
70 extern void mlsvc_disconnect(const char *);
71 extern int mlsvc_init(void);
72 extern void mlsvc_fini(void);
73 extern DWORD mlsvc_netlogon(char *, char *);
74 extern void mlsvc_join(smb_joininfo_t *, smb_joinres_t *);
75
76 extern void smb_logon_domain(smb_logon_t *, smb_token_t *);
77 extern uint32_t smb_decode_krb5_pac(smb_token_t *, char *, uint_t);
78 extern boolean_t smb_token_setup_common(smb_token_t *);
79
80
81 /*
82 * The maximum number of domains (NT limit).
83 */
84 #define MLSVC_DOMAIN_MAX 32
85
86 #define MLSVC_ANON_USER "IPC$"
111 char *ah_name; /* User account name */
112 char *ah_path; /* Home directory path */
113 char *ah_container; /* ADS container distinguished name */
114 } smb_autohome_t;
115
116 extern void smb_autohome_add(const smb_token_t *);
117 extern void smb_autohome_remove(const char *);
118
119 /*
120 * A local unique id (LUID) is an opaque id used by servers to identify
121 * local resources, such as privileges. A client will use lookup
122 * functions to translate the LUID to a more general, machine independent
123 * form; such as a string.
124 */
125 typedef struct ms_luid {
126 uint32_t low_part;
127 uint32_t high_part;
128 } ms_luid_t;
129
130 /*
131 * Information about a server as reported by NetServerGetInfo.
132 * The SV_PLATFORM and SV_TYPE definitions are in srvsvc.ndl.
133 */
134 typedef struct srvsvc_server_info {
135 uint32_t sv_platform_id;
136 char *sv_name;
137 uint32_t sv_version_major;
138 uint32_t sv_version_minor;
139 uint32_t sv_type;
140 char *sv_comment;
141 uint32_t sv_os;
142 } srvsvc_server_info_t;
143
144 int srvsvc_net_server_getinfo(char *, char *, srvsvc_server_info_t *);
145 int srvsvc_net_remote_tod(char *, char *, struct timeval *, struct tm *);
146
147
148 /*
149 * A client_t is created while binding a client connection to hold the
150 * context for calls made using that connection.
151 *
152 * Handles are RPC call specific and we use an inheritance mechanism to
153 * ensure that each handle has a pointer to the client_t. When the top
154 * level (bind) handle is released, we close the connection.
155 */
156 typedef struct mlsvc_handle {
157 ndr_hdid_t handle;
158 ndr_client_t *clnt;
159 srvsvc_server_info_t svinfo;
160 } mlsvc_handle_t;
161
162 void ndr_rpc_init(void);
163 void ndr_rpc_fini(void);
164 uint32_t ndr_rpc_bind(mlsvc_handle_t *, char *, char *, char *, const char *);
165 void ndr_rpc_unbind(mlsvc_handle_t *);
166 int ndr_rpc_call(mlsvc_handle_t *, int, void *);
167 void ndr_rpc_set_nonull(mlsvc_handle_t *);
168 const srvsvc_server_info_t *ndr_rpc_server_info(mlsvc_handle_t *);
169 uint32_t ndr_rpc_server_os(mlsvc_handle_t *);
170 int ndr_rpc_get_ssnkey(mlsvc_handle_t *, unsigned char *, size_t);
171 void *ndr_rpc_malloc(mlsvc_handle_t *, size_t);
172 ndr_heap_t *ndr_rpc_get_heap(mlsvc_handle_t *);
173 void ndr_rpc_release(mlsvc_handle_t *);
174 boolean_t ndr_is_null_handle(mlsvc_handle_t *);
175 boolean_t ndr_is_bind_handle(mlsvc_handle_t *);
176 void ndr_inherit_handle(mlsvc_handle_t *, mlsvc_handle_t *);
177 void ndr_rpc_status(mlsvc_handle_t *, int, uint32_t);
178
179 /* SVCCTL service */
180 /*
181 * Calculate the wide-char equivalent string length required to
182 * store a string - including the terminating null wide-char.
183 */
184 #define SVCCTL_WNSTRLEN(S) ((strlen((S)) + 1) * sizeof (smb_wchar_t))
185
186 /* An AVL-storable node representing each service in the SCM database. */
187 typedef struct svcctl_svc_node {
188 uu_avl_node_t sn_node;
189 char *sn_name; /* Service Name (Key) */
190 char *sn_fmri; /* Display Name (FMRI) */
191 char *sn_desc; /* Description */
192 char *sn_state; /* State */
193 } svcctl_svc_node_t;
194
195 /* This structure provides context for each svcctl_s_OpenManager call. */
196 typedef struct svcctl_manager_context {
197 scf_handle_t *mc_scf_hdl; /* SCF handle */
198 scf_propertygroup_t *mc_scf_gpg; /* Property group */
|
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2019 Nexenta Systems, Inc. All rights reserved.
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 <uuid/uuid.h>
34
35 #include <time.h>
36 #include <stdio.h>
37 #include <string.h>
38 #include <syslog.h>
39 #include <netdb.h>
40 #include <libuutil.h>
41
42 #include <smb/wintypes.h>
43 #include <libmlrpc/libmlrpc.h>
44
45 #include <smbsrv/hash_table.h>
46 #include <smbsrv/smb_token.h>
47 #include <smbsrv/smb_privilege.h>
48 #include <smbsrv/smb_share.h>
49 #include <smbsrv/smb_xdr.h>
50 #include <smbsrv/smb_dfs.h>
51 #include <smbsrv/libsmb.h>
52
53 /*
54 * XXX: Some temporary left-overs from the old ntstatus.h
55 * Should eliminate uses of these macros when convenient.
56 */
57 /* This used to OR in the severity bits. */
58 #define NT_SC_ERROR(S) (S)
59 /* This used to mask off the severity bits. */
60 #define NT_SC_VALUE(S) (S)
61 /* XXX end of temporary left-overs. */
62
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66
67 uint32_t lsa_lookup_name(char *, uint16_t, smb_account_t *);
68 uint32_t lsa_lookup_lname(char *, uint16_t, smb_account_t *);
69 uint32_t lsa_lookup_sid(smb_sid_t *, smb_account_t *);
70 uint32_t lsa_lookup_lsid(smb_sid_t *, smb_account_t *);
71
72 /*
73 * SMB domain API to discover a domain controller and obtain domain
74 * information.
75 */
76
77 extern boolean_t smb_locate_dc(char *, smb_domainex_t *);
78 uint32_t smb_ddiscover_dns(char *, smb_domainex_t *);
79 extern void smb_ddiscover_bad_dc(char *);
80 extern void smb_ddiscover_refresh(void);
81
82 extern int dssetup_check_service(void);
83 extern void dssetup_clear_domain_info(void);
84 extern void mlsvc_disconnect(const char *);
85 extern int mlsvc_init(void);
86 extern void mlsvc_fini(void);
87 extern DWORD mlsvc_netlogon(char *, char *);
88 extern void mlsvc_join(smb_joininfo_t *, smb_joinres_t *);
89
90 extern void smb_logon_domain(smb_logon_t *, smb_token_t *);
91 extern uint32_t smb_decode_krb5_pac(smb_token_t *, char *, uint_t);
92 extern boolean_t smb_token_setup_common(smb_token_t *);
93
94
95 /*
96 * The maximum number of domains (NT limit).
97 */
98 #define MLSVC_DOMAIN_MAX 32
99
100 #define MLSVC_ANON_USER "IPC$"
125 char *ah_name; /* User account name */
126 char *ah_path; /* Home directory path */
127 char *ah_container; /* ADS container distinguished name */
128 } smb_autohome_t;
129
130 extern void smb_autohome_add(const smb_token_t *);
131 extern void smb_autohome_remove(const char *);
132
133 /*
134 * A local unique id (LUID) is an opaque id used by servers to identify
135 * local resources, such as privileges. A client will use lookup
136 * functions to translate the LUID to a more general, machine independent
137 * form; such as a string.
138 */
139 typedef struct ms_luid {
140 uint32_t low_part;
141 uint32_t high_part;
142 } ms_luid_t;
143
144 /*
145 * A client_t is created while binding a client connection to hold the
146 * context for calls made using that connection.
147 *
148 * Handles are RPC call specific and we use an inheritance mechanism to
149 * ensure that each handle has a pointer to the client_t. When the top
150 * level (bind) handle is released, we close the connection.
151 */
152 typedef struct mlrpc_handle mlsvc_handle_t;
153
154 /* mlsvc_client.c */
155 void ndr_rpc_init(void);
156 void ndr_rpc_fini(void);
157 uint32_t ndr_rpc_bind(mlsvc_handle_t *, char *, char *, char *, const char *);
158 void ndr_rpc_unbind(mlsvc_handle_t *);
159 void ndr_rpc_status(mlsvc_handle_t *, int, uint32_t);
160
161 /* These three get info about the connected client. */
162 boolean_t ndr_is_admin(ndr_xa_t *);
163 boolean_t ndr_is_poweruser(ndr_xa_t *);
164 int32_t ndr_native_os(ndr_xa_t *);
165
166 /* SRVSVC */
167 int srvsvc_net_remote_tod(char *, char *, struct timeval *, struct tm *);
168
169 /* SVCCTL service */
170 /*
171 * Calculate the wide-char equivalent string length required to
172 * store a string - including the terminating null wide-char.
173 */
174 #define SVCCTL_WNSTRLEN(S) ((strlen((S)) + 1) * sizeof (smb_wchar_t))
175
176 /* An AVL-storable node representing each service in the SCM database. */
177 typedef struct svcctl_svc_node {
178 uu_avl_node_t sn_node;
179 char *sn_name; /* Service Name (Key) */
180 char *sn_fmri; /* Display Name (FMRI) */
181 char *sn_desc; /* Description */
182 char *sn_state; /* State */
183 } svcctl_svc_node_t;
184
185 /* This structure provides context for each svcctl_s_OpenManager call. */
186 typedef struct svcctl_manager_context {
187 scf_handle_t *mc_scf_hdl; /* SCF handle */
188 scf_propertygroup_t *mc_scf_gpg; /* Property group */
|