aboutsummaryrefslogtreecommitdiff
path: root/login
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-08-02 21:00:51 +0000
committerUlrich Drepper <drepper@redhat.com>1997-08-02 21:00:51 +0000
commit8f2ece695d8822e9ecc63ecd157e90bf17a6fe65 (patch)
tree8391ab64ce8c9c6e45d137905f75f1d17c9ed987 /login
parent3996f34b46043ed8ea8fdc6f44377d969d64396b (diff)
downloadglibc-8f2ece695d8822e9ecc63ecd157e90bf17a6fe65.zip
glibc-8f2ece695d8822e9ecc63ecd157e90bf17a6fe65.tar.gz
glibc-8f2ece695d8822e9ecc63ecd157e90bf17a6fe65.tar.bz2
1997-08-02 21:27 Ulrich Drepper <drepper@cygnus.com> * inet/Makefile (headers): Rename netinet/inbits.h to bits/in.h. * inet/netinet/in.h: Include bits/in.h instead of netinet/inbits.h. * sysdeps/generic/netinet/inbits.h: Move to... * sysdeps/generic/bits/in.h: ... here. * sysdeps/unix/sysv/linux/bits/inbits.h: Move to ... * sysdeps/unix/sysv/linux/bits/in.h: ... here. * nis/Makefile (headers): Add bits/nislib.h. * nis/rpcsvc/nislib.h: Moved to .... * nis/bits/nislib.h: ... here. * nis/nss_compat/compat-grp.c: Don't include <rpcsvc/nislib.h>. * nis/nss_compat/compat-pwd.c: Likewise. * nis/nss_compat/compat-spwd.c: Likewise. * nis/nss_nisplus/nisplus-alias.c: Likewise. * nis/nss_nisplus/nisplus-ethers.c: Likewise. * nis/nss_nisplus/nisplus-grp.c: Likewise. * nis/nss_nisplus/nisplus-hosts.c: Likewise. * nis/nss_nisplus/nisplus-netgrp.c: Likewise. * nis/nss_nisplus/nisplus-ntework.c: Likewise. * nis/nss_nisplus/nisplus-proto.c: Likewise. * nis/nss_nisplus/nisplus-publickey.c: Likewise. * nis/nss_nisplus/nisplus-pwd.c: Likewise. * nis/nss_nisplus/nisplus-rpc.c: Likewise. * nis/nss_nisplus/nisplus-service.c: Likewise. * nis/nss_nisplus/nisplus-spwd.c: Likewise. * nis/rpcsvc/nis.x: Include bits/nislib.h, not rpcsvc/nislib.h. * nis/rpcsvc/nis.h: Likewise. * inet/getnameinfo.c (nrl_domainname): Change return type to const char *. (getnameinfo): Change type of local variable c to const char *. * inet/inet_ntoa.c: Rewrite to use __libc_once for initialization. * stdlib/fmtmsg.c: Likewise. * intl/bindtextdom.c: Update from latest gettext. * intl/dcgettext.c: Likewise. * intl/finddomain.c: Likewise. * intl/l10nflist.c: Likewise. * intl/localealias.c: Likewise. * intl/textdomain.c: Likewise. * login/getutid_r.c: Remove parameter to setutent call. * login/getutline_r.c: Likewise. * posix/wordexp.c: Complete rewrite. Not fully implemented yet, though. Patch by Tim Waugh <tim@cyberelk.demon.co.uk>. * stdio-common/printf_fp.c: Remove relative include paths. * stdio-common/printf_fphex.c: Likewise. * sysdeps/generic/crypt.h: Cleanup. Don't define non standard elements unless __USE_GNU. * sysdeps/generic/vlimit.c: Pretty print. * sysdeps/generic/vtimes.c: Likewise. * sysdeps/i386/elf/bsd-_setjmp.S: New file. Empty dummy file. * sysdeps/i386/elf/bsd-setjmp.S: New file. Empty dummy file. * sysdeps/i386/elf/setjmp.S: New file. Define __setjmp and also weak definitions of setjmp and _setjmp. * sysdeps/i386/fpu/bits/mathinline.h: More patches by John Bowman. * sysdeps/stub/if_index.h: Set errno in all functions and add stub warnings. * sysdeps/stub/libc-lock.h: Add __libc_once. 1997-08-02 01:57 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/ptrace.c: Don't set errno in error case since the __syscall_ptrace call already did this. Reported by Philip Gladstone <philip@talon.raptor.com>. 1997-07-29 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/sys/fsuid.h: Change include <gnu/types.h> to <sys/types.h>. 1997-08-01 23:18 Ulrich Drepper <drepper@cygnus.com> * csu/defs.awk: Fix regexp for end and align. Patch by Klaus Espenlaub <kespenla@hydra.informatik.uni-ulm.de>. * locale/programs/localedef.c (print_escaped): New function. (show_info): Use print_escaped if strings can control unprintable characters. Patch by Jochen Hein <jochen.hein@delphi.central.de>. 1997-08-01 18:45 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * nis/nss_nisplus/nisplus-alias.c: Fix NULL pointer problems * nis/nss_nisplus/nisplus-grp.c: Likewise. 1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/dl-profile.c (_dl_start_profile): Use _dl_sysdep_error instead of fprintf. 1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * manual/socket.texi (Host Address Functions): Fix arguments of @deftypefun. 1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/dl-runtime.c: Avoid warning about profile_fixup being unused. * sysdeps/m68k/dl-machine.h: Add support for shared library profiling. 1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * md5-crypt/Makefile (extra-objs): Add onlymd5-crypt.o for dependencies. 1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Make-dist (subdirs): Distribute both aout and elf. 1997-07-31 23:04 Mark Kettenis <kettenis@phys.uva.nl> * login/utmp-private.h: Remove reset argument from backend setutent. * login/getutent_r.c (__setutent): Allways call the setutent function in the daemon backend. (setutent_unknown): Function removed. (getutent_unknown, pututline_unknown): Call __setutent instead of setutent_unknown. * login/utmp_file.c (setutent_file): Removed reset argument. All callers changed. * login/utmp_daemon.c (setutent_daemon): Removed reset argument. All callers changed. Try to open connection even if a previous connection failed, but first check if the sockets exist in the filesystem. * login/utmp_daemon.c (pututline_daemon): Try to open connection before reporting failure. * login/programs/database.c (open_database): Create compatibility file if it does not already exist. Supply mode argument in open calls to guarantee that created files have the proper protection. * login/programs/utmpd.c (main): Remove files created by a previous `bind' before creating sockets. Suggested by a sun <asum@zoology.washington.edu>. 1997-07-29 Andreas Jaeger <aj@arthur.rhein-neckar.de> * math/libm-test.c: Remove unneeded function check_int_exec. * BUGS: Correct typos. * gmon/gmon.c: Add alias for monstartup, declare _strerror_internal. 1997-07-30 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/socket.texi (Host Address Functions): Reformat inet_ntop entry to confirm with expected behaviour of some scripts. * libc.map: Add functions/variables in global namespace, remove wildcards. 1997-07-29 Andreas Jaeger <aj@arthur.rhein-neckar.de> * resolv/libresolv.map: Add variables and routines used by named, nslookup and other bind utils. * libc.map: Likewise. 1997-07-31 00:35 Philip Blundell <Philip.Blundell@pobox.com> * sysdeps/unix/sysv/linux/if_index.c: Rewrite to avoid using /proc filesystem. * inet/test_ifindex.c: New file. * inet/Makefile (tests): Add test_ifindex. 1997-08-01 04:25 Ulrich Drepper <drepper@cygnus.com> * nis/nss_nisplus/nisplus-parser.c: Fix another bug in the parser. Patch by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>. * manual/errno.texi: Fix typo. Reported by Erik Talvola <etalvo@sapient.com>. (write_hist): Remove dependency on 32 bit int.
Diffstat (limited to 'login')
-rw-r--r--login/getutent_r.c54
-rw-r--r--login/getutid_r.c4
-rw-r--r--login/getutline_r.c4
-rw-r--r--login/programs/database.c5
-rw-r--r--login/programs/utmpd.c5
-rw-r--r--login/utmp-private.h5
-rw-r--r--login/utmp_daemon.c35
-rw-r--r--login/utmp_file.c51
8 files changed, 76 insertions, 87 deletions
diff --git a/login/getutent_r.c b/login/getutent_r.c
index a50e278..ed4c330 100644
--- a/login/getutent_r.c
+++ b/login/getutent_r.c
@@ -29,9 +29,9 @@
/* The various backends we have. */
-static int setutent_unknown (int reset);
static int getutent_r_unknown (struct utmp *buffer, struct utmp **result);
static struct utmp *pututline_unknown (const struct utmp *data);
+static void setutent_unknown (void);
static void endutent_unknown (void);
/* Initial Jump table. */
@@ -58,7 +58,7 @@ __setutent (void)
{
__libc_lock_lock (__libc_utmp_lock);
- (void) (*__libc_utmp_jump_table->setutent) (1);
+ (*__libc_utmp_jump_table->setutent) ();
__libc_lock_unlock (__libc_utmp_lock);
}
@@ -66,36 +66,6 @@ weak_alias (__setutent, setutent)
weak_alias (__setutent, setutxent)
-static int
-setutent_unknown (int reset)
-{
- /* We have to test whether it is still not decided which backend to use. */
- assert (__libc_utmp_jump_table == &__libc_utmp_unknown_functions);
-
- /* See whether utmpd is running. */
- if ((*__libc_utmp_daemon_functions.setutent) (reset))
- __libc_utmp_jump_table = &__libc_utmp_daemon_functions;
- else
- {
- /* Use the normal file, but if the current file is _PATH_UTMP or
- _PATH_WTMP and the corresponding extended file (with an extra
- 'x' added to the pathname) exists, we use the extended file,
- because the original file is in a different format. */
- if (strcmp (__libc_utmp_file_name, _PATH_UTMP) == 0
- && __access (_PATH_UTMP "x", F_OK) == 0)
- __utmpname (_PATH_UTMP "x");
- else if (strcmp (__libc_utmp_file_name, _PATH_WTMP) == 0
- && __access (_PATH_WTMP "x", F_OK) == 0)
- __utmpname (_PATH_WTMP "x");
-
- (*__libc_utmp_file_functions.setutent) (reset);
- __libc_utmp_jump_table = &__libc_utmp_file_functions;
- }
-
- return 0;
-}
-
-
void
__endutent (void)
{
@@ -110,6 +80,20 @@ weak_alias (__endutent, endutxent)
static void
+setutent_unknown (void)
+{
+ /* See whether utmpd is running. */
+ if ((*__libc_utmp_daemon_functions.setutent) ())
+ __libc_utmp_jump_table = &__libc_utmp_daemon_functions;
+ else
+ {
+ (*__libc_utmp_file_functions.setutent) ();
+ __libc_utmp_jump_table = &__libc_utmp_file_functions;
+ }
+}
+
+
+static void
endutent_unknown (void)
{
/* Huh, how do we came here? Nothing to do. */
@@ -136,7 +120,7 @@ static int
getutent_r_unknown (struct utmp *buffer, struct utmp **result)
{
/* It is not yet initialized. */
- setutent_unknown (0);
+ __setutent ();
return (*__libc_utmp_jump_table->getutent_r) (buffer, result);
}
@@ -158,12 +142,12 @@ __pututline (const struct utmp *data)
weak_alias (__pututline, pututline)
weak_alias (__pututline, pututxline)
-
+
static struct utmp *
pututline_unknown (const struct utmp *data)
{
/* It is not yet initialized. */
- setutent_unknown (0);
+ __setutent ();
return (*__libc_utmp_jump_table->pututline) (data);
}
diff --git a/login/getutid_r.c b/login/getutid_r.c
index ee3a39a..90b75b8 100644
--- a/login/getutid_r.c
+++ b/login/getutid_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>
and Paul Janzen <pcj@primenet.com>, 1996.
@@ -55,7 +55,7 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result)
__libc_lock_lock (__libc_utmp_lock);
/* Not yet initialized. */
- if ((*__libc_utmp_jump_table->setutent) (0))
+ if ((*__libc_utmp_jump_table->setutent) ())
retval = (*__libc_utmp_jump_table->getutid_r) (id, buffer, result);
else
*result = NULL;
diff --git a/login/getutline_r.c b/login/getutline_r.c
index 9b4180f..a1bdc0b 100644
--- a/login/getutline_r.c
+++ b/login/getutline_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>
and Paul Janzen <pcj@primenet.com>, 1996.
@@ -43,7 +43,7 @@ __getutline_r (const struct utmp *line, struct utmp *buffer,
__libc_lock_lock (__libc_utmp_lock);
/* Not yet initialized. */
- if ((*__libc_utmp_jump_table->setutent) (0))
+ if ((*__libc_utmp_jump_table->setutent) ())
retval = (*__libc_utmp_jump_table->getutline_r) (line, buffer, result);
else
*result = NULL;
diff --git a/login/programs/database.c b/login/programs/database.c
index 087ec54..00d573f 100644
--- a/login/programs/database.c
+++ b/login/programs/database.c
@@ -52,6 +52,7 @@ static int get_mtime (int filedes, time_t *timer);
utmp_database *
open_database (const char *file, const char *old_file)
{
+ mode_t mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH;
utmp_database *database;
/* Allocate memory. */
@@ -65,7 +66,7 @@ open_database (const char *file, const char *old_file)
memset (database, 0, sizeof (utmp_database));
/* Open database, create it if it doesn't exist already. */
- database->fd = open (file, O_RDWR | O_CREAT);
+ database->fd = open (file, O_RDWR | O_CREAT, mode);
if (database->fd < 0)
{
error (0, errno, "%s", file);
@@ -81,7 +82,7 @@ open_database (const char *file, const char *old_file)
if (old_file)
{
- database->old_fd = open (old_file, O_RDWR);
+ database->old_fd = open (old_file, O_RDWR|O_CREAT, mode);
if (database->old_fd < 0)
{
error (0, errno, "%s", old_file);
diff --git a/login/programs/utmpd.c b/login/programs/utmpd.c
index 1469d94..e0648eb 100644
--- a/login/programs/utmpd.c
+++ b/login/programs/utmpd.c
@@ -141,6 +141,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
if (check_pid (_PATH_UTMPDPID))
error (EXIT_FAILURE, 0, _("already running"));
+ /* Cleanup files created by a previous `bind'. */
+ unlink (_PATH_UTMPD_RO);
+ unlink (_PATH_UTMPD_RW);
+
/* Open UTMP database. */
utmp_db = open_database (_PATH_UTMP "x", _PATH_UTMP);
if (utmp_db == NULL)
@@ -248,6 +252,7 @@ make_socket (const char *name)
size = (offsetof (struct sockaddr_un, sun_path)
+ strlen (addr.sun_path));
+
if (bind (sock, (struct sockaddr *) &addr, size) < 0)
error (EXIT_FAILURE, errno, "%s", name);
diff --git a/login/utmp-private.h b/login/utmp-private.h
index 87860d5..531d058 100644
--- a/login/utmp-private.h
+++ b/login/utmp-private.h
@@ -24,11 +24,10 @@
#include <utmp.h>
-/* The extra `int' argument for each function shows whether locking is
- wanted or not. */
+/* The structure describing the functions in a backend. */
struct utfuncs
{
- int (*setutent) (int);
+ int (*setutent) (void);
int (*getutent_r) (struct utmp *, struct utmp **);
int (*getutid_r) (const struct utmp *, struct utmp *, struct utmp **);
int (*getutline_r) (const struct utmp *, struct utmp *, struct utmp **);
diff --git a/login/utmp_daemon.c b/login/utmp_daemon.c
index e0a20e9..5907e06 100644
--- a/login/utmp_daemon.c
+++ b/login/utmp_daemon.c
@@ -35,7 +35,7 @@ static int daemon_sock = INT_MIN;
/* Functions defined here. */
-static int setutent_daemon (int reset);
+static int setutent_daemon (void);
static int getutent_r_daemon (struct utmp *buffer, struct utmp **result);
static int getutid_r_daemon (const struct utmp *line, struct utmp *buffer,
struct utmp **result);
@@ -74,9 +74,13 @@ static int send_request (int sock, const request_header *request,
static int
-setutent_daemon (int reset)
+setutent_daemon (void)
{
- if (daemon_sock == INT_MIN)
+ if (access (_PATH_UTMPD_RW, F_OK) == -1
+ && access (_PATH_UTMPD_RO, F_OK) == -1)
+ return 0;
+
+ if (daemon_sock < 0)
{
daemon_sock = open_socket (_PATH_UTMPD_RW);
if (daemon_sock < 0)
@@ -86,18 +90,12 @@ setutent_daemon (int reset)
if (daemon_sock < 0)
return 0;
}
-
- /* Send request to the daemon. */
- if (do_setutent (daemon_sock) < 0)
- return 0;
- }
- else if (reset)
- {
- /* Send request to the daemon. */
- if (do_setutent (daemon_sock) < 0)
- return 0;
}
+ /* Send request to the daemon. */
+ if (do_setutent (daemon_sock) < 0)
+ return 0;
+
return 1;
}
@@ -121,7 +119,7 @@ getutent_r_daemon (struct utmp *buffer, struct utmp **result)
{
/* Open connection if not already done. */
if (daemon_sock == INT_MIN)
- setutent_daemon (1);
+ setutent_daemon ();
if (daemon_sock < 0)
{
@@ -189,9 +187,9 @@ getutid_r_daemon (const struct utmp *id, struct utmp *buffer,
static struct utmp *
pututline_daemon (const struct utmp *utmp)
{
+ /* Open connection if not already done. */
if (daemon_sock == INT_MIN)
- /* The connection is closed. Open it again. */
- setutent_daemon (0);
+ setutent_daemon ();
if (daemon_sock < 0)
/* Something went wrong. */
@@ -217,7 +215,10 @@ updwtmp_daemon (const char *file, const struct utmp *utmp)
/* Send request to the daemon. */
if (do_updwtmp (sock, file, utmp) < 0)
- return -1;
+ {
+ close (sock);
+ return -1;
+ }
close (sock);
return 0;
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 4e218d8..6d6e05b 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -39,7 +39,7 @@ static struct utmp last_entry;
/* Functions defined here. */
-static int setutent_file (int reset);
+static int setutent_file (void);
static int getutent_r_file (struct utmp *buffer, struct utmp **result);
static int getutid_r_file (const struct utmp *key, struct utmp *buffer,
struct utmp **result);
@@ -63,41 +63,40 @@ struct utfuncs __libc_utmp_file_functions =
static int
-setutent_file (int reset)
+setutent_file (void)
{
- if (file_fd == INT_MIN)
+ if (file_fd < 0)
{
- file_fd = open (__libc_utmp_file_name, O_RDWR);
+ const char *file_name = __libc_utmp_file_name;
+
+ if (strcmp (__libc_utmp_file_name, _PATH_UTMP) == 0
+ && __access (_PATH_UTMP "x", F_OK) == 0)
+ file_name = _PATH_UTMP "x";
+ else if (strcmp (__libc_utmp_file_name, _PATH_WTMP) == 0
+ && __access (_PATH_WTMP "x", F_OK) == 0)
+ file_name = _PATH_WTMP "x";
+
+ file_fd = open (file_name, O_RDWR);
if (file_fd == -1)
{
/* Hhm, read-write access did not work. Try read-only. */
- file_fd = open (__libc_utmp_file_name, O_RDONLY);
+ file_fd = open (file_name, O_RDONLY);
if (file_fd == -1)
{
perror (_("while opening UTMP file"));
return 0;
}
}
- file_offset = 0;
-
-#if _HAVE_UT_TYPE - 0
- /* Make sure the entry won't match. */
- last_entry.ut_type = -1;
-#endif
}
- else if (reset)
- {
- lseek (file_fd, 0, SEEK_SET);
- /* Remember we are at beginning of file. */
- file_offset = 0;
+ lseek (file_fd, 0, SEEK_SET);
+ file_offset = 0;
#if _HAVE_UT_TYPE - 0
- /* Make sure the entry won't match. */
- last_entry.ut_type = -1;
+ /* Make sure the entry won't match. */
+ last_entry.ut_type = -1;
#endif
- }
-
+
return 1;
}
@@ -120,7 +119,7 @@ getutent_r_file (struct utmp *buffer, struct utmp **result)
/* Open utmp file if not already done. */
if (file_fd == INT_MIN)
- setutent_file (1);
+ setutent_file ();
if (file_fd == -1 || file_offset == -1l)
{
@@ -348,14 +347,14 @@ pututline_file (const struct utmp *data)
struct utmp *pbuf;
int found;
- if (file_fd < 0)
+ /* Open utmp file if not already done. */
+ if (file_fd == INT_MIN)
+ setutent_file ();
+
+ if (file_fd == -1)
/* Something went wrong. */
return NULL;
- if (file_fd == INT_MIN)
- /* The file is closed. Open it again. */
- setutent_file (0);
-
/* Find the correct place to insert the data. */
if (file_offset > 0
&& (