xref: /illumos-gate/usr/src/lib/libsmbfs/netsmb/smb_keychain.h (revision 4bff34e37def8a90f9194d81bc345c52ba20086a)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SMB_KEYCHAIN_H
28 #define	_SMB_KEYCHAIN_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * External interface to the libsmbfs/netsmb keychain
34  * storage mechanism.  This interface is consumed by
35  * the "smbutil" commands: login, logout, ...
36  * and by the SMBFS PAM module.
37  */
38 
39 #define	SMB_KEYCHAIN_SUCCESS	0
40 #define	SMB_KEYCHAIN_BADPASSWD	300
41 #define	SMB_KEYCHAIN_BADDOMAIN	301
42 #define	SMB_KEYCHAIN_BADUSER	302
43 #define	SMB_KEYCHAIN_NODRIVER	303
44 #define	SMB_KEYCHAIN_UNKNOWN	304
45 
46 /* Add a password to the keychain. */
47 int smbfs_keychain_add(uid_t uid, const char *domain, const char *user,
48 	const char *password);
49 
50 /* Delete a password from the keychain. */
51 int smbfs_keychain_del(uid_t uid, const char *domain, const char *user);
52 
53 /*
54  * Check for existence of a keychain entry.
55  * Returns 0 if it exists, else ENOENT.
56  */
57 int smbfs_keychain_chk(const char *domain, const char *user);
58 
59 /*
60  * Delete all keychain entries owned by the caller.
61  */
62 int smbfs_keychain_del_owner(void);
63 
64 /*
65  * Delete all keychain entries (regardless of owner).
66  * Requires super-user privliege.
67  */
68 int smbfs_keychain_del_everyone(void);
69 
70 /*
71  * This is not really part of the keychain library,
72  * but is typically needed in code that wants to
73  * provide (editable) defaults for domain/user
74  *
75  * Get default domain and user names
76  * Server name is optional.
77  */
78 int
79 smbfs_default_dom_usr(const char *home, const char *server,
80 	char *dom, int maxdom, char *usr, int maxusr);
81 
82 #endif /* _SMB_KEYCHAIN_H */
83