summaryrefslogtreecommitdiffstats
path: root/loader/pwd-stub.c
blob: 43da508f7c751a012e43e8375b9abf35d4632120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <sys/types.h>
#include <errno.h>
#include <pwd.h>
#include <string.h>

static struct passwd pw_root = {
  pw_name: "root",
  pw_passwd: "",
  pw_uid: 0,
  pw_gid: 0,
  pw_gecos: "root",
  pw_dir: "/",
  pw_shell: "/bin/bash"
};

struct passwd *getpwuid(uid_t u)
{
  if (u) return NULL;
  return &pw_root;
}

int __getpwnam_r(const char *name, struct passwd *result_buf, char *buf,
		 size_t buflen, struct passwd **result)
{
  if (strcmp (name, "root")) {
    errno = 0;
    *result = NULL;
    return -1;
  }
  memcpy(result_buf, &pw_root, sizeof(struct passwd));
  *result = result_buf;
  return 0;
}