diff --git a/src/system/libroot/posix/pwd.c b/src/system/libroot/posix/pwd.c index 019fa91c46..404831463f 100644 --- a/src/system/libroot/posix/pwd.c +++ b/src/system/libroot/posix/pwd.c @@ -132,3 +132,28 @@ getpwuid_r(uid_t uid, struct passwd *passwd, char *buffer, *_result = passwd; return 0; } + + +char *getlogin() +{ + struct passwd *pw; + pw = getpwuid(getuid()); + if (pw) + return pw->pw_name; + errno = ENOMEM; + return NULL; +} + + +int getlogin_r(char *name, size_t nameSize) +{ + struct passwd *pw; + pw = getpwuid(getuid()); + if (pw && (nameSize > 32/*PW_MAX_NAME*/)) { + memset(name, 0, nameSize); + strlcpy(name, pw->pw_name, 32/*PW_MAX_NAME*/); + return B_OK; + } + return ENOMEM; +} + diff --git a/src/system/libroot/posix/pwd_query.c b/src/system/libroot/posix/pwd_query.c index 65e6f7a695..521df6aa03 100644 --- a/src/system/libroot/posix/pwd_query.c +++ b/src/system/libroot/posix/pwd_query.c @@ -621,6 +621,30 @@ struct passwd *getpwnam(const char *name) } +char *getlogin() +{ + struct passwd *pw; + pw = getpwuid(getuid()); + if (pw) + return pw->pw_name; + errno = ENOMEM; + return NULL; +} + + +int getlogin_r(char *name, size_t nameSize) +{ + struct passwd *pw; + pw = getpwuid(getuid()); + if (pw && (nameSize > 32/*PW_MAX_NAME*/)) { + memset(name, 0, nameSize); + strlcpy(name, pw->pw_name, 32/*PW_MAX_NAME*/); + return B_OK; + } + return ENOMEM; +} + + void __init_pwd_stuff(void) //void _multiuser_init(void) { diff --git a/src/system/libroot/posix/unistd/usergroup.c b/src/system/libroot/posix/unistd/usergroup.c index fd7628b8f1..693ceeb393 100644 --- a/src/system/libroot/posix/unistd/usergroup.c +++ b/src/system/libroot/posix/unistd/usergroup.c @@ -100,28 +100,3 @@ seteuid(uid_t uid) return EPERM; } - -char *getlogin() -{ - struct passwd *pw; - pw = getpwuid(getuid()); - if (pw) - return pw->pw_name; - errno = ENOMEM; - return NULL; -} - - -int getlogin_r(char *name, size_t nameSize) -{ - struct passwd *pw; - pw = getpwuid(getuid()); - if (pw && (nameSize > 32/*PW_MAX_NAME*/)) { - memset(name, 0, nameSize); - strlcpy(name, pw->pw_name, 32/*PW_MAX_NAME*/); - return B_OK; - } - return ENOMEM; -} - -