libsmb.h revision 89dc44ce9705974a8bc4a39f1e878a0491a5be61
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern "C" {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb#define SMB_CCACHE_PATH SMB_VARRUN_DIR "/" SMB_CCACHE_FILE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* Max value length of all SMB properties */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBD_DEFAULT_INSTANCE_FMRI "svc:/network/smb/server:default"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBD_SMF_NO_MEMORY 1 /* no memory for data structures */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBD_SMF_SYSTEM_ERR 2 /* system error, use errno */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBD_SMF_NO_PERMISSION 3 /* no permission for operation */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct smb_scfhandle {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CIFS Configuration Management
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef enum {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* SMF helper functions */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_set_string_property(smb_scfhandle_t *, char *, char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_get_string_property(smb_scfhandle_t *, char *,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_set_integer_property(smb_scfhandle_t *, char *, int64_t);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_get_integer_property(smb_scfhandle_t *, char *, int64_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_set_boolean_property(smb_scfhandle_t *, char *, uint8_t);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_get_boolean_property(smb_scfhandle_t *, char *, uint8_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_set_opaque_property(smb_scfhandle_t *, char *,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_get_opaque_property(smb_scfhandle_t *, char *,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_smf_create_service_pgroup(smb_scfhandle_t *, char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* Configuration management functions */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern char *smb_config_get_localsid(void);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern int smb_config_secmode_fromstr(char *);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern char *smb_config_secmode_tostr(int);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_config_get_secmode(void);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern int smb_config_set_secmode(int);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern int smb_config_set_idmap_domain(char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_config_refresh_idmap(void);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern int smb_setdomainprops(char *, char *, char *);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern void smb_update_netlogon_seqnum(void);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/* maximum password length on Windows 2000 and above */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#define SMB_PASSWD_MAXLEN 127
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#define SMB_USERNAME_MAXLEN 40
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct smb_joininfo {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States char domain_username[SMB_USERNAME_MAXLEN + 1];
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States char domain_passwd[SMB_PASSWD_MAXLEN + 1];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* APIs to communicate with SMB daemon via door calls */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern bool_t xdr_smb_dr_joininfo_t(XDR *, smb_joininfo_t *);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregoextern void nt_domain_save(void);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregoextern void nt_domain_show(void);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregoextern void nt_domain_unlink(void);
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern void smb_config_getdomaininfo(char *domain, char *fqdn, char *forest,
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern void smb_config_setdomaininfo(char *domain, char *fqdn, char *forest,
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern uint32_t smb_get_dcinfo(char *, uint32_t, uint32_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * buffer context structure. This is used to keep track of the buffer
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * context.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * basep: points to the beginning of the buffer
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * curp: points to the current offset
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * endp: points to the limit of the buffer
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *basep;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *curp;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *endp;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_ctxbuf_init(smb_ctxbuf_t *ctx, unsigned char *buf,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_ctxbuf_printf(smb_ctxbuf_t *ctx, const char *fmt, ...);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* Functions to handle SMB daemon communications with idmap service */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_idmap_start(void);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern void smb_idmap_stop(void);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_idmap_restart(void);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* Miscellaneous functions */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern void hexdump(unsigned char *, int);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern size_t bintohex(const char *, size_t, char *, size_t);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern size_t hextobin(const char *, size_t, char *, size_t);
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern char *strstrip(char *, const char *);
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern char *strtrim(char *, const char *);
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern char *trim_whitespace(char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern void randomize(char *, unsigned);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern void rand_hash(unsigned char *, size_t, unsigned char *, size_t);
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern struct hostent *smb_gethostbyname(const char *, int *);
8d7e41661dc4633488e93b13363137523ce59977jose borregoextern struct hostent *smb_gethostbyaddr(const char *, int, int, int *);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#define SMB_SAMACCT_MAXLEN (NETBIOS_NAME_SZ + 1)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesextern int smb_getsamaccount(char *, size_t);
7b59d02d2a384be9a08087b14defadd214b3c1ddjbextern void smb_tonetbiosname(char *, char *, char);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesextern int smb_chk_hostaccess(ipaddr_t, char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid smb_trace(const char *s);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Authentication
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBAUTH_HASH_SZ 16 /* also LM/NTLM/NTLMv2 Hash size */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBAUTH_LM_RESP_SZ 24 /* also NTLM Response size */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBAUTH_V2_CLNT_CHALLENGE_SZ 8 /* both LMv2 and NTLMv2 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Name Types
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The list of names near the end of the data blob (i.e. the ndb_names
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * field of the smb_auth_data_blob_t data structure) can be classify into
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the following types:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x0000 Indicates the end of the list.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x0001 The name is a NetBIOS machine name (e.g. server name)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x0002 The name is an NT Domain NetBIOS name.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x0003 The name is the server's DNS hostname.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x0004 The name is a W2K Domain name (a DNS name).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_auth_name_entry_t
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Each name entry in the data blob consists of the following 3 fields:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * nne_type - name type
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * nne_len - the length of the name
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * nne_name - the name, in uppercase UCS-2LE Unicode format
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct smb_auth_name_entry {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned short nne_type;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned short nne_len;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_auth_data_blob
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The format of this NTLMv2 data blob structure is as follow:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * - Blob Signature 0x01010000 (4 bytes)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * - Reserved (0x00000000) (4 bytes)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * - Timestamp Little-endian, 64-bit signed value representing
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the number of tenths of a microsecond since January 1, 1601.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * (8 bytes)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * - Client Challenge (8 bytes)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * - Unknown1 (4 bytes)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * - List of Target Information (variable length)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * - Unknown2 (4 bytes)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct smb_auth_data_blob {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char ndb_clnt_challenge[SMBAUTH_V2_CLNT_CHALLENGE_SZ];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBAUTH_BLOB_MAXLEN (sizeof (smb_auth_data_blob_t))
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMBAUTH_CS_MAXLEN (SMBAUTH_BLOB_MAXLEN + SMBAUTH_HASH_SZ)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_auth_info_t
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The structure contains all the authentication information
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * needed for the preparaton of the SMBSessionSetupAndx request
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and the user session key.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * hash - NTLM hash
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * hash_v2 - NTLMv2 hash
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ci_len - the length of the case-insensitive password
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ci - case-insensitive password
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * (If NTLMv2 authentication mechanism is used, it
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * represents the LMv2 response. Otherwise, it
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * is empty.)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * cs_len - the length of the case-sensitive password
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * cs - case-sensitive password
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * (If NTLMv2 authentication mechanism is used, it
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * represents the NTLMv2 response. Otherwise, it
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * represents the NTLM response.)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data_blob - NTLMv2 data blob
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct smb_auth_info {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned short ci_len;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned short cs_len;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB password management
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct smb_passwd {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Control flags passed to smb_pwd_setcntl
3db3f65c6274eb042354801a308c8e9bc4994553amwtypedef struct smb_pwditer {
3db3f65c6274eb042354801a308c8e9bc4994553amwtypedef struct smb_luser {
7b59d02d2a384be9a08087b14defadd214b3c1ddjbextern void smb_pwd_fini(void);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregoextern smb_passwd_t *smb_pwd_getpwnam(const char *, smb_passwd_t *);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregoextern smb_passwd_t *smb_pwd_getpwuid(uid_t, smb_passwd_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_pwd_setpasswd(const char *, const char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_pwd_setcntl(const char *, int);
3db3f65c6274eb042354801a308c8e9bc4994553amwextern int smb_pwd_num(void);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_qnd_unicode(mts_wchar_t *dst, char *src, int length);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_hmac_md5(unsigned char *data, int data_len,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *key, int key_len, unsigned char *digest);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * A variation on HMAC-MD5 known as HMACT64 is used by Windows systems.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The HMACT64() function is the same as the HMAC-MD5() except that
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * it truncates the input key to 64 bytes rather than hashing it down
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * to 16 bytes using the MD5() function.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_auth_hmac_md5(D, Ds, K, (Ks > 64) ? 64 : Ks, digest)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_DES(unsigned char *, int, unsigned char *, int,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *, int);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_md4(unsigned char *, unsigned char *, int);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_lm_hash(char *, unsigned char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_ntlm_hash(char *, unsigned char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_set_info(char *, char *,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned char *, char *, unsigned char *,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int, int, smb_auth_info_t *);
8c10a8659ac31335ed870a1711c0182623f72fd6asextern int smb_auth_ntlmv2_hash(unsigned char *,
8c10a8659ac31335ed870a1711c0182623f72fd6as char *, char *, unsigned char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_auth_gen_session_key(smb_auth_info_t *, unsigned char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwboolean_t smb_auth_validate_lm(unsigned char *, uint32_t, smb_passwd_t *,
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as unsigned char *, int, char *, char *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwboolean_t smb_auth_validate_nt(unsigned char *, uint32_t, smb_passwd_t *,
c8ec8eea9849cac239663c46be8a7f5d2ba7ca00jose borrego unsigned char *, int, char *, char *, uchar_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB MAC Signing
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMB_MAC_KEY_SZ (SMBAUTH_SESSION_KEY_SZ + SMBAUTH_CS_MAXLEN)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define SMB_SIG_OFFS 14 /* signature field offset within header */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Signing flags:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB_SCF_ENABLE Signing is enabled.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB_SCF_REQUIRED Signing is enabled and required.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This flag shouldn't be set if
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB_SCF_ENABLE isn't set.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB_SCF_STARTED Signing will start after receiving
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the first non-anonymous SessionSetup
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * request.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB_SCF_KEY_ISSET_THIS_LOGON Indicates whether the MAC key has just
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * been set for this logon. (prior to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * sending the SMBSessionSetup request)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_sign_ctx
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB signing context.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ssc_seqnum sequence number
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ssc_keylen mac key length
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ssc_mid multiplex id - reserved
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ssc_flags flags
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ssc_mackey mac key
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ssc_sign mac signature
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct smb_sign_ctx {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned int ssc_seqnum;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned short ssc_keylen;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned short ssc_mid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw unsigned int ssc_flags;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern int smb_mac_init(smb_sign_ctx_t *sign_ctx, smb_auth_info_t *auth);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw const unsigned char *buf, size_t buf_len, unsigned char *mac_sign);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern void smb_mac_inc_seqnum(smb_sign_ctx_t *sign_ctx);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern void smb_mac_dec_seqnum(smb_sign_ctx_t *sign_ctx);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Each domain is categorized using the enum values below.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The local domain refers to the local machine and is named
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * after the local hostname. The primary domain is the domain
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * that the system joined. All other domains are either
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * trusted or untrusted, as defined by the primary domain PDC.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This enum must be kept in step with the table of strings
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef enum nt_domain_type {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This is the information that is held about each domain. The database
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * is a linked list that is threaded through the domain structures. As
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the number of domains in the database should be small (32 max), this
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * should be sufficient.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct nt_domain {
6537f381d2d9e7b4e2f7b29c3e7a3f13be036f2easnt_domain_t *nt_domain_new(nt_domain_type_t type, char *name, smb_sid_t *sid);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwnt_domain_type_t nt_domain_xlat_type_name(char *type_name);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwnt_domain_t *nt_domain_lookupbytype(nt_domain_type_t type);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5astypedef enum {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5astypedef struct smb_gsid {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5astypedef struct smb_giter {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5astypedef struct smb_group {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5asint smb_lgrp_add(char *, char *);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5asint smb_lgrp_rename(char *, char *);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5asint smb_lgrp_setcmnt(char *, char *);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5asint smb_lgrp_getcmnt(char *, char **);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5asint smb_lgrp_getbyrid(uint32_t, smb_gdomain_t, smb_group_t *);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as#define SMB_LGRP_NAME_MAX (SMB_LGRP_NAME_CHAR_MAX * MTS_MB_CHAR_MAX + 1)
7b59d02d2a384be9a08087b14defadd214b3c1ddjb * values for smb_nic_t.smbflags
7b59d02d2a384be9a08087b14defadd214b3c1ddjb#define SMB_NICF_NBEXCL 0x01 /* Excluded from Netbios activities */
7b59d02d2a384be9a08087b14defadd214b3c1ddjb * smb_nic_t
7b59d02d2a384be9a08087b14defadd214b3c1ddjb * nic_host actual host name
7b59d02d2a384be9a08087b14defadd214b3c1ddjb * nic_nbname 16-byte NetBIOS host name
7b59d02d2a384be9a08087b14defadd214b3c1ddjbtypedef struct {
7b59d02d2a384be9a08087b14defadd214b3c1ddjbtypedef struct smb_niciter {
7b59d02d2a384be9a08087b14defadd214b3c1ddjb/* NIC config functions */
7b59d02d2a384be9a08087b14defadd214b3c1ddjbint smb_nic_addhost(const char *, const char *, int, const char **);
7b59d02d2a384be9a08087b14defadd214b3c1ddjbint smb_nic_delhost(const char *);
6537f381d2d9e7b4e2f7b29c3e7a3f13be036f2eas/* NIC Monitoring functions */
6537f381d2d9e7b4e2f7b29c3e7a3f13be036f2easint smb_nicmon_start(const char *);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * Well-known account structure
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * A security identifier (SID) is a unique value of variable length that
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * is used to identify a security principal or security group in
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * Windows. Well-known SIDs are a group of SIDs that identify generic
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * users or generic groups. Their values remain constant across all
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * operating systems.
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * This structure is defined to store these SIDs and other related
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * information about them (e.g. account and domain names) in a
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * predefined table.
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregotypedef struct smb_wka {
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * Defined values for smb_wka.wka_flags
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * SMB_WKAFLG_LGRP_ENABLE Can be added as local group
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * Well-known account interfaces
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregochar *smb_wka_lookup_sid(smb_sid_t *, uint16_t *);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregosmb_sid_t *smb_wka_lookup_name(char *, uint16_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif /* _LIBSMB_H */