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