da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
96a62ada8aa6cb19b04270da282e7e21ba74b808joyce mcintosh * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States#include <syslog.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef enum {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic pid_t lck_pid = 0; /* process's pid at last lock */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic thread_t lck_tid = 0; /* thread that holds the lock */
7b59d02d2a384be9a08087b14defadd214b3c1ddjbstatic struct {
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego smb_passwd_t *(*pwop_getpwnam)(const char *, smb_passwd_t *);
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego smb_passwd_t *(*pwop_getpwuid)(uid_t, smb_passwd_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic int smb_pwd_lock(void);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic int smb_pwd_unlock(void);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic int smb_pwd_flck(void);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic int smb_pwd_fulck(void);
3db3f65c6274eb042354801a308c8e9bc4994553amw * buffer structure used by smb_pwd_fgetent/smb_pwd_fputent
3db3f65c6274eb042354801a308c8e9bc4994553amw * flag values used with smb_pwd_fgetent
3db3f65c6274eb042354801a308c8e9bc4994553amw#define SMB_PWD_GETF_ALL 1 /* get all the account info */
3db3f65c6274eb042354801a308c8e9bc4994553amw#define SMB_PWD_GETF_NOPWD 2 /* password is not needed */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic smb_pwbuf_t *smb_pwd_fgetent(FILE *, smb_pwbuf_t *, uint32_t);
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wrightstatic int smb_pwd_fputent(FILE *, const smb_pwbuf_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic int smb_pwd_chgpwent(smb_passwd_t *, const char *, int);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic int smb_pwd_update(const char *, const char *, int);
3db3f65c6274eb042354801a308c8e9bc4994553amw * Local Users Cache
3db3f65c6274eb042354801a308c8e9bc4994553amw * Simplifying assumptions
3db3f65c6274eb042354801a308c8e9bc4994553amw * o smbpasswd is a service private file and shouldn't be edited manually
3db3f65c6274eb042354801a308c8e9bc4994553amw * o accounts are only added/modified via passwd and/or smbadm CLIs
3db3f65c6274eb042354801a308c8e9bc4994553amw * o accounts are not removed but disabled using smbadm CLI
3db3f65c6274eb042354801a308c8e9bc4994553amw * o editing smbpasswd manually might result in cache inconsistency
3db3f65c6274eb042354801a308c8e9bc4994553amw * Cache is created and populated upon service startup.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Cache is updated each time users list is requested if there's been
3db3f65c6274eb042354801a308c8e9bc4994553amw * any change in smbpasswd file. The change criteria is smbpasswd's
3db3f65c6274eb042354801a308c8e9bc4994553amw * modification timestamp.
3db3f65c6274eb042354801a308c8e9bc4994553amw * User cache handle
3db3f65c6274eb042354801a308c8e9bc4994553amw * User cache node
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void smb_lucache_create(void);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void smb_lucache_destroy(void);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void smb_lucache_update(void);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int smb_lucache_num(void);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int smb_lucache_lock(void);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void smb_lucache_unlock(void);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int smb_lucache_do_update(void);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void smb_lucache_flush(void);
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_init
3db3f65c6274eb042354801a308c8e9bc4994553amw * Initializes the cache if requested.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Checks to see if a password management utility library
3db3f65c6274eb042354801a308c8e9bc4994553amw * is interposed. If yes then it'll initializes smb_pwd_ops
3db3f65c6274eb042354801a308c8e9bc4994553amw * structure with function pointers from this library.
fe1c642d06e14b412cd83ae2179303186ab08972Bill Krier * This pre-loading of the cache results in idmapd requests.
fe1c642d06e14b412cd83ae2179303186ab08972Bill Krier * With the change to allow idmapd to call into libsmb to
fe1c642d06e14b412cd83ae2179303186ab08972Bill Krier * map names and SIDs, this creates a circular startup
fe1c642d06e14b412cd83ae2179303186ab08972Bill Krier * dependency. This call has been temporarily disabled to
fe1c642d06e14b412cd83ae2179303186ab08972Bill Krier * avoid this issue. It can be enabled when the name/SID
fe1c642d06e14b412cd83ae2179303186ab08972Bill Krier * lookup can be done directly on the LSA service.
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego (smb_passwd_t *(*)())dlsym(smb_pwd_hdl, "smb_pwd_getpwnam");
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego (smb_passwd_t *(*)())dlsym(smb_pwd_hdl, "smb_pwd_getpwuid");
3db3f65c6274eb042354801a308c8e9bc4994553amw (smb_luser_t *(*)())dlsym(smb_pwd_hdl, "smb_pwd_iterate");
7b59d02d2a384be9a08087b14defadd214b3c1ddjb /* If error or function(s) are missing, use original lib */
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_fini
3db3f65c6274eb042354801a308c8e9bc4994553amw * Destroys the cache.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Closes interposed library.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown bzero((void *)&smb_pwd_ops, sizeof (smb_pwd_ops));
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * smb_pwd_getpwnam
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Returns a smb password structure for the given user name.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smbpw is a pointer to a buffer allocated by the caller.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Returns NULL upon failure.
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregosmb_pwd_getpwnam(const char *name, smb_passwd_t *smbpw)
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego return (smb_pwd_ops.pwop_getpwnam(name, smbpw));
12b65585e720714b31036daaa2b30eb76014048eGordon Ross syslog(LOG_WARNING, "smb_pwdutil: lock failed, err=%d", err);
12b65585e720714b31036daaa2b30eb76014048eGordon Ross syslog(LOG_WARNING, "smb_pwdutil: open failed, %m");
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego while (smb_pwd_fgetent(fp, &pwbuf, SMB_PWD_GETF_ALL) != NULL) {
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * smb_pwd_getpwuid
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * Returns a smb password structure for the given UID
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * smbpw is a pointer to a buffer allocated by the caller.
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego * Returns NULL upon failure.
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borregosmb_pwd_getpwuid(uid_t uid, smb_passwd_t *smbpw)
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego return (smb_pwd_ops.pwop_getpwuid(uid, smbpw));
12b65585e720714b31036daaa2b30eb76014048eGordon Ross syslog(LOG_WARNING, "smb_pwdutil: lock failed, err=%d", err);
12b65585e720714b31036daaa2b30eb76014048eGordon Ross syslog(LOG_WARNING, "smb_pwdutil: open failed, %m");
3db3f65c6274eb042354801a308c8e9bc4994553amw while (smb_pwd_fgetent(fp, &pwbuf, SMB_PWD_GETF_ALL) != NULL) {
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_setpasswd
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Update/add the given user to the smbpasswd file.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_pwd_setpasswd(const char *name, const char *password)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_pwd_setcntl
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Change the account state. This can be making the account
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * disable/enable or removing its LM hash.
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_num
3db3f65c6274eb042354801a308c8e9bc4994553amw * Returns the number of cached local users
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_iteropen
3db3f65c6274eb042354801a308c8e9bc4994553amw * Initalizes the given iterator handle.
3db3f65c6274eb042354801a308c8e9bc4994553amw * This handle will be used to iterate the users cache
3db3f65c6274eb042354801a308c8e9bc4994553amw * by the caller. The cache will be locked for read and it
3db3f65c6274eb042354801a308c8e9bc4994553amw * will remain locked until smb_pwd_iterclose() is called.
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_iterate
3db3f65c6274eb042354801a308c8e9bc4994553amw * Scans through users cache using the given iterator
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_iterclose
3db3f65c6274eb042354801a308c8e9bc4994553amw * Closes the given iterator. Effectively it only unlocks the cache
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_update
3db3f65c6274eb042354801a308c8e9bc4994553amw * Updates the password entry of the given user if the user already
3db3f65c6274eb042354801a308c8e9bc4994553amw * has an entry, otherwise it'll add an entry for the user with
3db3f65c6274eb042354801a308c8e9bc4994553amw * given password and control information.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_pwd_update(const char *name, const char *password, int control)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((tempfd = open(SMB_PASSTEMP, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as if (smb_config_getnum(SMB_CI_LM_LEVEL, &lm_level) != SMBD_SMF_OK)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * copy old password entries to temporary file while replacing
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the entry that matches "name"
3db3f65c6274eb042354801a308c8e9bc4994553amw while (smb_pwd_fgetent(src, &pwbuf, SMB_PWD_GETF_ALL) != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Rename temp to passwd */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (unlink(SMB_OPASSWD) && access(SMB_OPASSWD, 0) == 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_fgetent
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Parse the buffer in the passed pwbuf and fill in the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb password structure to point to the parsed information.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The entry format is:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * <user-name>:<user-id>:<LM hash>:<NTLM hash>
3db3f65c6274eb042354801a308c8e9bc4994553amw * Returns a pointer to the passed pwbuf structure on success,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * otherwise returns NULL.
3db3f65c6274eb042354801a308c8e9bc4994553amwsmb_pwd_fgetent(FILE *fp, smb_pwbuf_t *pwbuf, uint32_t flags)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (i = 0; i < SMB_PWD_NARG; ++i) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((*argv[SMB_PWD_NAME] == '\0') || (*argv[SMB_PWD_UID] == '\0'))
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego (void) strlcpy(pw->pw_name, argv[SMB_PWD_NAME], sizeof (pw->pw_name));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (strcmp(argv[SMB_PWD_LMHASH], SMB_PWD_DISABLE) == 0) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) hextobin(argv[SMB_PWD_LMHASH], SMBAUTH_HEXHASH_SZ,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else if (lm_len != 0) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) hextobin(argv[SMB_PWD_NTHASH], SMBAUTH_HEXHASH_SZ,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else if (nt_len != 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_chgpwent
3db3f65c6274eb042354801a308c8e9bc4994553amw * Updates the given smb_passwd_t structure with given password and
3db3f65c6274eb042354801a308c8e9bc4994553amw * control information.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_pwd_chgpwent(smb_passwd_t *smbpw, const char *password, int control)
3db3f65c6274eb042354801a308c8e9bc4994553amw /* disable the user */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) strcpy((char *)smbpw->pw_lmhash, SMB_PWD_DISABLE);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) strcpy((char *)smbpw->pw_nthash, SMB_PWD_DISABLE);
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((control & SMB_PWC_ENABLE) && (smbpw->pw_flags & SMB_PWF_DISABLE)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw /* enable the user if it's been disabled */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* No password update if account is disabled */
3db3f65c6274eb042354801a308c8e9bc4994553amw /* This call was just to update the control flags */
3db3f65c6274eb042354801a308c8e9bc4994553amw /* LM hash should not be present */
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright (void) smb_auth_lm_hash(password, smbpw->pw_lmhash);
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright (void) smb_auth_ntlm_hash(password, smbpw->pw_nthash);
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_fputent
3db3f65c6274eb042354801a308c8e9bc4994553amw * If LM/NTLM hash are present, converts them to hex string
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and write them along with user's name and Id to the smbpasswd
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wrightsmb_pwd_fputent(FILE *fp, const smb_pwbuf_t *pwbuf)
89dc44ce9705974a8bc4a39f1e878a0491a5be61jose borrego rc = fprintf(fp, "%s:%u:%s:%s\n", pw->pw_name, pw->pw_uid,
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_lock
3db3f65c6274eb042354801a308c8e9bc4994553amw * A wrapper around smb_pwd_flck() which locks smb password
3db3f65c6274eb042354801a308c8e9bc4994553amw * file so that only one thread at a time is operational.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (errno) {
96a62ada8aa6cb19b04270da282e7e21ba74b808joyce mcintosh * smb_pwd_unlock
3db3f65c6274eb042354801a308c8e9bc4994553amw * A wrapper around smb_pwd_fulck() which unlocks
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb password file.
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_flck
3db3f65c6274eb042354801a308c8e9bc4994553amw * Creates a lock file and grabs an exclusive (write) lock on it.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (;;) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* somebody forked */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (lck_tid == 0) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * For compatibility with the past, pretend
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * that we were interrupted by SIGALRM.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (-1);
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_fulck
3db3f65c6274eb042354801a308c8e9bc4994553amw * Unlocks smb password file for operations done via
3db3f65c6274eb042354801a308c8e9bc4994553amw * this library APIs.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return (-1);
3db3f65c6274eb042354801a308c8e9bc4994553amw * Local User Cache Functions
3db3f65c6274eb042354801a308c8e9bc4994553amw * Local user cache is implemented using AVL tree
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_cmp
3db3f65c6274eb042354801a308c8e9bc4994553amw * AVL compare function, the key is username.
3db3f65c6274eb042354801a308c8e9bc4994553amw return (-1);
3db3f65c6274eb042354801a308c8e9bc4994553amw return (1);
3db3f65c6274eb042354801a308c8e9bc4994553amw return (0);
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_update
3db3f65c6274eb042354801a308c8e9bc4994553amw * Updates the cache if needed. Whether an update is needed
3db3f65c6274eb042354801a308c8e9bc4994553amw * is determined based on smbpasswd file modification timestamp
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw /* Want only one thread executing this function at a time */
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_pwd_lock() is not called here so it can
3db3f65c6274eb042354801a308c8e9bc4994553amw * be checked quickly whether an updated is needed
3db3f65c6274eb042354801a308c8e9bc4994553amw /* no smbpasswd file; empty the cache */
3db3f65c6274eb042354801a308c8e9bc4994553amw /* empty smbpasswd file; empty the cache */
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((smb_uch.uc_timestamp.tv_sec == stbuf.st_mtim.tv_sec) &&
3db3f65c6274eb042354801a308c8e9bc4994553amw (smb_uch.uc_timestamp.tv_nsec == stbuf.st_mtim.tv_nsec)) {
3db3f65c6274eb042354801a308c8e9bc4994553amw /* No changes since the last cache update */
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((rc == SMB_PWE_SUCCESS) && (stat64(SMB_PASSWD, &stbuf) == 0))
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_do_update
3db3f65c6274eb042354801a308c8e9bc4994553amw * This function takes care of updating the AVL tree.
3db3f65c6274eb042354801a308c8e9bc4994553amw * If an entry has been updated, it'll be modified in place.
3db3f65c6274eb042354801a308c8e9bc4994553amw * New entries will be added to a temporary AVL tree then
3db3f65c6274eb042354801a308c8e9bc4994553amw * passwod file is unlocked and all the new entries will
3db3f65c6274eb042354801a308c8e9bc4994553amw * be transferred to the main cache from the temporary tree.
3db3f65c6274eb042354801a308c8e9bc4994553amw * This function MUST NOT be called directly
12b65585e720714b31036daaa2b30eb76014048eGordon Ross syslog(LOG_WARNING, "smb_pwdutil: lock failed, err=%d", rc);
12b65585e720714b31036daaa2b30eb76014048eGordon Ross syslog(LOG_WARNING, "smb_pwdutil: open failed, %m");
3db3f65c6274eb042354801a308c8e9bc4994553amw sizeof (smb_ucnode_t), offsetof(smb_ucnode_t, cn_link));
3db3f65c6274eb042354801a308c8e9bc4994553amw while (smb_pwd_fgetent(fp, &pwbuf, SMB_PWD_GETF_NOPWD) != NULL) {
3db3f65c6274eb042354801a308c8e9bc4994553amw uc_newnode = avl_find(&smb_uch.uc_cache, &uc_node, NULL);
3db3f65c6274eb042354801a308c8e9bc4994553amw /* update the node info */
3db3f65c6274eb042354801a308c8e9bc4994553amw /* create a new node */
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((uc_newnode = malloc(sizeof (smb_ucnode_t))) == NULL) {
3db3f65c6274eb042354801a308c8e9bc4994553amw idm_stat = smb_idmap_getsid(smbpw.pw_uid, SMB_IDMAP_USER, &sid);
3db3f65c6274eb042354801a308c8e9bc4994553amw /* Destroy the temporary list */
3db3f65c6274eb042354801a308c8e9bc4994553amw while ((uc_newnode = avl_destroy_nodes(&tmp_cache, &cookie)) != NULL) {
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_create
3db3f65c6274eb042354801a308c8e9bc4994553amw * Creates the AVL tree and initializes the global user cache handle.
3db3f65c6274eb042354801a308c8e9bc4994553amw * This function doesn't populate the cache.
3db3f65c6274eb042354801a308c8e9bc4994553amw * User cache is only created by smbd at startup
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw sizeof (smb_ucnode_t), offsetof(smb_ucnode_t, cn_link));
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_flush
3db3f65c6274eb042354801a308c8e9bc4994553amw * Removes and frees all the cache entries
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw while ((ucnode = avl_destroy_nodes(&smb_uch.uc_cache, &cookie))
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_destroy
3db3f65c6274eb042354801a308c8e9bc4994553amw * Destroys the cache.
3db3f65c6274eb042354801a308c8e9bc4994553amw * This function is only called in smb_pwd_fini()
3db3f65c6274eb042354801a308c8e9bc4994553amw * User cache is only destroyed by smbd upon shutdown
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_lock
3db3f65c6274eb042354801a308c8e9bc4994553amw * Locks the user cache for reading and also
3db3f65c6274eb042354801a308c8e9bc4994553amw * increment the handle reference count.
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_unlock
3db3f65c6274eb042354801a308c8e9bc4994553amw * Unlock the cache
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw * smb_lucache_num
3db3f65c6274eb042354801a308c8e9bc4994553amw * Returns the number of cache entries
3db3f65c6274eb042354801a308c8e9bc4994553amw return (0);
3db3f65c6274eb042354801a308c8e9bc4994553amw return (0);