Lines Matching defs:user

104  *      - The user is in the list of users for his session.
106 * - This user can not access anything yet.
111 * - The user is in the list of users for his session.
112 * - References will be given out if the user is looked up.
113 * - The user can access files and pipes.
118 * - The user is in the list of users for his session.
119 * - References will not be given out if the user is looked up.
120 * - The trees the user connected are being disconnected.
121 * - The resources associated with the user remain.
126 * - The user is queued in the list of users of his session.
127 * - References will not be given out if the user is looked up.
128 * - The user has no more trees connected.
129 * - The resources associated with the user remain.
134 * new user object and adds it to the list of users for
140 * assigned in T0) update the state of this user object,
146 * makes the new user object available for requests.
153 * partially constructed user.
162 * with the user are deleted as well as the user. For the transition to
163 * occur, the user must be in the SMB_USER_STATE_LOGGED_OFF state and the
169 * The state machine of the user structures is controlled by 3 elements:
174 * There's a mutex embedded in the user structure used to protect its fields
177 * To insert the user into the list of users of the session and to remove
178 * the user from it, the lock must be entered in RW_WRITER mode.
180 * Rules of access to a user structure:
185 * 2) All actions applied to a user require a reference count.
187 * 3) There are 2 ways of getting a reference count. One is when the user
188 * logs in. The other when the user is looked up.
190 * It should be noted that the reference count of a user registers the
191 * number of references to the user in other structures (such as an smb
194 * 1) The user is logged in. An user is anchored by his state. If there's
195 * no activity involving a user currently logged in, the reference
196 * count of that user is zero.
198 * 2) The user is queued in the list of users of the session. The fact of
215 * Create a new user.
220 smb_user_t *user;
225 user = kmem_cache_alloc(smb_cache_user, KM_SLEEP);
226 bzero(user, sizeof (smb_user_t));
228 user->u_refcnt = 1;
229 user->u_session = session;
230 user->u_server = session->s_server;
231 user->u_logon_time = gethrestime_sec();
233 if (smb_idpool_alloc(&session->s_uid_pool, &user->u_uid))
236 mutex_init(&user->u_mutex, NULL, MUTEX_DEFAULT, NULL);
237 user->u_state = SMB_USER_STATE_LOGGING_ON;
238 user->u_magic = SMB_USER_MAGIC;
241 smb_llist_insert_tail(&session->s_user_list, user);
245 return (user);
248 if (user->u_uid != 0)
249 smb_idpool_free(&session->s_uid_pool, user->u_uid);
250 kmem_cache_free(smb_cache_user, user);
255 * Fill in the details of a user, meaning a transition
260 smb_user_t *user,
269 ASSERT(user->u_magic == SMB_USER_MAGIC);
274 mutex_enter(&user->u_mutex);
276 if (user->u_state != SMB_USER_STATE_LOGGING_ON) {
277 mutex_exit(&user->u_mutex);
281 smb_authsock_close(user);
283 user->u_state = SMB_USER_STATE_LOGGED_ON;
284 user->u_flags = flags;
285 user->u_name_len = strlen(account_name) + 1;
286 user->u_domain_len = strlen(domain_name) + 1;
287 user->u_name = smb_mem_strdup(account_name);
288 user->u_domain = smb_mem_strdup(domain_name);
289 user->u_audit_sid = audit_sid;
291 smb_user_setcred(user, cr, privileges);
293 mutex_exit(&user->u_mutex);
301 * Change the user state and disconnect trees.
302 * The user list must not be entered or modified here.
306 smb_user_t *user)
308 ASSERT(user->u_magic == SMB_USER_MAGIC);
310 mutex_enter(&user->u_mutex);
311 ASSERT(user->u_refcnt);
312 switch (user->u_state) {
314 smb_authsock_close(user);
315 user->u_state = SMB_USER_STATE_LOGGED_OFF;
316 smb_server_dec_users(user->u_server);
322 * The user is moved into a state indicating that the log off
325 user->u_state = SMB_USER_STATE_LOGGING_OFF;
326 mutex_exit(&user->u_mutex);
327 smb_session_disconnect_owned_trees(user->u_session, user);
328 smb_user_auth_logoff(user);
329 mutex_enter(&user->u_mutex);
330 user->u_state = SMB_USER_STATE_LOGGED_OFF;
331 smb_server_dec_users(user->u_server);
342 mutex_exit(&user->u_mutex);
346 * Take a reference on a user. Do not return a reference unless the user is in
350 smb_user_hold(smb_user_t *user)
352 SMB_USER_VALID(user);
354 mutex_enter(&user->u_mutex);
356 if (user->u_state == SMB_USER_STATE_LOGGED_ON) {
357 user->u_refcnt++;
358 mutex_exit(&user->u_mutex);
362 mutex_exit(&user->u_mutex);
367 * Unconditionally take a reference on a user.
370 smb_user_hold_internal(smb_user_t *user)
372 SMB_USER_VALID(user);
374 mutex_enter(&user->u_mutex);
375 user->u_refcnt++;
376 mutex_exit(&user->u_mutex);
380 * Release a reference on a user. If the reference count falls to
381 * zero and the user has logged off, post the object for deletion.
387 smb_user_t *user)
389 ASSERT(user->u_magic == SMB_USER_MAGIC);
391 mutex_enter(&user->u_mutex);
392 ASSERT(user->u_refcnt);
393 user->u_refcnt--;
395 switch (user->u_state) {
397 if (user->u_refcnt == 0)
398 smb_session_post_user(user->u_session, user);
410 mutex_exit(&user->u_mutex);
414 * Determine whether or not the user is an administrator.
418 smb_user_is_admin(smb_user_t *user)
429 ASSERT(user);
430 ASSERT(user->u_cred);
432 if (SMB_USER_IS_ADMIN(user))
441 ksidlist = crgetsidlist(user->u_cred);
447 ksid2 = crgetsid(user->u_cred, KSID_USER);
455 user->u_flags |= SMB_USER_FLAG_ADMIN;
469 * This function should be called with a hold on the user.
472 smb_user_namecmp(smb_user_t *user, const char *name)
477 if (smb_strcasecmp(name, user->u_name, 0) == 0)
483 user->u_domain, user->u_name);
488 user->u_name, user->u_domain);
498 * If the enumeration request is for user data, handle the request
501 * This function should be called with a hold on the user.
504 smb_user_enum(smb_user_t *user, smb_svcenum_t *svcenum)
508 ASSERT(user);
509 ASSERT(user->u_magic == SMB_USER_MAGIC);
512 return (smb_user_enum_private(user, svcenum));
520 * Delete a user. The tree list should be empty.
522 * Remove the user from the session's user list before freeing resources
523 * associated with the user.
529 smb_user_t *user = (smb_user_t *)arg;
531 SMB_USER_VALID(user);
532 ASSERT(user->u_refcnt == 0);
533 ASSERT(user->u_state == SMB_USER_STATE_LOGGED_OFF);
534 ASSERT(user->u_authsock == NULL);
536 session = user->u_session;
538 smb_llist_remove(&session->s_user_list, user);
539 smb_idpool_free(&session->s_uid_pool, user->u_uid);
542 mutex_enter(&user->u_mutex);
543 mutex_exit(&user->u_mutex);
545 user->u_magic = (uint32_t)~SMB_USER_MAGIC;
546 mutex_destroy(&user->u_mutex);
547 if (user->u_cred)
548 crfree(user->u_cred);
549 if (user->u_privcred)
550 crfree(user->u_privcred);
551 smb_mem_free(user->u_name);
552 smb_mem_free(user->u_domain);
553 kmem_cache_free(smb_cache_user, user);
557 smb_user_getcred(smb_user_t *user)
559 return (user->u_cred);
563 smb_user_getprivcred(smb_user_t *user)
565 return ((user->u_privcred)? user->u_privcred : user->u_cred);
570 * Assign the user cred and privileges.
572 * If the user has backup and/or restore privleges, dup the cred
576 smb_user_setcred(smb_user_t *user, cred_t *cr, uint32_t privileges)
601 user->u_cred = cr;
602 user->u_privcred = privcred;
603 user->u_privileges = privileges;
611 smb_user_enum_private(smb_user_t *user, smb_svcenum_t *svcenum)
628 rc = smb_user_netinfo_encode(user, pb, svcenum->se_bavail, &nbytes);
639 * Encode the NetInfo for a user into a buffer. NetInfo contains
640 * information that is often needed in user space to support RPC
644 smb_user_netinfo_encode(smb_user_t *user, uint8_t *buf, size_t buflen,
650 smb_user_netinfo_init(user, &info);
658 smb_user_netinfo_init(smb_user_t *user, smb_netuserinfo_t *info)
663 ASSERT(user);
664 ASSERT(user->u_domain);
665 ASSERT(user->u_name);
667 session = user->u_session;
675 info->ui_smb_uid = user->u_uid;
676 info->ui_logon_time = user->u_logon_time;
677 info->ui_flags = user->u_flags;
678 info->ui_posix_uid = crgetuid(user->u_cred);
680 info->ui_domain_len = user->u_domain_len;
681 info->ui_domain = smb_mem_strdup(user->u_domain);
683 info->ui_account_len = user->u_name_len;
684 info->ui_account = smb_mem_strdup(user->u_name);
710 smb_user_auth_logoff(smb_user_t *user)
712 uint32_t audit_sid = user->u_audit_sid;
714 (void) smb_kdoor_upcall(user->u_server, SMB_DR_USER_AUTH_LOGOFF,