2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBSMBFS_H
2N/A#define _LIBSMBFS_H
2N/A
2N/A/*
2N/A * Defines the API exported to smbfs commands and to the
2N/A * MS-style RPC-over-named-pipes library (libndr).
2N/A */
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <sys/types.h>
2N/A#include <sys/acl.h>
2N/A
2N/A/*
2N/A * Some errno values we need to expose in this API.
2N/A * NB: These two defines are duplicated from the
2N/A * driver smb_dev.h to avoid exposing that here.
2N/A *
2N/A * EBADRPC is used for message decoding errors.
2N/A * EAUTH is used for CIFS authentication errors.
2N/A */
2N/A#ifndef EBADRPC
2N/A#define EBADRPC 113
2N/A#endif
2N/A#ifndef EAUTH
2N/A#define EAUTH 114
2N/A#endif
2N/A
2N/A
2N/A/*
2N/A * Share type values for smb_ctx_new, _init
2N/A * Based on NetUseAdd() USE_INFO_[12] _asg_type values
2N/A * They also happen to match: STYPE_DISKTREE, etc.
2N/A */
2N/Atypedef enum {
2N/A USE_DISKDEV = 0, /* also STYPE_DISKTREE */
2N/A USE_SPOOLDEV, /* also STYPE_PRINTQ */
2N/A USE_CHARDEV, /* also STYPE_DEVICE */
2N/A USE_IPC, /* also STYPE_IPC */
2N/A USE_WILDCARD /* also STYPE_UNKNOWN */
2N/A} smb_use_shtype_t;
2N/A
2N/A/*
2N/A * Parse "level" spec. for smb_ctx_parseunc()
2N/A * i.e. whether we require a share name, etc.
2N/A */
2N/Atypedef enum {
2N/A SMBL_NONE = 0, /* have nothing */
2N/A SMBL_SERVER, /* have server */
2N/A SMBL_VC = 1, /* alias for _SERVER */
2N/A SMBL_SHARE, /* have server share */
2N/A SMBL_PATH /* have server share path */
2N/A} smb_parse_level_t;
2N/A
2N/A/*
2N/A * Authentication type flags
2N/A * See: smb_ctx_setauthflags()
2N/A */
2N/A#define SMB_AT_ANON 1 /* anonymous (NULL session) */
2N/A#define SMB_AT_LM1 2 /* LM1 (with NTLM) */
2N/A#define SMB_AT_NTLM1 4 /* NTLM (v1) */
2N/A#define SMB_AT_NTLM2 8 /* NTLMv2 */
2N/A#define SMB_AT_KRB5 0x10 /* Kerberos5 (AD) */
2N/A#define SMB_AT_DEFAULT (SMB_AT_KRB5 | SMB_AT_NTLM2 | SMB_AT_NTLM1)
2N/A
2N/A/*
2N/A * Value of the ct_rflags, used to determine the context of request.
2N/A */
2N/A#define SMBFS_STANDALONE 0x00000000 /* Client standalone request */
2N/A#define SMBFS_OUTBOUNDDC 0x00000001 /* SMB server request */
2N/A
2N/Astruct smb_ctx; /* anonymous here; real one in smb_lib.h */
2N/Atypedef struct smb_ctx smb_ctx_t;
2N/A
2N/Aextern int smbfs_debug;
2N/A
2N/Aint smbfs_lib_init(void);
2N/Avoid smbfs_error(const char *, int, ...);
2N/A
2N/A/*
2N/A * Context management
2N/A */
2N/Aint smbfs_ctx_alloc(struct smb_ctx **);
2N/Avoid smbfs_ctx_free(struct smb_ctx *);
2N/Aint smbfs_ctx_kill(struct smb_ctx *);
2N/A
2N/Aint smbfs_ctx_parseunc(struct smb_ctx *, const char *, int, int, int,
2N/A const char **);
2N/Aint smbfs_ctx_parsedomuser(char *, char **, char **);
2N/Aint smbfs_get_authentication(struct smb_ctx *);
2N/A
2N/Aint smbfs_ctx_flags2(struct smb_ctx *);
2N/Aint smbfs_ctx_resolve(struct smb_ctx *);
2N/Aint smbfs_ctx_get_ssn(struct smb_ctx *);
2N/Aint smbfs_ctx_get_tree(struct smb_ctx *);
2N/A
2N/Aint smbfs_ctx_setauthflags(struct smb_ctx *, int);
2N/Aint smbfs_ctx_setcharset(struct smb_ctx *, const char *);
2N/Aint smbfs_ctx_setfullserver(struct smb_ctx *, const char *);
2N/Aint smbfs_ctx_setsigning(struct smb_ctx *, boolean_t required);
2N/A
2N/Aint smbfs_ctx_setnbflags(struct smb_ctx *, int ena, int bcast);
2N/Aint smbfs_ctx_setscope(struct smb_ctx *, const char *);
2N/Aint smbfs_ctx_setwins(struct smb_ctx *, const char *, const char *);
2N/A
2N/Aint smbfs_ctx_setserver(struct smb_ctx *, const char *);
2N/Aint smbfs_ctx_setshare(struct smb_ctx *, const char *, int);
2N/Aint smbfs_ctx_setrealm(struct smb_ctx *, const char *);
2N/Aint smbfs_ctx_setdomain(struct smb_ctx *, const char *, int);
2N/Aint smbfs_ctx_setuser(struct smb_ctx *, const char *, int);
2N/Aint smbfs_ctx_setpassword(struct smb_ctx *, const char *, int);
2N/Aint smbfs_ctx_setpwhash(struct smb_ctx *, const uchar_t *, const uchar_t *);
2N/A
2N/Atypedef void (*smb_ctx_close_hook_t)(struct smb_ctx *);
2N/A
2N/A/*
2N/A * Additional client context passed from consumers of smbfs_fh_open calls.
2N/A * These context values are set by consumers of smbfs_fh_open calls to
2N/A * facilitate authentication.
2N/A */
2N/Atypedef struct smbfs_fh_ctx {
2N/A char *sf_realm;
2N/A uint32_t sf_cflag;
2N/A} smbfs_fh_ctx_t;
2N/Avoid smbfs_fh_ctx_create(smbfs_fh_ctx_t *, uint32_t, char *);
2N/Avoid smbfs_fh_ctx_destroy(smbfs_fh_ctx_t *);
2N/A
2N/Aint smbfs_fh_open(const char *, int, const smbfs_fh_ctx_t *);
2N/Aint smbfs_fh_close(int);
2N/Aint smbfs_fh_read(int, void *, size_t, off_t);
2N/Aint smbfs_fh_write(int, const void *, size_t, off_t);
2N/Aint smbfs_fh_xactnp(int, int, const char *,
2N/A int *, char *, int *);
2N/Aint smbfs_fh_getssnkey(int, uchar_t *, size_t);
2N/Aint smbfs_print(const char *, const char *, const char *);
2N/A
2N/Avoid smbfs_set_default_domain(const char *);
2N/Avoid smbfs_set_default_user(const char *);
2N/Achar *smbfs_strerror(int);
2N/A
2N/A
2N/A/*
2N/A * Get/set ACL APIs.
2N/A * The ACL is in the form used by libsec (type=ACE_T)
2N/A * but we need to carry the uid/gid info here too.
2N/A */
2N/A/*
2N/A * Get a ZFS-style acl from an FD opened in smbfs.
2N/A * Intentionally similar to: facl_get(3SEC)
2N/A *
2N/A * Allocates an acl_t via libsec. Free with: acl_free(3SEC)
2N/A * Get owner/group IDs too if ID pointers != NULL
2N/A */
2N/Aint smbfs_acl_get(int fd, acl_t **, uid_t *, gid_t *);
2N/A
2N/A/*
2N/A * Set a ZFS-style acl onto an FD opened in smbfs.
2N/A * Intentionally similar to: facl_set(3SEC)
2N/A *
2N/A * The acl_t must be of type ACE_T (from libsec).
2N/A * Set owner/group IDs too if ID values != -1
2N/A */
2N/Aint smbfs_acl_set(int fd, acl_t *, uid_t, gid_t);
2N/A
2N/A
2N/A/*
2N/A * Slightly lower-level functions, allowing access to
2N/A * the raw Windows Security Descriptor (SD)
2N/A *
2N/A * The struct i_ntsid is opaque in this I/F.
2N/A * Real decl. in: common/smbclnt/smbfs_ntacl.h
2N/A */
2N/Astruct i_ntsd;
2N/A
2N/A/*
2N/A * Get an "internal form" SD from the FD (opened in smbfs).
2N/A * Allocates a hierarchy in isdp. Caller must free it via
2N/A * smbfs_acl_free_isd()
2N/A */
2N/Aint smbfs_acl_getsd(int fd, uint32_t, struct i_ntsd **);
2N/A
2N/A/*
2N/A * Set an "internal form" SD onto the FD (opened in smbfs).
2N/A */
2N/Aint smbfs_acl_setsd(int fd, uint32_t, struct i_ntsd *);
2N/A
2N/Astruct __FILE;
2N/Avoid smbfs_acl_print_sd(struct __FILE *, struct i_ntsd *);
2N/A
2N/A/*
2N/A * These are duplicated from common/smbclnt/smbfs_ntacl.h
2N/A * rather than exporting that header for this library.
2N/A * Any mismatch would be detected in smb/acl_api.c
2N/A */
2N/Aint smbfs_acl_sd2zfs(struct i_ntsd *, acl_t *, uid_t *, gid_t *);
2N/Aint smbfs_acl_zfs2sd(acl_t *, uid_t, gid_t, uint32_t, struct i_ntsd **);
2N/Avoid smbfs_acl_free_sd(struct i_ntsd *);
2N/A
2N/A/*
2N/A * External interface to the libsmbfs/netsmb keychain
2N/A * storage mechanism. This interface is consumed by
2N/A * the smbfs commands like login, logout etc. and by the SMBFS PAM module.
2N/A */
2N/A#define SMB_KEYCHAIN_SUCCESS 0
2N/A#define SMB_KEYCHAIN_BADPASSWD 300
2N/A#define SMB_KEYCHAIN_BADDOMAIN 301
2N/A#define SMB_KEYCHAIN_BADUSER 302
2N/A#define SMB_KEYCHAIN_NODRIVER 303
2N/A#define SMB_KEYCHAIN_UNKNOWN 304
2N/A
2N/A/* Add a password to the keychain. */
2N/Aint smbfs_keychain_add(uid_t uid, const char *domain, const char *user,
2N/A const char *password, boolean_t updatefile);
2N/A
2N/A/* Add LM-hash and NT-hash (16-bytes) to the keychain. */
2N/Aint smbfs_keychain_addhash(uid_t uid, const char *domain, const char *user,
2N/A const uchar_t *lmhash, const uchar_t *nthash);
2N/A
2N/A/* Delete a password from the keychain. */
2N/Aint smbfs_keychain_del(uid_t uid, const char *domain, const char *user,
2N/A boolean_t updatefile);
2N/A
2N/A/*
2N/A * Check for existence of a keychain entry.
2N/A * Returns 0 if it exists, else ENOENT.
2N/A */
2N/Aint smbfs_keychain_chk(const char *domain, const char *user);
2N/A
2N/A/*
2N/A * Delete all keychain entries owned by the caller.
2N/A */
2N/Aint smbfs_keychain_del_owner(boolean_t updatefile);
2N/A
2N/A/*
2N/A * Delete all keychain entries (regardless of owner).
2N/A * Requires super-user privliege.
2N/A */
2N/Aint smbfs_keychain_del_everyone(void);
2N/A
2N/A/*
2N/A * This is not really part of the keychain library,
2N/A * but is typically needed in code that wants to
2N/A * provide (editable) defaults for domain/user
2N/A *
2N/A * Get default domain and user names
2N/A * Server name is optional.
2N/A */
2N/Aint smbfs_default_dom_usr(char *dom, int maxdom, char *usr, int maxusr);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBSMBFS_H */