xref: /openbmc/linux/fs/smb/server/mgmt/user_config.h (revision 7f1005dd)
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 };
22 
23 static inline bool user_guest(struct ksmbd_user *user)
24 {
25 	return user->flags & KSMBD_USER_FLAG_GUEST_ACCOUNT;
26 }
27 
28 static inline void set_user_flag(struct ksmbd_user *user, int flag)
29 {
30 	user->flags |= flag;
31 }
32 
33 static inline int test_user_flag(struct ksmbd_user *user, int flag)
34 {
35 	return user->flags & flag;
36 }
37 
38 static inline void set_user_guest(struct ksmbd_user *user)
39 {
40 }
41 
42 static inline char *user_passkey(struct ksmbd_user *user)
43 {
44 	return user->passkey;
45 }
46 
47 static inline char *user_name(struct ksmbd_user *user)
48 {
49 	return user->name;
50 }
51 
52 static inline unsigned int user_uid(struct ksmbd_user *user)
53 {
54 	return user->uid;
55 }
56 
57 static inline unsigned int user_gid(struct ksmbd_user *user)
58 {
59 	return user->gid;
60 }
61 
62 struct ksmbd_user *ksmbd_login_user(const char *account);
63 struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp);
64 void ksmbd_free_user(struct ksmbd_user *user);
65 int ksmbd_anonymous_user(struct ksmbd_user *user);
66 bool ksmbd_compare_user(struct ksmbd_user *u1, struct ksmbd_user *u2);
67 #endif /* __USER_CONFIG_MANAGEMENT_H__ */
68