15331Samw /* 25331Samw * CDDL HEADER START 35331Samw * 45331Samw * The contents of this file are subject to the terms of the 55331Samw * Common Development and Distribution License (the "License"). 65331Samw * You may not use this file except in compliance with the License. 75331Samw * 85331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95331Samw * or http://www.opensolaris.org/os/licensing. 105331Samw * See the License for the specific language governing permissions 115331Samw * and limitations under the License. 125331Samw * 135331Samw * When distributing Covered Code, include this CDDL HEADER in each 145331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155331Samw * If applicable, add the following below this CDDL HEADER, with the 165331Samw * fields enclosed by brackets "[]" replaced with your own identifying 175331Samw * information: Portions Copyright [yyyy] [name of copyright owner] 185331Samw * 195331Samw * CDDL HEADER END 205331Samw */ 215331Samw /* 228474SJose.Borrego@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 235331Samw * Use is subject to license terms. 245331Samw */ 255331Samw 265331Samw #ifndef _LIBMLSVC_H 275331Samw #define _LIBMLSVC_H 285331Samw 298334SJose.Borrego@Sun.COM #include <sys/param.h> 305331Samw #include <sys/types.h> 318334SJose.Borrego@Sun.COM #include <sys/uio.h> 328334SJose.Borrego@Sun.COM #include <sys/ksynch.h> 338334SJose.Borrego@Sun.COM #include <stdio.h> 348334SJose.Borrego@Sun.COM #include <string.h> 358334SJose.Borrego@Sun.COM #include <smbsrv/wintypes.h> 365331Samw #include <smbsrv/hash_table.h> 375331Samw #include <smbsrv/smb_token.h> 385331Samw #include <smbsrv/smb_privilege.h> 397052Samw #include <smbsrv/smb_share.h> 408334SJose.Borrego@Sun.COM #include <smbsrv/smb_xdr.h> 415331Samw #include <smbsrv/libsmb.h> 428334SJose.Borrego@Sun.COM #include <smbsrv/libsmbrdr.h> 438334SJose.Borrego@Sun.COM #include <smbsrv/libmlrpc.h> 448334SJose.Borrego@Sun.COM #include <smbsrv/ndl/lsarpc.ndl> 455331Samw 465331Samw #ifdef __cplusplus 475331Samw extern "C" { 485331Samw #endif 495331Samw 508334SJose.Borrego@Sun.COM extern uint32_t mlsvc_lookup_name(char *, smb_sid_t **, uint16_t *); 518334SJose.Borrego@Sun.COM extern uint32_t mlsvc_lookup_sid(smb_sid_t *, char **); 528334SJose.Borrego@Sun.COM 538334SJose.Borrego@Sun.COM /* 548334SJose.Borrego@Sun.COM * SMB domain API to discover a domain controller and obtain domain 558334SJose.Borrego@Sun.COM * information. 568334SJose.Borrego@Sun.COM */ 578334SJose.Borrego@Sun.COM 588334SJose.Borrego@Sun.COM extern boolean_t smb_locate_dc(char *, char *, smb_domain_t *); 598334SJose.Borrego@Sun.COM extern boolean_t smb_domain_getinfo(smb_domain_t *); 608334SJose.Borrego@Sun.COM 618334SJose.Borrego@Sun.COM 627588Samw@Sun.COM extern uint64_t mlsvc_get_num_users(void); 63*9832Samw@Sun.COM extern int mlsvc_get_user_list(smb_ulist_t *); 647619SJose.Borrego@Sun.COM extern void dssetup_clear_domain_info(void); 655331Samw extern int mlsvc_init(void); 66*9832Samw@Sun.COM extern void mlsvc_fini(void); 677588Samw@Sun.COM extern int mlsvc_set_share(int, char *, char *); 686139Sjb150015 extern DWORD mlsvc_netlogon(char *, char *); 698334SJose.Borrego@Sun.COM extern DWORD mlsvc_join(smb_domain_t *, char *, char *); 708334SJose.Borrego@Sun.COM 718334SJose.Borrego@Sun.COM 728334SJose.Borrego@Sun.COM /* 738334SJose.Borrego@Sun.COM * The maximum number of domains (NT limit). 748334SJose.Borrego@Sun.COM */ 758334SJose.Borrego@Sun.COM #define MLSVC_DOMAIN_MAX 32 768334SJose.Borrego@Sun.COM 778334SJose.Borrego@Sun.COM /* 788334SJose.Borrego@Sun.COM * Status code returned from enumeration RPCs to indicate 798334SJose.Borrego@Sun.COM * that the server has no more data. Normally returned at 808334SJose.Borrego@Sun.COM * severity level ERROR_SEVERITY_WARNING. 818334SJose.Borrego@Sun.COM */ 828334SJose.Borrego@Sun.COM #define MLSVC_NO_MORE_DATA 0x1A 835331Samw 848334SJose.Borrego@Sun.COM #define MLSVC_ANON_USER "IPC$" 858334SJose.Borrego@Sun.COM 868334SJose.Borrego@Sun.COM char *mlsvc_ipc_name(int ipc_type, char *username); 878334SJose.Borrego@Sun.COM 888334SJose.Borrego@Sun.COM /* 898334SJose.Borrego@Sun.COM * Passthrough negotiation and authentication interface. 908334SJose.Borrego@Sun.COM * 918334SJose.Borrego@Sun.COM * NT supports two forms of password: a Lanman (case-insensitive) 928334SJose.Borrego@Sun.COM * password and an NT (case-sensitive) password. If either of the 938334SJose.Borrego@Sun.COM * passwords is not available its pointer and length should be set 948334SJose.Borrego@Sun.COM * to zero. The session key and vc number are required to validate 958334SJose.Borrego@Sun.COM * the encrypted passwords. 968334SJose.Borrego@Sun.COM */ 978334SJose.Borrego@Sun.COM 988334SJose.Borrego@Sun.COM void mlsvc_nt_password_hash(char *result, char *password); 998334SJose.Borrego@Sun.COM int mlsvc_encrypt_nt_password(char *password, char *key, int keylen, char *out, 1008334SJose.Borrego@Sun.COM int outmax); 1015331Samw 1025331Samw #define SMB_AUTOHOME_FILE "smbautohome" 1035331Samw #define SMB_AUTOHOME_PATH "/etc" 1045331Samw 1055331Samw typedef struct smb_autohome { 1065331Samw struct smb_autohome *ah_next; 1075331Samw uint32_t ah_hits; 1085331Samw time_t ah_timestamp; 1095331Samw char *ah_name; /* User account name */ 1105331Samw char *ah_path; /* Home directory path */ 1115331Samw char *ah_container; /* ADS container distinguished name */ 1125331Samw } smb_autohome_t; 1135331Samw 1146771Sjb150015 extern void smb_autohome_add(const char *); 1156771Sjb150015 extern void smb_autohome_remove(const char *); 1165331Samw 1178334SJose.Borrego@Sun.COM /* 1188334SJose.Borrego@Sun.COM * A local unique id (LUID) is an opaque id used by servers to identify 1198334SJose.Borrego@Sun.COM * local resources, such as privileges. A client will use lookup 1208334SJose.Borrego@Sun.COM * functions to translate the LUID to a more general, machine independent 1218334SJose.Borrego@Sun.COM * form; such as a string. 1228334SJose.Borrego@Sun.COM */ 1238334SJose.Borrego@Sun.COM typedef struct ms_luid { 1248334SJose.Borrego@Sun.COM uint32_t low_part; 1258334SJose.Borrego@Sun.COM uint32_t high_part; 1268334SJose.Borrego@Sun.COM } ms_luid_t; 1278334SJose.Borrego@Sun.COM 1288334SJose.Borrego@Sun.COM /* 1298334SJose.Borrego@Sun.COM * A client_t is created while binding a client connection to hold the 1308334SJose.Borrego@Sun.COM * context for calls made using that connection. 1318334SJose.Borrego@Sun.COM * 1328334SJose.Borrego@Sun.COM * Handles are RPC call specific and we use an inheritance mechanism to 1338334SJose.Borrego@Sun.COM * ensure that each handle has a pointer to the client_t. When the top 1348334SJose.Borrego@Sun.COM * level (bind) handle is released, we close the connection. 1358334SJose.Borrego@Sun.COM */ 1368334SJose.Borrego@Sun.COM typedef struct mlsvc_handle { 1378334SJose.Borrego@Sun.COM ndr_hdid_t handle; 1388334SJose.Borrego@Sun.COM ndr_client_t *clnt; 1398334SJose.Borrego@Sun.COM int remote_os; 1408334SJose.Borrego@Sun.COM } mlsvc_handle_t; 1418334SJose.Borrego@Sun.COM 1428334SJose.Borrego@Sun.COM int ndr_rpc_bind(mlsvc_handle_t *, char *, char *, char *, const char *); 1438334SJose.Borrego@Sun.COM void ndr_rpc_unbind(mlsvc_handle_t *); 1448334SJose.Borrego@Sun.COM int ndr_rpc_call(mlsvc_handle_t *, int, void *); 1458334SJose.Borrego@Sun.COM int ndr_rpc_server_os(mlsvc_handle_t *); 1468334SJose.Borrego@Sun.COM void *ndr_rpc_malloc(mlsvc_handle_t *, size_t); 1478334SJose.Borrego@Sun.COM ndr_heap_t *ndr_rpc_get_heap(mlsvc_handle_t *); 1488334SJose.Borrego@Sun.COM void ndr_rpc_release(mlsvc_handle_t *); 1498334SJose.Borrego@Sun.COM boolean_t ndr_is_null_handle(mlsvc_handle_t *); 1508334SJose.Borrego@Sun.COM boolean_t ndr_is_bind_handle(mlsvc_handle_t *); 1518334SJose.Borrego@Sun.COM void ndr_inherit_handle(mlsvc_handle_t *, mlsvc_handle_t *); 1528334SJose.Borrego@Sun.COM void ndr_rpc_status(mlsvc_handle_t *, int, uint32_t); 1538334SJose.Borrego@Sun.COM 1545331Samw #ifdef __cplusplus 1555331Samw } 1565331Samw #endif 1575331Samw 1585331Samw #endif /* _LIBMLSVC_H */ 159