xref: /openbmc/linux/fs/smb/server/mgmt/user_config.h (revision 9134211f)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *   Copyright (C) 2018 Samsung Electronics Co., Ltd.
4  */
5 
6 #ifndef __USER_CONFIG_MANAGEMENT_H__
7 #define __USER_CONFIG_MANAGEMENT_H__
8 
9 #include "../glob.h"
10 
11 struct ksmbd_user {
12 	unsigned short		flags;
13 
14 	unsigned int		uid;
15 	unsigned int		gid;
16 
17 	char			*name;
18 
19 	size_t			passkey_sz;
20 	char			*passkey;
21 	unsigned int		failed_login_count;
22 };
23 
24 static inline bool user_guest(struct ksmbd_user *user)
25 {
26 	return user->flags & KSMBD_USER_FLAG_GUEST_ACCOUNT;
27 }
28 
29 static inline void set_user_flag(struct ksmbd_user *user, int flag)
30 {
31 	user->flags |= flag;
32 }
33 
34 static inline int test_user_flag(struct ksmbd_user *user, int flag)
35 {
36 	return user->flags & flag;
37 }
38 
39 static inline void set_user_guest(struct ksmbd_user *user)
40 {
41 }
42 
43 static inline char *user_passkey(struct ksmbd_user *user)
44 {
45 	return user->passkey;
46 }
47 
48 static inline char *user_name(struct ksmbd_user *user)
49 {
50 	return user->name;
51 }
52 
53 static inline unsigned int user_uid(struct ksmbd_user *user)
54 {
55 	return user->uid;
56 }
57 
58 static inline unsigned int user_gid(struct ksmbd_user *user)
59 {
60 	return user->gid;
61 }
62 
63 struct ksmbd_user *ksmbd_login_user(const char *account);
64 struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp);
65 void ksmbd_free_user(struct ksmbd_user *user);
66 int ksmbd_anonymous_user(struct ksmbd_user *user);
67 bool ksmbd_compare_user(struct ksmbd_user *u1, struct ksmbd_user *u2);
68 #endif /* __USER_CONFIG_MANAGEMENT_H__ */
69