xref: /titanic_50/usr/src/lib/libsmbfs/netsmb/smb_keychain.h (revision 5e53ed34920bc03b619b50f459f2475e7bf80b6f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
24  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef _SMB_KEYCHAIN_H
29 #define	_SMB_KEYCHAIN_H
30 
31 /*
32  * External interface to the libsmbfs/netsmb keychain
33  * storage mechanism.  This interface is consumed by
34  * the "smbutil" commands: login, logout, ...
35  * and by the SMBFS PAM module.
36  */
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define	SMB_KEYCHAIN_SUCCESS	0
43 #define	SMB_KEYCHAIN_BADPASSWD	300
44 #define	SMB_KEYCHAIN_BADDOMAIN	301
45 #define	SMB_KEYCHAIN_BADUSER	302
46 #define	SMB_KEYCHAIN_NODRIVER	303
47 #define	SMB_KEYCHAIN_UNKNOWN	304
48 
49 /* Add a password to the keychain. */
50 int smbfs_keychain_add(uid_t uid, const char *domain, const char *user,
51 	const char *password);
52 
53 /* Add an NT-hash (16-bytes) to the keychain. */
54 int smbfs_keychain_addhash(uid_t uid, const char *domain, const char *user,
55 	const uchar_t *nthash);
56 
57 /* Delete a password from the keychain. */
58 int smbfs_keychain_del(uid_t uid, const char *domain, const char *user);
59 
60 /*
61  * Check for existence of a keychain entry.
62  * Returns 0 if it exists, else ENOENT.
63  */
64 int smbfs_keychain_chk(const char *domain, const char *user);
65 
66 /*
67  * Delete all keychain entries owned by the caller.
68  */
69 int smbfs_keychain_del_owner(void);
70 
71 /*
72  * Delete all keychain entries (regardless of owner).
73  * Requires super-user privliege.
74  */
75 int smbfs_keychain_del_everyone(void);
76 
77 /*
78  * This is not really part of the keychain library,
79  * but is typically needed in code that wants to
80  * provide (editable) defaults for domain/user
81  *
82  * Get default domain and user names
83  * Server name is optional.
84  */
85 int
86 smbfs_default_dom_usr(const char *home, const char *server,
87 	char *dom, int maxdom, char *usr, int maxusr);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif /* _SMB_KEYCHAIN_H */
94