2023-01-06 21:08:04 +00:00
|
|
|
/* Copyright (C) 2008-2023 Free Software Foundation, Inc.
|
2008-07-26 17:43:30 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
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
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2008-07-26 17:43:30 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <utmp.h>
|
|
|
|
#include <errno.h>
|
2020-02-04 13:29:04 +00:00
|
|
|
#include <stdlib.h>
|
2008-07-26 17:43:30 +00:00
|
|
|
|
|
|
|
#include "utmp32.h"
|
|
|
|
#include "utmp-convert.h"
|
|
|
|
|
|
|
|
/* Allocate a static buffer to be returned to the caller. As well as
|
|
|
|
with the existing version of these functions the caller has to be
|
|
|
|
aware that the contents of this buffer will change with subsequent
|
|
|
|
calls. */
|
|
|
|
#define ALLOCATE_UTMP32_OUT(OUT) \
|
|
|
|
static struct utmp32 *OUT = NULL; \
|
2010-02-06 10:38:53 +00:00
|
|
|
\
|
2008-07-26 17:43:30 +00:00
|
|
|
if (OUT == NULL) \
|
|
|
|
{ \
|
|
|
|
OUT = malloc (sizeof (struct utmp32)); \
|
|
|
|
if (OUT == NULL) \
|
|
|
|
return NULL; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform a lookup for a utmp entry matching FIELD using function
|
|
|
|
FUNC. FIELD is converted to a 64 bit utmp and the result is
|
|
|
|
converted back to 32 bit utmp. */
|
|
|
|
#define ACCESS_UTMP_ENTRY(FUNC, FIELD) \
|
|
|
|
struct utmp in64; \
|
|
|
|
struct utmp *out64; \
|
|
|
|
ALLOCATE_UTMP32_OUT (out32); \
|
|
|
|
\
|
|
|
|
utmp_convert32to64 (FIELD, &in64); \
|
|
|
|
out64 = FUNC (&in64); \
|
|
|
|
\
|
|
|
|
if (out64 == NULL) \
|
|
|
|
return NULL; \
|
|
|
|
\
|
|
|
|
utmp_convert64to32 (out64, out32); \
|
|
|
|
\
|
|
|
|
return out32;
|
|
|
|
|
|
|
|
/* Search forward from the current point in the utmp file until the
|
|
|
|
next entry with a ut_type matching ID->ut_type. */
|
|
|
|
struct utmp32 *
|
|
|
|
getutid32 (const struct utmp32 *id)
|
|
|
|
{
|
2010-02-06 10:03:10 +00:00
|
|
|
ACCESS_UTMP_ENTRY (__getutid, id)
|
2008-07-26 17:43:30 +00:00
|
|
|
}
|
|
|
|
symbol_version (getutid32, getutid, GLIBC_2.0);
|
|
|
|
|
|
|
|
/* Search forward from the current point in the utmp file until the
|
|
|
|
next entry with a ut_line matching LINE->ut_line. */
|
|
|
|
struct utmp32 *
|
|
|
|
getutline32 (const struct utmp32 *line)
|
|
|
|
{
|
2010-02-06 10:03:10 +00:00
|
|
|
ACCESS_UTMP_ENTRY (__getutline, line)
|
2008-07-26 17:43:30 +00:00
|
|
|
}
|
|
|
|
symbol_version (getutline32, getutline, GLIBC_2.0);
|
|
|
|
|
|
|
|
/* Write out entry pointed to by UTMP_PTR into the utmp file. */
|
|
|
|
struct utmp32 *
|
|
|
|
pututline32 (const struct utmp32 *utmp_ptr)
|
|
|
|
{
|
2010-02-06 10:03:10 +00:00
|
|
|
ACCESS_UTMP_ENTRY (__pututline, utmp_ptr)
|
2008-07-26 17:43:30 +00:00
|
|
|
}
|
|
|
|
symbol_version (pututline32, pututline, GLIBC_2.0);
|
|
|
|
|
|
|
|
/* Read next entry from a utmp-like file. */
|
|
|
|
struct utmp32 *
|
|
|
|
getutent32 (void)
|
|
|
|
{
|
|
|
|
struct utmp *out64;
|
|
|
|
ALLOCATE_UTMP32_OUT (out32);
|
|
|
|
|
2010-02-06 10:03:10 +00:00
|
|
|
out64 = __getutent ();
|
2008-07-26 17:43:30 +00:00
|
|
|
if (!out64)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
utmp_convert64to32 (out64, out32);
|
|
|
|
return out32;
|
|
|
|
}
|
|
|
|
symbol_version (getutent32, getutent, GLIBC_2.0);
|
|
|
|
|
|
|
|
/* Reentrant versions of the file for handling utmp files. */
|
|
|
|
|
|
|
|
int
|
|
|
|
getutent32_r (struct utmp32 *buffer, struct utmp32 **result)
|
|
|
|
{
|
|
|
|
struct utmp out64;
|
|
|
|
struct utmp *out64p;
|
|
|
|
int ret;
|
|
|
|
|
2010-02-06 10:03:10 +00:00
|
|
|
ret = __getutent_r (&out64, &out64p);
|
2008-07-26 17:43:30 +00:00
|
|
|
if (ret == -1)
|
|
|
|
{
|
|
|
|
*result = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
utmp_convert64to32 (out64p, buffer);
|
|
|
|
*result = buffer;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
symbol_version (getutent32_r, getutent_r, GLIBC_2.0);
|
|
|
|
|
|
|
|
int
|
|
|
|
getutid32_r (const struct utmp32 *id, struct utmp32 *buffer,
|
|
|
|
struct utmp32 **result)
|
|
|
|
{
|
|
|
|
struct utmp in64;
|
|
|
|
struct utmp out64;
|
|
|
|
struct utmp *out64p;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
utmp_convert32to64 (id, &in64);
|
|
|
|
|
2010-02-06 10:03:10 +00:00
|
|
|
ret = __getutid_r (&in64, &out64, &out64p);
|
2008-07-26 17:43:30 +00:00
|
|
|
if (ret == -1)
|
|
|
|
{
|
|
|
|
*result = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
utmp_convert64to32 (out64p, buffer);
|
|
|
|
*result = buffer;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
symbol_version (getutid32_r, getutid_r, GLIBC_2.0);
|
|
|
|
|
|
|
|
int
|
|
|
|
getutline32_r (const struct utmp32 *line,
|
|
|
|
struct utmp32 *buffer, struct utmp32 **result)
|
|
|
|
{
|
|
|
|
struct utmp in64;
|
|
|
|
struct utmp out64;
|
|
|
|
struct utmp *out64p;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
utmp_convert32to64 (line, &in64);
|
|
|
|
|
2010-02-06 10:03:10 +00:00
|
|
|
ret = __getutline_r (&in64, &out64, &out64p);
|
2008-07-26 17:43:30 +00:00
|
|
|
if (ret == -1)
|
|
|
|
{
|
|
|
|
*result = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
utmp_convert64to32 (out64p, buffer);
|
|
|
|
*result = buffer;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
symbol_version (getutline32_r, getutline_r, GLIBC_2.0);
|
|
|
|
|
|
|
|
/* Append entry UTMP to the wtmp-like file WTMP_FILE. */
|
|
|
|
void
|
|
|
|
updwtmp32 (const char *wtmp_file, const struct utmp32 *utmp)
|
|
|
|
{
|
|
|
|
struct utmp in32;
|
|
|
|
|
|
|
|
utmp_convert32to64 (utmp, &in32);
|
2010-02-06 10:03:10 +00:00
|
|
|
__updwtmp (wtmp_file, &in32);
|
2008-07-26 17:43:30 +00:00
|
|
|
}
|
|
|
|
symbol_version (updwtmp32, updwtmp, GLIBC_2.0);
|