Move getlogin*() to its own file and fix the build.

This way it doesn't get linked to the kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23395 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2008-01-11 13:47:45 +00:00
parent 374b5544a9
commit 38196dea30
4 changed files with 39 additions and 48 deletions
-24
View File
@@ -133,27 +133,3 @@ getpwuid_r(uid_t uid, struct passwd *passwd, char *buffer,
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;
}
-24
View File
@@ -621,30 +621,6 @@ 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)
{
+1
View File
@@ -14,6 +14,7 @@ MergeObject posix_unistd.o :
_exit.c
fcntl.c
fork.c
getlogin.c
hostname.cpp
ioctl.c
link.c
@@ -0,0 +1,38 @@
/*
* Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <syscalls.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <pwd.h>
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;
}