Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/glibc/nscd/getpwuid_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,27 @@
/* We are nscd, so we don't want to be talking to ourselves. */
#undef USE_NSCD

#include <nss/getXXbyYY_r.c>
// TODO: normal getpwuid routine is not working correctly for some reason
// currently hardcoded the value but we should fix this in the future
// #include <nss/getXXbyYY_r.c>

int
__getpwuid_r (uid_t uid, struct passwd *resbuf, char *buffer,
size_t buflen, struct passwd **result)
{
if(uid != 1000) return -1;

resbuf->pw_name = "lind";
resbuf->pw_passwd = "";
resbuf->pw_uid = 1000;
resbuf->pw_gid = 1000;
resbuf->pw_gecos = "lind";
resbuf->pw_dir = "/home";
resbuf->pw_shell = "/bin/sh";

result = &resbuf;

return 0;
}

weak_alias (__getpwuid_r, getpwuid_r)
22 changes: 20 additions & 2 deletions src/glibc/nss/getpwuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<https://www.gnu.org/licenses/>. */

#include <pwd.h>

#include <stdlib.h>

#define LOOKUP_TYPE struct passwd
#define FUNCTION_NAME getpwuid
Expand All @@ -25,4 +25,22 @@
#define ADD_VARIABLES uid
#define BUFLEN NSS_BUFLEN_PASSWD

#include "../nss/getXXbyYY.c"
// TODO: normal getpwuid routine is not working correctly for some reason
// currently hardcoded the value but we should fix this in the future
// #include "../nss/getXXbyYY.c"

struct passwd *
getpwuid (uid_t uid)
{
if(uid != 1000) return NULL;

struct passwd *res = malloc(sizeof(struct passwd));
res->pw_name = "lind";
res->pw_passwd = "";
res->pw_uid = 1000;
res->pw_gid = 1000;
res->pw_gecos = "lind";
res->pw_dir = "/home";
res->pw_shell = "/bin/sh";
return res;
}
23 changes: 22 additions & 1 deletion src/glibc/nss/getpwuid_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,25 @@
#define ADD_VARIABLES uid
#define BUFLEN NSS_BUFLEN_PASSWD

#include <nss/getXXbyYY_r.c>
// TODO: normal getpwuid routine is not working correctly for some reason
// currently hardcoded the value but we should fix this in the future
// #include <nss/getXXbyYY_r.c>

int
getpwuid_r (uid_t uid, struct passwd *resbuf, char *buffer,
size_t buflen, struct passwd **result)
{
if(uid != 1000) return -1;

resbuf->pw_name = "lind";
resbuf->pw_passwd = "";
resbuf->pw_uid = 1000;
resbuf->pw_gid = 1000;
resbuf->pw_gecos = "lind";
resbuf->pw_dir = "/home";
resbuf->pw_shell = "/bin/sh";

result = &resbuf;

return 0;
}