1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
6 #include <linux/slab.h>
9 #include "user_config.h"
10 #include "../transport_ipc.h"
12 struct ksmbd_user *ksmbd_login_user(const char *account)
14 struct ksmbd_login_response *resp;
15 struct ksmbd_user *user = NULL;
17 resp = ksmbd_ipc_login_request(account);
21 if (!(resp->status & KSMBD_USER_FLAG_OK))
24 user = ksmbd_alloc_user(resp);
30 struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp)
32 struct ksmbd_user *user = NULL;
34 user = kmalloc(sizeof(struct ksmbd_user), GFP_KERNEL);
38 user->name = kstrdup(resp->account, GFP_KERNEL);
39 user->flags = resp->status;
40 user->gid = resp->gid;
41 user->uid = resp->uid;
42 user->passkey_sz = resp->hash_sz;
43 user->passkey = kmalloc(resp->hash_sz, GFP_KERNEL);
45 memcpy(user->passkey, resp->hash, resp->hash_sz);
47 if (!user->name || !user->passkey) {
56 void ksmbd_free_user(struct ksmbd_user *user)
58 ksmbd_ipc_logout_request(user->name, user->flags);
64 int ksmbd_anonymous_user(struct ksmbd_user *user)
66 if (user->name[0] == '\0')