aboutsummaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-08-23 14:22:36 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-08-23 14:22:36 -0700
commit5d014653fd5ebc87eb6cdaf638cf1a5fc713cd1e (patch)
tree5f9c4c44dd840af7b9fff4bcb2efa2ef94e298c4 /usr
parentc8fc5a2059910d095371860c45fb8658600f430e (diff)
downloadlinux-2.6-klibc-5d014653fd5ebc87eb6cdaf638cf1a5fc713cd1e.tar.gz
[klibc] Add dummy userdb functions to keep udev happy
Add dummy userdb functions which only know about root. In the future we might want to replace these with real files which mmap() the password file. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/include/grp.h7
-rw-r--r--usr/include/pwd.h19
-rw-r--r--usr/klibc/Kbuild4
-rw-r--r--usr/klibc/userdb/getgrgid.c16
-rw-r--r--usr/klibc/userdb/getgrnam.c16
-rw-r--r--usr/klibc/userdb/getpwnam.c17
-rw-r--r--usr/klibc/userdb/getpwuid.c17
-rw-r--r--usr/klibc/userdb/root_group.c12
-rw-r--r--usr/klibc/userdb/root_user.c17
-rw-r--r--usr/klibc/userdb/userdb.h19
10 files changed, 143 insertions, 1 deletions
diff --git a/usr/include/grp.h b/usr/include/grp.h
index 19b1828c406c04..88bf79e8310a4a 100644
--- a/usr/include/grp.h
+++ b/usr/include/grp.h
@@ -8,6 +8,13 @@
#include <klibc/extern.h>
#include <sys/types.h>
+struct group {
+ char *gr_name;
+ char *gr_passwd;
+ gid_t gr_gid;
+ char **gr_mem;
+};
+
__extern int setgroups(size_t, const gid_t *);
#endif /* _GRP_H */
diff --git a/usr/include/pwd.h b/usr/include/pwd.h
new file mode 100644
index 00000000000000..aeddbfbe8a358f
--- /dev/null
+++ b/usr/include/pwd.h
@@ -0,0 +1,19 @@
+#ifndef _PWD_H
+#define _PWD_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+
+struct passwd {
+ char *pw_name;
+ char *pw_passwd;
+ uid_t pw_uid;
+ gid_t pw_gid;
+ char *pw_gecos;
+ char *pw_dir;
+ char *pw_shell;
+};
+
+__extern struct passwd *getpwnam(const char *name);
+
+#endif /* _PWD_H */
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 65ca2e44d51886..b47d6e3fa1c39c 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -52,7 +52,9 @@ klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \
ctype/isblank.o ctype/iscntrl.o ctype/isdigit.o \
ctype/isgraph.o ctype/islower.o ctype/isprint.o \
ctype/ispunct.o ctype/isspace.o ctype/isupper.o \
- ctype/isxdigit.o ctype/tolower.o ctype/toupper.o
+ ctype/isxdigit.o ctype/tolower.o ctype/toupper.o \
+ userdb/getgrgid.o userdb/getgrnam.o userdb/getpwnam.o \
+ userdb/getpwuid.o userdb/root_group.o userdb/root_user.o
klib-$(CONFIG_KLIBC_ERRLIST) += errlist.o
diff --git a/usr/klibc/userdb/getgrgid.c b/usr/klibc/userdb/getgrgid.c
new file mode 100644
index 00000000000000..5e13a47ab3fc34
--- /dev/null
+++ b/usr/klibc/userdb/getgrgid.c
@@ -0,0 +1,16 @@
+/*
+ * getgrgid.c
+ *
+ * Dummy getgrgid() to support udev
+ */
+
+#include "userdb.h"
+
+struct group *getgrgid(gid_t gid)
+{
+ if (!gid)
+ return (struct group *)&__root_group;
+
+ errno = ENOENT;
+ return NULL;
+}
diff --git a/usr/klibc/userdb/getgrnam.c b/usr/klibc/userdb/getgrnam.c
new file mode 100644
index 00000000000000..8df7b8f2744af5
--- /dev/null
+++ b/usr/klibc/userdb/getgrnam.c
@@ -0,0 +1,16 @@
+/*
+ * getgrnam.c
+ *
+ * Dummy getgrnam() to support udev
+ */
+
+#include "userdb.h"
+
+struct group *getgrnam(const char *name)
+{
+ if (!strcmp(name, "root"))
+ return (struct group *)&__root_group;
+
+ errno = ENOENT;
+ return NULL;
+}
diff --git a/usr/klibc/userdb/getpwnam.c b/usr/klibc/userdb/getpwnam.c
new file mode 100644
index 00000000000000..ae1359c925871c
--- /dev/null
+++ b/usr/klibc/userdb/getpwnam.c
@@ -0,0 +1,17 @@
+/*
+ * getpwnam.c
+ *
+ * Dummy getpwnam() to support udev
+ */
+
+#include "userdb.h"
+
+
+struct passwd *getpwnam(const char *name)
+{
+ if (!strcmp(name, "root"))
+ return (struct passwd *)&__root_user;
+
+ errno = ENOENT;
+ return NULL;
+}
diff --git a/usr/klibc/userdb/getpwuid.c b/usr/klibc/userdb/getpwuid.c
new file mode 100644
index 00000000000000..f924f29ac8f89d
--- /dev/null
+++ b/usr/klibc/userdb/getpwuid.c
@@ -0,0 +1,17 @@
+/*
+ * getpwuid.c
+ *
+ * Dummy getpwuid() to support udev
+ */
+
+#include "userdb.h"
+
+
+struct passwd *getpwuid(uid_t uid)
+{
+ if (!uid)
+ return (struct passwd *)&__root_user;
+
+ errno = ENOENT;
+ return NULL;
+}
diff --git a/usr/klibc/userdb/root_group.c b/usr/klibc/userdb/root_group.c
new file mode 100644
index 00000000000000..e936d543ba4ee6
--- /dev/null
+++ b/usr/klibc/userdb/root_group.c
@@ -0,0 +1,12 @@
+/*
+ * root_group.c
+ */
+
+#include "userdb.h"
+
+const struct group __root_group = {
+ .gr_name = "root",
+ .gr_passwd = "",
+ .gr_gid = 0,
+ .gr_mem = NULL
+};
diff --git a/usr/klibc/userdb/root_user.c b/usr/klibc/userdb/root_user.c
new file mode 100644
index 00000000000000..ee2e99a68394b0
--- /dev/null
+++ b/usr/klibc/userdb/root_user.c
@@ -0,0 +1,17 @@
+/*
+ * root_user.c
+ *
+ */
+
+#include "userdb.h"
+#include <paths.h>
+
+const struct passwd __root_user = {
+ .pw_name = "root",
+ .pw_passwd = "",
+ .pw_uid = 0,
+ .pw_gid = 0,
+ .pw_gecos = "root",
+ .pw_dir = "/",
+ .pw_shell = _PATH_BSHELL
+};
diff --git a/usr/klibc/userdb/userdb.h b/usr/klibc/userdb/userdb.h
new file mode 100644
index 00000000000000..dda093f17a9bb7
--- /dev/null
+++ b/usr/klibc/userdb/userdb.h
@@ -0,0 +1,19 @@
+/*
+ * userdb.h
+ *
+ * Common header file
+ */
+
+#ifndef USERDB_H
+#define USERDB_H
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+#include <string.h>
+#include <errno.h>
+
+extern const struct passwd __root_user;
+extern const struct group __root_group;
+
+#endif /* USERDB_H */