14bff34ethurlow/*
24bff34ethurlow * CDDL HEADER START
34bff34ethurlow *
44bff34ethurlow * The contents of this file are subject to the terms of the
54bff34ethurlow * Common Development and Distribution License (the "License").
64bff34ethurlow * You may not use this file except in compliance with the License.
74bff34ethurlow *
84bff34ethurlow * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
94bff34ethurlow * or http://www.opensolaris.org/os/licensing.
104bff34ethurlow * See the License for the specific language governing permissions
114bff34ethurlow * and limitations under the License.
124bff34ethurlow *
134bff34ethurlow * When distributing Covered Code, include this CDDL HEADER in each
144bff34ethurlow * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
154bff34ethurlow * If applicable, add the following below this CDDL HEADER, with the
164bff34ethurlow * fields enclosed by brackets "[]" replaced with your own identifying
174bff34ethurlow * information: Portions Copyright [yyyy] [name of copyright owner]
184bff34ethurlow *
194bff34ethurlow * CDDL HEADER END
204bff34ethurlow */
214bff34ethurlow
224bff34ethurlow/*
23430b4c4Gordon Ross * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
244bff34ethurlow * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
254bff34ethurlow * Use is subject to license terms.
264bff34ethurlow */
274bff34ethurlow
284bff34ethurlow#ifndef _SMB_KEYCHAIN_H
294bff34ethurlow#define	_SMB_KEYCHAIN_H
304bff34ethurlow
314bff34ethurlow/*
324bff34ethurlow * External interface to the libsmbfs/netsmb keychain
334bff34ethurlow * storage mechanism.  This interface is consumed by
344bff34ethurlow * the "smbutil" commands: login, logout, ...
354bff34ethurlow * and by the SMBFS PAM module.
364bff34ethurlow */
374bff34ethurlow
38430b4c4Gordon Ross#ifdef __cplusplus
39430b4c4Gordon Rossextern "C" {
40430b4c4Gordon Ross#endif
41430b4c4Gordon Ross
424bff34ethurlow#define	SMB_KEYCHAIN_SUCCESS	0
434bff34ethurlow#define	SMB_KEYCHAIN_BADPASSWD	300
444bff34ethurlow#define	SMB_KEYCHAIN_BADDOMAIN	301
454bff34ethurlow#define	SMB_KEYCHAIN_BADUSER	302
464bff34ethurlow#define	SMB_KEYCHAIN_NODRIVER	303
474bff34ethurlow#define	SMB_KEYCHAIN_UNKNOWN	304
484bff34ethurlow
494bff34ethurlow/* Add a password to the keychain. */
504bff34ethurlowint smbfs_keychain_add(uid_t uid, const char *domain, const char *user,
514bff34ethurlow	const char *password);
524bff34ethurlow
53430b4c4Gordon Ross/* Add an NT-hash (16-bytes) to the keychain. */
54430b4c4Gordon Rossint smbfs_keychain_addhash(uid_t uid, const char *domain, const char *user,
55430b4c4Gordon Ross	const uchar_t *nthash);
56430b4c4Gordon Ross
574bff34ethurlow/* Delete a password from the keychain. */
584bff34ethurlowint smbfs_keychain_del(uid_t uid, const char *domain, const char *user);
594bff34ethurlow
604bff34ethurlow/*
614bff34ethurlow * Check for existence of a keychain entry.
624bff34ethurlow * Returns 0 if it exists, else ENOENT.
634bff34ethurlow */
644bff34ethurlowint smbfs_keychain_chk(const char *domain, const char *user);
654bff34ethurlow
664bff34ethurlow/*
674bff34ethurlow * Delete all keychain entries owned by the caller.
684bff34ethurlow */
694bff34ethurlowint smbfs_keychain_del_owner(void);
704bff34ethurlow
714bff34ethurlow/*
724bff34ethurlow * Delete all keychain entries (regardless of owner).
734bff34ethurlow * Requires super-user privliege.
744bff34ethurlow */
754bff34ethurlowint smbfs_keychain_del_everyone(void);
764bff34ethurlow
774bff34ethurlow/*
784bff34ethurlow * This is not really part of the keychain library,
794bff34ethurlow * but is typically needed in code that wants to
804bff34ethurlow * provide (editable) defaults for domain/user
814bff34ethurlow *
824bff34ethurlow * Get default domain and user names
834bff34ethurlow * Server name is optional.
844bff34ethurlow */
854bff34ethurlowint
864bff34ethurlowsmbfs_default_dom_usr(const char *home, const char *server,
874bff34ethurlow	char *dom, int maxdom, char *usr, int maxusr);
884bff34ethurlow
89430b4c4Gordon Ross#ifdef __cplusplus
90430b4c4Gordon Ross}
91430b4c4Gordon Ross#endif
92430b4c4Gordon Ross
934bff34ethurlow#endif /* _SMB_KEYCHAIN_H */
94