glibc/login/getutid.c
H.J. Lu 59c04e6763 Mark internal utmp functions with attribute_hidden [BZ #18822]
Mark internal utmp functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/utmp.h (__updwtmp): Add libc_hidden_proto.
	(__getutent): Likewise.
	(__getutid): Likewise.
	(__getutline): Likewise.
	(__pututline): Likewise.
	(__getutent_r): Likewise.
	(__getutid_r): Likewise.
	(__getutline_r): Likewise.
	(__utmpname): Add attribute_hidden.
	(__setutent): Likewise.
	(__endutent): Likewise.
	* login/getutent.c (__getutent): Add libc_hidden_def.
	* login/getutent_r.c (__getutent_r): Likewise.
	(__pututline): Likewise.
	* login/getutid.c (__getutid): Likewise.
	* login/getutid_r.c (__getutid_r): Likewise.
	* login/getutline.c (__getutline): Likewise.
	* login/getutline_r.c (__getutline_r): Likewise.
	* login/updwtmp.c (__updwtmp): Likewise.
2017-10-01 15:51:56 -07:00

44 lines
1.3 KiB
C

/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <utmp.h>
/* Local buffer to store the result. */
libc_freeres_ptr (static struct utmp *buffer);
struct utmp *
__getutid (const struct utmp *id)
{
struct utmp *result;
if (buffer == NULL)
{
buffer = (struct utmp *) malloc (sizeof (struct utmp));
if (buffer == NULL)
return NULL;
}
if (__getutid_r (id, buffer, &result) < 0)
return NULL;
return result;
}
libc_hidden_def (__getutid)
weak_alias (__getutid, getutid)