1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef COMPAT_PWD_H
18 #define COMPAT_PWD_H
19 
20 #include <pwd.h>
21 
22 #include <sys/cdefs.h>
23 
24 __BEGIN_DECLS
25 
26 static struct passwd PASSWORD = {
27   .pw_name = (char *)"android",
28   .pw_uid = 1,
29   .pw_gid = 1,
30   .pw_passwd = (char *)"",
31   .pw_dir = (char *)"/",
32   .pw_gecos = NULL,
33   .pw_shell = (char *)"/bin/bash",
34 };
35 
getpwnam_r(const char * name __UNUSED,struct passwd * pwd __UNUSED,char * buf __UNUSED,size_t buflen __UNUSED,struct passwd ** result)36 int getpwnam_r(const char *name __UNUSED, struct passwd *pwd __UNUSED,
37                char *buf __UNUSED, size_t buflen __UNUSED, struct passwd **result) {
38   *result = &PASSWORD;
39   return 0;
40 }
41 
getpwuid_r(uid_t uid __UNUSED,passwd * pwd __UNUSED,char * buf __UNUSED,size_t byte_count __UNUSED,struct passwd ** result)42 int getpwuid_r(uid_t uid __UNUSED, passwd* pwd __UNUSED, char *buf __UNUSED,
43                size_t byte_count __UNUSED, struct passwd** result) {
44   *result = &PASSWORD;
45   return 0;
46 }
47 
48 __END_DECLS
49 
50 #endif  // COMPAT_PWD_H
51