|
|
5f7b84 |
commit 1a7fe2ebe52b3c8bf465d1756e69452d05c1c103
|
|
|
5f7b84 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
5f7b84 |
Date: Mon Aug 5 15:54:10 2019 +0200
|
|
|
5f7b84 |
|
|
|
5f7b84 |
login: Remove utmp backend jump tables [BZ #23518]
|
|
|
5f7b84 |
|
|
|
5f7b84 |
There is just one file-based implementation, so this dispatch
|
|
|
5f7b84 |
mechanism is unnecessary. Instead of the vtable pointer
|
|
|
5f7b84 |
__libc_utmp_jump_table, use a non-negative file_fd as the indicator
|
|
|
5f7b84 |
that the backend is initialized.
|
|
|
5f7b84 |
|
|
|
5f7b84 |
diff --git a/login/getutent_r.c b/login/getutent_r.c
|
|
|
5f7b84 |
index 6a244ba6e0b86da7..44239ecb81bacea4 100644
|
|
|
5f7b84 |
--- a/login/getutent_r.c
|
|
|
5f7b84 |
+++ b/login/getutent_r.c
|
|
|
5f7b84 |
@@ -23,115 +23,16 @@
|
|
|
5f7b84 |
|
|
|
5f7b84 |
#include "utmp-private.h"
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Functions defined here. */
|
|
|
5f7b84 |
-static int setutent_unknown (void);
|
|
|
5f7b84 |
-static int getutent_r_unknown (struct utmp *buffer, struct utmp **result);
|
|
|
5f7b84 |
-static int getutid_r_unknown (const struct utmp *line, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result);
|
|
|
5f7b84 |
-static int getutline_r_unknown (const struct utmp *id, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result);
|
|
|
5f7b84 |
-static struct utmp *pututline_unknown (const struct utmp *data);
|
|
|
5f7b84 |
-static void endutent_unknown (void);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Initial Jump table. */
|
|
|
5f7b84 |
-const struct utfuncs __libc_utmp_unknown_functions =
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- setutent_unknown,
|
|
|
5f7b84 |
- getutent_r_unknown,
|
|
|
5f7b84 |
- getutid_r_unknown,
|
|
|
5f7b84 |
- getutline_r_unknown,
|
|
|
5f7b84 |
- pututline_unknown,
|
|
|
5f7b84 |
- endutent_unknown,
|
|
|
5f7b84 |
- NULL
|
|
|
5f7b84 |
-};
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Currently selected backend. */
|
|
|
5f7b84 |
-const struct utfuncs *__libc_utmp_jump_table = &__libc_utmp_unknown_functions;
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
/* We need to protect the opening of the file. */
|
|
|
5f7b84 |
__libc_lock_define_initialized (, __libc_utmp_lock attribute_hidden)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-setutent_unknown (void)
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- int result;
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- result = (*__libc_utmp_file_functions.setutent) ();
|
|
|
5f7b84 |
- if (result)
|
|
|
5f7b84 |
- __libc_utmp_jump_table = &__libc_utmp_file_functions;
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- return result;
|
|
|
5f7b84 |
-}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-getutent_r_unknown (struct utmp *buffer, struct utmp **result)
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- /* The backend was not yet initialized. */
|
|
|
5f7b84 |
- if (setutent_unknown ())
|
|
|
5f7b84 |
- return (*__libc_utmp_jump_table->getutent_r) (buffer, result);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- /* Not available. */
|
|
|
5f7b84 |
- *result = NULL;
|
|
|
5f7b84 |
- return -1;
|
|
|
5f7b84 |
-}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-getutid_r_unknown (const struct utmp *id, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result)
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- /* The backend was not yet initialized. */
|
|
|
5f7b84 |
- if (setutent_unknown ())
|
|
|
5f7b84 |
- return (*__libc_utmp_jump_table->getutid_r) (id, buffer, result);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- /* Not available. */
|
|
|
5f7b84 |
- *result = NULL;
|
|
|
5f7b84 |
- return -1;
|
|
|
5f7b84 |
-}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-getutline_r_unknown (const struct utmp *line, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result)
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- /* The backend was not yet initialized. */
|
|
|
5f7b84 |
- if (setutent_unknown ())
|
|
|
5f7b84 |
- return (*__libc_utmp_jump_table->getutline_r) (line, buffer, result);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- /* Not available. */
|
|
|
5f7b84 |
- *result = NULL;
|
|
|
5f7b84 |
- return -1;
|
|
|
5f7b84 |
-}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-static struct utmp *
|
|
|
5f7b84 |
-pututline_unknown (const struct utmp *data)
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- /* The backend was not yet initialized. */
|
|
|
5f7b84 |
- if (setutent_unknown ())
|
|
|
5f7b84 |
- return (*__libc_utmp_jump_table->pututline) (data);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- /* Not available. */
|
|
|
5f7b84 |
- return NULL;
|
|
|
5f7b84 |
-}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-static void
|
|
|
5f7b84 |
-endutent_unknown (void)
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- /* Nothing to do. */
|
|
|
5f7b84 |
-}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
void
|
|
|
5f7b84 |
__setutent (void)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- (*__libc_utmp_jump_table->setutent) ();
|
|
|
5f7b84 |
+ __libc_setutent ();
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
@@ -145,7 +46,7 @@ __getutent_r (struct utmp *buffer, struct utmp **result)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- retval = (*__libc_utmp_jump_table->getutent_r) (buffer, result);
|
|
|
5f7b84 |
+ retval = __libc_getutent_r (buffer, result);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
@@ -162,7 +63,7 @@ __pututline (const struct utmp *data)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- buffer = (*__libc_utmp_jump_table->pututline) (data);
|
|
|
5f7b84 |
+ buffer = __libc_pututline (data);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
@@ -177,8 +78,7 @@ __endutent (void)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- (*__libc_utmp_jump_table->endutent) ();
|
|
|
5f7b84 |
- __libc_utmp_jump_table = &__libc_utmp_unknown_functions;
|
|
|
5f7b84 |
+ __libc_endutent ();
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
diff --git a/login/getutid_r.c b/login/getutid_r.c
|
|
|
5f7b84 |
index b7d3dbac75774b0a..8cb6b16d735e8265 100644
|
|
|
5f7b84 |
--- a/login/getutid_r.c
|
|
|
5f7b84 |
+++ b/login/getutid_r.c
|
|
|
5f7b84 |
@@ -49,7 +49,7 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- retval = (*__libc_utmp_jump_table->getutid_r) (id, buffer, result);
|
|
|
5f7b84 |
+ retval = __libc_getutid_r (id, buffer, result);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
diff --git a/login/getutline_r.c b/login/getutline_r.c
|
|
|
5f7b84 |
index 6996887f76b28816..5607c19ed2e1ca66 100644
|
|
|
5f7b84 |
--- a/login/getutline_r.c
|
|
|
5f7b84 |
+++ b/login/getutline_r.c
|
|
|
5f7b84 |
@@ -36,7 +36,7 @@ __getutline_r (const struct utmp *line, struct utmp *buffer,
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- retval = (*__libc_utmp_jump_table->getutline_r) (line, buffer, result);
|
|
|
5f7b84 |
+ retval = __libc_getutline_r (line, buffer, result);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
diff --git a/login/updwtmp.c b/login/updwtmp.c
|
|
|
5f7b84 |
index 56fb41916a776c0a..7ae96224ca789b6d 100644
|
|
|
5f7b84 |
--- a/login/updwtmp.c
|
|
|
5f7b84 |
+++ b/login/updwtmp.c
|
|
|
5f7b84 |
@@ -29,7 +29,7 @@ __updwtmp (const char *wtmp_file, const struct utmp *utmp)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
const char *file_name = TRANSFORM_UTMP_FILE_NAME (wtmp_file);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- (*__libc_utmp_file_functions.updwtmp) (file_name, utmp);
|
|
|
5f7b84 |
+ __libc_updwtmp (file_name, utmp);
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
libc_hidden_def (__updwtmp)
|
|
|
5f7b84 |
weak_alias (__updwtmp, updwtmp)
|
|
|
5f7b84 |
diff --git a/login/utmp-private.h b/login/utmp-private.h
|
|
|
5f7b84 |
index bd8773984cfc56de..5c2048ee52dc3cee 100644
|
|
|
5f7b84 |
--- a/login/utmp-private.h
|
|
|
5f7b84 |
+++ b/login/utmp-private.h
|
|
|
5f7b84 |
@@ -24,24 +24,17 @@
|
|
|
5f7b84 |
#include <utmp.h>
|
|
|
5f7b84 |
#include <libc-lock.h>
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-/* The structure describing the functions in a backend. */
|
|
|
5f7b84 |
-struct utfuncs
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- int (*setutent) (void);
|
|
|
5f7b84 |
- int (*getutent_r) (struct utmp *, struct utmp **);
|
|
|
5f7b84 |
- int (*getutid_r) (const struct utmp *, struct utmp *, struct utmp **);
|
|
|
5f7b84 |
- int (*getutline_r) (const struct utmp *, struct utmp *, struct utmp **);
|
|
|
5f7b84 |
- struct utmp *(*pututline) (const struct utmp *);
|
|
|
5f7b84 |
- void (*endutent) (void);
|
|
|
5f7b84 |
- int (*updwtmp) (const char *, const struct utmp *);
|
|
|
5f7b84 |
-};
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* The tables from the services. */
|
|
|
5f7b84 |
-extern const struct utfuncs __libc_utmp_file_functions attribute_hidden;
|
|
|
5f7b84 |
-extern const struct utfuncs __libc_utmp_unknown_functions attribute_hidden;
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Currently selected backend. */
|
|
|
5f7b84 |
-extern const struct utfuncs *__libc_utmp_jump_table attribute_hidden;
|
|
|
5f7b84 |
+/* These functions check for initialization, but not perform any
|
|
|
5f7b84 |
+ locking. */
|
|
|
5f7b84 |
+int __libc_setutent (void) attribute_hidden;
|
|
|
5f7b84 |
+int __libc_getutent_r (struct utmp *, struct utmp **) attribute_hidden;
|
|
|
5f7b84 |
+int __libc_getutid_r (const struct utmp *, struct utmp *, struct utmp **)
|
|
|
5f7b84 |
+ attribute_hidden;
|
|
|
5f7b84 |
+int __libc_getutline_r (const struct utmp *, struct utmp *, struct utmp **)
|
|
|
5f7b84 |
+ attribute_hidden;
|
|
|
5f7b84 |
+struct utmp *__libc_pututline (const struct utmp *) attribute_hidden;
|
|
|
5f7b84 |
+void __libc_endutent (void) attribute_hidden;
|
|
|
5f7b84 |
+int __libc_updwtmp (const char *, const struct utmp *) attribute_hidden;
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Current file name. */
|
|
|
5f7b84 |
extern const char *__libc_utmp_file_name attribute_hidden;
|
|
|
5f7b84 |
diff --git a/login/utmp_file.c b/login/utmp_file.c
|
|
|
5f7b84 |
index 040a5057116bb69d..069e6d0452e333ad 100644
|
|
|
5f7b84 |
--- a/login/utmp_file.c
|
|
|
5f7b84 |
+++ b/login/utmp_file.c
|
|
|
5f7b84 |
@@ -105,37 +105,12 @@ static void timeout_handler (int signum) {};
|
|
|
5f7b84 |
alarm (old_timeout); \
|
|
|
5f7b84 |
} while (0)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Functions defined here. */
|
|
|
5f7b84 |
-static int setutent_file (void);
|
|
|
5f7b84 |
-static int getutent_r_file (struct utmp *buffer, struct utmp **result);
|
|
|
5f7b84 |
-static int getutid_r_file (const struct utmp *key, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result);
|
|
|
5f7b84 |
-static int getutline_r_file (const struct utmp *key, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result);
|
|
|
5f7b84 |
-static struct utmp *pututline_file (const struct utmp *data);
|
|
|
5f7b84 |
-static void endutent_file (void);
|
|
|
5f7b84 |
-static int updwtmp_file (const char *file, const struct utmp *utmp);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Jump table for file functions. */
|
|
|
5f7b84 |
-const struct utfuncs __libc_utmp_file_functions =
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- setutent_file,
|
|
|
5f7b84 |
- getutent_r_file,
|
|
|
5f7b84 |
- getutid_r_file,
|
|
|
5f7b84 |
- getutline_r_file,
|
|
|
5f7b84 |
- pututline_file,
|
|
|
5f7b84 |
- endutent_file,
|
|
|
5f7b84 |
- updwtmp_file
|
|
|
5f7b84 |
-};
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
#ifndef TRANSFORM_UTMP_FILE_NAME
|
|
|
5f7b84 |
# define TRANSFORM_UTMP_FILE_NAME(file_name) (file_name)
|
|
|
5f7b84 |
#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-setutent_file (void)
|
|
|
5f7b84 |
+int
|
|
|
5f7b84 |
+__libc_setutent (void)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
if (file_fd < 0)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
@@ -166,15 +141,19 @@ setutent_file (void)
|
|
|
5f7b84 |
return 1;
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
+/* Preform initialization if necessary. */
|
|
|
5f7b84 |
+static bool
|
|
|
5f7b84 |
+maybe_setutent (void)
|
|
|
5f7b84 |
+{
|
|
|
5f7b84 |
+ return file_fd >= 0 || __libc_setutent ();
|
|
|
5f7b84 |
+}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-getutent_r_file (struct utmp *buffer, struct utmp **result)
|
|
|
5f7b84 |
+int
|
|
|
5f7b84 |
+__libc_getutent_r (struct utmp *buffer, struct utmp **result)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
ssize_t nbytes;
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- assert (file_fd >= 0);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- if (file_offset == -1l)
|
|
|
5f7b84 |
+ if (!maybe_setutent () || file_offset == -1l)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
/* Not available. */
|
|
|
5f7b84 |
*result = NULL;
|
|
|
5f7b84 |
@@ -279,13 +258,11 @@ unlock_return:
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* For implementing this function we don't use the getutent_r function
|
|
|
5f7b84 |
because we can avoid the reposition on every new entry this way. */
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-getutid_r_file (const struct utmp *id, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result)
|
|
|
5f7b84 |
+int
|
|
|
5f7b84 |
+__libc_getutid_r (const struct utmp *id, struct utmp *buffer,
|
|
|
5f7b84 |
+ struct utmp **result)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
- assert (file_fd >= 0);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- if (file_offset == -1l)
|
|
|
5f7b84 |
+ if (!maybe_setutent () || file_offset == -1l)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
*result = NULL;
|
|
|
5f7b84 |
return -1;
|
|
|
5f7b84 |
@@ -309,13 +286,11 @@ getutid_r_file (const struct utmp *id, struct utmp *buffer,
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* For implementing this function we don't use the getutent_r function
|
|
|
5f7b84 |
because we can avoid the reposition on every new entry this way. */
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-getutline_r_file (const struct utmp *line, struct utmp *buffer,
|
|
|
5f7b84 |
- struct utmp **result)
|
|
|
5f7b84 |
+int
|
|
|
5f7b84 |
+__libc_getutline_r (const struct utmp *line, struct utmp *buffer,
|
|
|
5f7b84 |
+ struct utmp **result)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
- assert (file_fd >= 0);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- if (file_offset == -1l)
|
|
|
5f7b84 |
+ if (!maybe_setutent () || file_offset == -1l)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
*result = NULL;
|
|
|
5f7b84 |
return -1;
|
|
|
5f7b84 |
@@ -361,15 +336,16 @@ unlock_return:
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-static struct utmp *
|
|
|
5f7b84 |
-pututline_file (const struct utmp *data)
|
|
|
5f7b84 |
+struct utmp *
|
|
|
5f7b84 |
+__libc_pututline (const struct utmp *data)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
+ if (!maybe_setutent ())
|
|
|
5f7b84 |
+ return NULL;
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
struct utmp buffer;
|
|
|
5f7b84 |
struct utmp *pbuf;
|
|
|
5f7b84 |
int found;
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- assert (file_fd >= 0);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
if (! file_writable)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
/* We must make the file descriptor writable before going on. */
|
|
|
5f7b84 |
@@ -467,18 +443,19 @@ pututline_file (const struct utmp *data)
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-static void
|
|
|
5f7b84 |
-endutent_file (void)
|
|
|
5f7b84 |
+void
|
|
|
5f7b84 |
+__libc_endutent (void)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
- assert (file_fd >= 0);
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- __close_nocancel_nostatus (file_fd);
|
|
|
5f7b84 |
- file_fd = -1;
|
|
|
5f7b84 |
+ if (file_fd >= 0)
|
|
|
5f7b84 |
+ {
|
|
|
5f7b84 |
+ __close_nocancel_nostatus (file_fd);
|
|
|
5f7b84 |
+ file_fd = -1;
|
|
|
5f7b84 |
+ }
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-static int
|
|
|
5f7b84 |
-updwtmp_file (const char *file, const struct utmp *utmp)
|
|
|
5f7b84 |
+int
|
|
|
5f7b84 |
+__libc_updwtmp (const char *file, const struct utmp *utmp)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
int result = -1;
|
|
|
5f7b84 |
off64_t offset;
|
|
|
5f7b84 |
diff --git a/login/utmpname.c b/login/utmpname.c
|
|
|
5f7b84 |
index 21cb890a1a2fdc92..73b19c33ceab4dd7 100644
|
|
|
5f7b84 |
--- a/login/utmpname.c
|
|
|
5f7b84 |
+++ b/login/utmpname.c
|
|
|
5f7b84 |
@@ -42,8 +42,7 @@ __utmpname (const char *file)
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Close the old file. */
|
|
|
5f7b84 |
- (*__libc_utmp_jump_table->endutent) ();
|
|
|
5f7b84 |
- __libc_utmp_jump_table = &__libc_utmp_unknown_functions;
|
|
|
5f7b84 |
+ __libc_endutent ();
|
|
|
5f7b84 |
|
|
|
5f7b84 |
if (strcmp (file, __libc_utmp_file_name) != 0)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
diff --git a/manual/users.texi b/manual/users.texi
|
|
|
5f7b84 |
index 4ed79ba26fc8e9d0..a006bb58acfd0568 100644
|
|
|
5f7b84 |
--- a/manual/users.texi
|
|
|
5f7b84 |
+++ b/manual/users.texi
|
|
|
5f7b84 |
@@ -894,9 +894,9 @@ The @code{getlogin} function is declared in @file{unistd.h}, while
|
|
|
5f7b84 |
@c ttyname_r dup @ascuheap @acsmem @acsfd
|
|
|
5f7b84 |
@c strncpy dup ok
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->setutent dup @mtasurace:utent @acsfd
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->getutline_r dup @mtasurace:utent @mtascusig:ALRM @mtascutimer
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->endutent dup @mtasurace:utent @asulock @aculock
|
|
|
5f7b84 |
+@c __libc_setutent dup @mtasurace:utent @acsfd
|
|
|
5f7b84 |
+@c __libc_getutline_r dup @mtasurace:utent @mtascusig:ALRM @mtascutimer
|
|
|
5f7b84 |
+@c __libc_endutent dup @mtasurace:utent @asulock @aculock
|
|
|
5f7b84 |
@c libc_lock_unlock dup ok
|
|
|
5f7b84 |
@c strlen dup ok
|
|
|
5f7b84 |
@c memcpy dup ok
|
|
|
5f7b84 |
@@ -1111,7 +1111,7 @@ compatibility only, @file{utmp.h} defines @code{ut_time} as an alias for
|
|
|
5f7b84 |
|
|
|
5f7b84 |
@c setutent @mtasurace:utent @asulock @aculock @acsfd
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->setutent @mtasurace:utent @acsfd
|
|
|
5f7b84 |
+@c __libc_setutent @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c setutent_unknown @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c *libc_utmp_file_functions.setutent = setutent_file @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c open_not_cancel_2 dup @acsfd
|
|
|
5f7b84 |
@@ -1152,7 +1152,7 @@ A null pointer is returned in case no further entry is available.
|
|
|
5f7b84 |
@safety{@prelim{}@mtunsafe{@mtasurace{:utent}}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{}}}
|
|
|
5f7b84 |
@c endutent @mtasurace:utent @asulock @aculock @acsfd
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->endutent @mtasurace:utent @acsfd
|
|
|
5f7b84 |
+@c __libc_endutent @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c endutent_unknown ok
|
|
|
5f7b84 |
@c endutent_file @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c close_not_cancel_no_status dup @acsfd
|
|
|
5f7b84 |
@@ -1230,7 +1230,7 @@ over again.
|
|
|
5f7b84 |
@safety{@prelim{}@mtunsafe{@mtasurace{:utent} @mtascusig{:ALRM} @mtascutimer{}}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{}}}
|
|
|
5f7b84 |
@c pututline @mtasurace:utent @mtascusig:ALRM @mtascutimer @asulock @aculock @acsfd
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->pututline @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
+@c __libc_pututline @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
@c pututline_unknown @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c setutent_unknown dup @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c pututline_file @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
@@ -1282,7 +1282,7 @@ user-provided buffer.
|
|
|
5f7b84 |
@safety{@prelim{}@mtunsafe{@mtasurace{:utent} @mtascusig{:ALRM} @mtascutimer{}}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{}}}
|
|
|
5f7b84 |
@c getutent_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @asulock @aculock @acsfd
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->getutent_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
+@c __libc_getutent_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
@c getutent_r_unknown @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c setutent_unknown dup @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c getutent_r_file @mtasurace:utent @mtascusig:ALRM @mtascutimer
|
|
|
5f7b84 |
@@ -1319,7 +1319,7 @@ This function is a GNU extension.
|
|
|
5f7b84 |
@safety{@prelim{}@mtunsafe{@mtasurace{:utent} @mtascusig{:ALRM} @mtascutimer{}}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{}}}
|
|
|
5f7b84 |
@c getutid_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @asulock @aculock @acsfd
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->getutid_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
+@c __libc_getutid_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
@c getutid_r_unknown @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c setutent_unknown dup @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c getutid_r_file @mtascusig:ALRM @mtascutimer
|
|
|
5f7b84 |
@@ -1349,7 +1349,7 @@ This function is a GNU extension.
|
|
|
5f7b84 |
@safety{@prelim{}@mtunsafe{@mtasurace{:utent} @mtascusig{:ALRM} @mtascutimer{}}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{}}}
|
|
|
5f7b84 |
@c getutline_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @asulock @aculock @acsfd
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->getutline_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
+@c __libc_getutline_r @mtasurace:utent @mtascusig:ALRM @mtascutimer @acsfd
|
|
|
5f7b84 |
@c getutline_r_unknown @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c setutent_unknown dup @mtasurace:utent @acsfd
|
|
|
5f7b84 |
@c getutline_r_file @mtasurace:utent @mtascusig:ALRM @mtascutimer
|
|
|
5f7b84 |
@@ -1393,7 +1393,7 @@ be used.
|
|
|
5f7b84 |
@safety{@prelim{}@mtunsafe{@mtasurace{:utent}}@asunsafe{@asulock{} @ascuheap{}}@acunsafe{@aculock{} @acsmem{}}}
|
|
|
5f7b84 |
@c utmpname @mtasurace:utent @asulock @ascuheap @aculock @acsmem
|
|
|
5f7b84 |
@c libc_lock_lock dup @asulock @aculock
|
|
|
5f7b84 |
-@c *libc_utmp_jump_table->endutent dup @mtasurace:utent
|
|
|
5f7b84 |
+@c __libc_endutent dup @mtasurace:utent
|
|
|
5f7b84 |
@c strcmp dup ok
|
|
|
5f7b84 |
@c free dup @ascuheap @acsmem
|
|
|
5f7b84 |
@c strdup dup @ascuheap @acsmem
|
|
|
5f7b84 |
diff --git a/sysdeps/unix/getlogin_r.c b/sysdeps/unix/getlogin_r.c
|
|
|
5f7b84 |
index 444df7e4d3210cf6..180c0bbca13d0f87 100644
|
|
|
5f7b84 |
--- a/sysdeps/unix/getlogin_r.c
|
|
|
5f7b84 |
+++ b/sysdeps/unix/getlogin_r.c
|
|
|
5f7b84 |
@@ -64,8 +64,8 @@ __getlogin_r (char *name, size_t name_len)
|
|
|
5f7b84 |
held so that our search is thread-safe. */
|
|
|
5f7b84 |
|
|
|
5f7b84 |
__libc_lock_lock (__libc_utmp_lock);
|
|
|
5f7b84 |
- (*__libc_utmp_jump_table->setutent) ();
|
|
|
5f7b84 |
- result = (*__libc_utmp_jump_table->getutline_r) (&line, &buffer, &ut);
|
|
|
5f7b84 |
+ __libc_setutent ();
|
|
|
5f7b84 |
+ result = __libc_getutline_r (&line, &buffer, &ut);
|
|
|
5f7b84 |
if (result < 0)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
if (errno == ESRCH)
|
|
|
5f7b84 |
@@ -74,8 +74,7 @@ __getlogin_r (char *name, size_t name_len)
|
|
|
5f7b84 |
else
|
|
|
5f7b84 |
result = errno;
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
- (*__libc_utmp_jump_table->endutent) ();
|
|
|
5f7b84 |
- __libc_utmp_jump_table = &__libc_utmp_unknown_functions;
|
|
|
5f7b84 |
+ __libc_endutent ();
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
if (result == 0)
|