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:
@@ -133,27 +133,3 @@ getpwuid_r(uid_t uid, struct passwd *passwd, char *buffer,
|
|||||||
return 0;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 __init_pwd_stuff(void)
|
||||||
//void _multiuser_init(void)
|
//void _multiuser_init(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ MergeObject posix_unistd.o :
|
|||||||
_exit.c
|
_exit.c
|
||||||
fcntl.c
|
fcntl.c
|
||||||
fork.c
|
fork.c
|
||||||
|
getlogin.c
|
||||||
hostname.cpp
|
hostname.cpp
|
||||||
ioctl.c
|
ioctl.c
|
||||||
link.c
|
link.c
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2006, Axel Dörfler, [email protected]. 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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user