glibc/login
Ulrich Drepper 50304ef057 Update.
1998-07-16 10:23  Ulrich Drepper  <drepper@cygnus.com>

	* argp/argp-fmtstream.c: Unify names of used global functions.
	* argp/argp-help.c: Likewise.
	* assert/assert-perr.c: Likewise
	* assert/assert.c: Likewise
	* dirent/scandir.c: Likewise
	* dirent/scandir64.c: Likewise
	* dirent/versionsort.c: Likewise
	* dirent/versionsort64.c: Likewise
	* gmon/bb_exit_func.c: Likewise.
	* gmon/gmon.c: Likewise.
	* grp/initgroups.c: Likewise.
	* iconv/gconv_conf.c: Likewise.
	* inet/getnameinfo.c: Likewise.
	* inet/getnetgrent_r.c: Likewise.
	* inet/inet_ntoa.c: Likewise.
	* inet/rcmd.c: Likewise.
	* inet/rexec.c: Likewise.
	* inet/ruserpass.c: Likewise.
	* io/fts.c: Likewise.
	* io/ftw.c: Likewise.
	* io/ftw64.c: Likewise.
	* io/getdirname.c: Likewise.
	* io/getwd.c: Likewise.
	* io/lockf.c: Likewise.
	* libio/iofdopen.c: Likewise.
	* libio/iopopen.c: Likewise.
	* login/utmp_daemon.c: Likewise.
	* malloc/mtrace.c: Likewise.
	* malloc/obstack.c
	* misc/daemon.c: Likewise.
	* misc/efgcvt_r.c: Likewise.
	* misc/err.c: Likewise.
	* misc/error.c: Likewise.
	* misc/fstab.c: Likewise.
	* misc/getpass.c: Likewise.
	* misc/getttyent.c: Likewise.
	* misc/mntent_r.c: Likewise.
	* misc/search.h: Likewise.
	* misc/syslog.c: Likewise.
	* nscd/nscd_getgr_r.c: Likewise.
	* nscd/nscd_getpw_r.c: Likewise.
	* posix/getpgrp.c: Likewise.
	* posix/wordexp.c: Likewise.
	* pwd/fgetpwent_r.c: Likewise.
	* pwd/getpw.c: Likewise.
	* resolv/herror.c: Likewise.
	* resolv/res_init.c: Likewise.
	* shadow/fgetspent_r.c: Likewise.
	* shadow/lckpwdf.c: Likewise.
	* signal/sigrelse.c: Likewise.
	* stdio-common/asprintf.c: Likewise.
	* stdio-common/dprintf.c: Likewise.
	* stdio-common/getw.c: Likewise.
	* stdio-common/putw.c: Likewise.
	* stdio-common/snprintf.c: Likewise.
	* stdio-common/sprintf.c: Likewise.
	* stdio-common/sscanf.c: Likewise.
	* stdlib/lrand48_r.c: Likewise.
	* stdlib/mrand48_r.c: Likewise.
	* string/argz-replace.c: Likewise.
	* string/envz.c: Likewise.
	* sunrpc/auth_des.c: Likewise.
	* sunrpc/auth_unix.c: Likewise.
	* sunrpc/bindrsvprt.c: Likewise.
	* sunrpc/clnt_gen.c: Likewise.
	* sunrpc/clnt_perr.c: Likewise.
	* sunrpc/clnt_simp.c: Likewise.
	* sunrpc/clnt_tcp.c: Likewise.
	* sunrpc/clnt_udp.c: Likewise.
	* sunrpc/get_myaddr.c: Likewise.
	* sunrpc/key_call.c: Likewise.
	* sunrpc/netname.c: Likewise.
	* sunrpc/openchild.c: Likewise.
	* sunrpc/pmap_rmt.c: Likewise.
	* sunrpc/rpc_dtable.c: Likewise.
	* sunrpc/rtime.c: Likewise.
	* sunrpc/svc_run.c: Likewise.
	* sunrpc/svc_simple.c: Likewise.
	* sunrpc/svc_tcp.c: Likewise.
	* sunrpc/svc_udp.c: Likewise.
	* sunrpc/svcauth_des.c: Likewise.
	* sunrpc/xdr_array.c: Likewise.
	* sunrpc/xdr_rec.c: Likewise.
	* sunrpc/xdr_ref.c: Likewise.
	* sunrpc/xdr_stdio.c: Likewise.
	* sysdeps/generic/abort.c: Likewise.
	* sysdeps/generic/dl-sysdep.c: Likewise.
	* sysdeps/generic/fstatfs64.c: Likewise.
	* sysdeps/generic/ftruncate64.c: Likewise.
	* sysdeps/generic/getrlimit64.c: Likewise.
	* sysdeps/generic/glob.c: Likewise.
	* sysdeps/generic/prof-freq.c: Likewise.
	* sysdeps/generic/putenv.c: Likewise.
	* sysdeps/generic/statfs64.c: Likewise.
	* sysdeps/generic/ttyname_r.c: Likewise.
	* sysdeps/generic/utmp_file.c: Likewise.
	* sysdeps/generic/vlimit.c: Likewise.
	* sysdeps/generic/vtimes.c: Likewise.
	* sysdeps/posix/cuserid.c: Likewise.
	* sysdeps/posix/euidaccess.c: Likewise.
	* sysdeps/posix/mkstemp.c: Likewise.
	* sysdeps/posix/mktemp.c: Likewise.
	* sysdeps/posix/pread.c: Likewise.
	* sysdeps/posix/pread64.c: Likewise.
	* sysdeps/posix/profil.c: Likewise.
	* sysdeps/posix/pwrite.c: Likewise.
	* sysdeps/posix/pwrite64.c: Likewise.
	* sysdeps/posix/sigblock.c: Likewise.
	* sysdeps/posix/sigpause.c: Likewise.
	* sysdeps/posix/ttyname.c: Likewise.
	* sysdeps/posix/ttyname_r.c: Likewise.
	* sysdeps/posix/waitid.c: Likewise.
	* sysdeps/unix/getlogin_r.c: Likewise.
	* sysdeps/unix/grantpt.c: Likewise.
	* sysdeps/unix/rewinddir.c: Likewise.
	* sysdeps/unix/sysv/linux/gethostid.c: Likewise.
	* sysdeps/unix/sysv/linux/getpt.c: Likewise.
	* sysdeps/unix/sysv/linux/if_index.c: Likewise.
	* sysdeps/unix/sysv/linux/ptsname.c: Likewise.
	* sysdeps/unix/sysv/linux/sendmsg.c: Likewise.
	* sysdeps/unix/sysv/linux/statvfs.c: Likewise.
	* sysdeps/unix/sysv/linux/ttyname.c: Likewise.
	* sysdeps/unix/sysv/linux/ttyname_r.c: Likewise.
	* sysdeps/unix/sysv/linux/ulimit.c: Likewise.
	* sysdeps/unix/sysv/linux/unlockpt.c: Likewise.
	* sysvipc/sys/shm.h: Likewise.
	* time/ctime_r.c: Likewise.
	* time/strptime.c: Likewise.
	* wcsmbs/mbrlen.c: Likewise.
	* wcsmbs/wcsdup.c: Likewise.
	* wcsmbs/wcsxfrm.c: Likewise.
	* wctype/wcfuncs.c: Likewise.

	* sysdeps/unix/sysv/linux/i386/socker.S: Change to honor NO_WEAK_ALIAS.
	* sysdeps/unix/sysv/linux/accept.S: Don't generate __ name.
	* sysdeps/unix/sysv/linux/bind.S: Likewise.
	* sysdeps/unix/sysv/linux/getsockname.S: Likewise.
	* sysdeps/unix/sysv/linux/listen.S: Likewise.
	* sysdeps/unix/sysv/linux/recvfrom.S: Likewise.
	* sysdeps/unix/sysv/linux/sendto.S: Likewise.
	* sysdeps/unix/sysv/linux/setsockopt.S: Likewise.

	* grp/fgetgrent_r.c: Use explicit locking of the stream.

	* elf/Makefile (rtld-routines): Add dl-environ.
	* sysdeps/generic/dl-environ.c: New file.

	* libio/Makefile [REENTRANT] (routines): Add iofputs_u.
	* libio/Versions: Add fputs_unlocked.
	* libio/iofputs_u.c: New file.
	* libio/stdio.h: Add prototype for fputs_unlocked.

	* sunrpc/rpc/auth.h: Use __PMT instead of __P in type definitions.
	* sunrpc/rpc/clnt.h: Likewise.
	* sunrpc/rpc/pmap_clnt.h: Likewise.
	* sunrpc/rpc/svc.h: Likewise.
	* sunrpc/rpc/xdr.h: Likewise.

	* sysdeps/i386/memchr.S: Correct for more strict gas.
	* sysdeps/i386/fpu/bits/mathinline.h: Likewise.
	* sysdeps/libm-i387/i686/s_fdim.S: Likewise.
	* sysdeps/libm-i387/i686/s_fdimf.S: Likewise.
	* sysdeps/libm-i387/i686/s_fdiml.S: Likewise.

1998-07-15  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* configure.in: Change message for binutils version from
	2.8.1.0.17->2.8.1.0.23.

1998-07-15  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h: Define LOC.
	Patch by John Tobey <jtobey@banta-im.com>.
1998-07-16 11:44:36 +00:00
..
programs Update. 1998-06-29 12:44:22 +00:00
forkpty.c Update. 1998-01-30 11:44:34 +00:00
getutent_r.c Update. 1998-04-20 18:41:05 +00:00
getutent.c Update. 1998-04-20 18:41:05 +00:00
getutid_r.c Update. 1997-08-10 18:37:15 +00:00
getutid.c Update. 1998-04-20 18:41:05 +00:00
getutline_r.c Update. 1997-08-10 18:37:15 +00:00
getutline.c Update. 1998-04-20 18:41:05 +00:00
lastlog.h Update. 1997-06-21 02:59:26 +00:00
login_tty.c update from main archive 961001 1996-10-02 01:40:17 +00:00
login.c Update. 1998-06-02 12:58:14 +00:00
logout.c Update. 1997-08-10 18:37:15 +00:00
logwtmp.c Update. 1997-05-29 12:06:58 +00:00
Makefile Update. 1998-06-02 12:58:14 +00:00
openpty.c Update. 1998-04-07 09:21:28 +00:00
pty-internal.h Update. 1998-01-30 11:44:34 +00:00
pty.h Update. 1997-11-26 04:23:08 +00:00
README.utmpd Update. 1998-05-15 14:46:36 +00:00
tst-utmp.c Update. 1998-06-02 12:58:14 +00:00
tst-utmpx.c Update. 1998-06-02 12:58:14 +00:00
utmp_daemon.c Update. 1998-07-16 11:44:36 +00:00
utmp-private.h Update. 1997-08-02 21:00:51 +00:00
utmp.h Update. 1998-04-20 18:41:05 +00:00
utmpname.c Update. 1997-08-10 18:37:15 +00:00
Versions Update. 1998-07-02 22:51:40 +00:00

With the introduction of version 2 of the GNU C Library the format of
the UTMP and WTMP files changed for some configurations (see Q&A `Why
does getlogin() always return NULL on my Linux box?' of the FAQ).
This version of the GNU C Library contains a solution for the problems
this may cause, by providing an UTMP daemon `utmpd'.

Do I need it?
=============

If your configuration is one of the following:

                i[3456]86-*-linux-gnu    Linux-2.0 on Intel
                m68k-*-linux-gnu         Linux-2.0 on Motorola 680x0

you might need it, so please read on.  If it is not, please read the
section titled `Programming' at the end of this text.

In principle, you only need the daemon if you want to keep using old
programs linked against the previous version of the Linux C Library
(libc5).  In addition you will need the daemon if you are running
Linux on Intel, and you are planning to use iBCS (Intel Binary
Compatibility Standard).  If you have no libc5 programs left on your
system and you are not using iBCS, it is probably better not to
install the daemon since it uses (a small amount of) memory and CPU
time.  But apart from that it shouldn't hurt to install `utmpd', so
when in doubt install it anyway.


Installation
============

The installation process (`make install') already places the `utmpd'
binary in $(sbindir).  The only thing you have to do is modifying your
startup scripts to start the daemon.  Unfortunately this is a bit of a
hassle, since the layout of these scripts is not standardized.  You
should try to find the command that creates the file `/var/run/utmp'.
This is usually done in a script named `/etc/rc', `/etc/init.d/boot'
(Debian) or `/etc/rc.d/rc.S' (Slackware).  You could try:

     grep utmp /etc/* /etc/init.d/* /etc/rc.d/*

to find the right script.  The creation of `/var/run/utmp' is usually
done with a command like:

     : > /var/run/utmp

or

     cat /dev/null > /var/run/utmp

Now add a line before this command to create the file `/var/run/utmpx'
e.g.

     : > /var/run/utmpx

or

     cat /dev/null > /var/run/utmpx

whatever you prefer, and after this command, add a line to start the
daemon

     utmpd

The entire fragment could look something like

     # Clean up /var/run and create /var/run/utmp so that we can login.
     ( cd /var/run && find . ! -type d -exec rm -f -- {} \; )
     : > /var/run/utmpx
     : > /var/run/utmp
     utmpd

If the file `/var/log/wtmp' exists on your system, you will probably
want to create the file `/var/log/wtmpx'.  Programs linked against the
GNU C Library will now write to `/var/log/wtmpx', while programs
linked against the old library will continue to write to
`/var/log/wtmp'.  Of course this means that the information gets
spread over two files.  We hope to provide a better solution in the
future.

After a reboot, user accounting should be working again.  If not,
please refer to the section titled `Troubleshooting' below before
submitting a bug report.


What is `utmpd' doing?
======================

After installation there will be two files that store the user
accounting information: `/var/run/utmp' and `/var/run/utmpx'.  The
file `/var/run/utmp' will be in the old format so libc5 programs will
continue to work (even if they are broken and do not use the library
functions to access the user accounting database).  And on Intel, you
can safely link `/var/run/utmp' to `/etc/utmp' for iBCS programs.
Programs linked against the new GNU C Library (glibc2) will contact
the daemon for all user accounting database access.  The daemon will
store its information in `/var/run/utmpx' and keeps this file in sync
with `/var/run/utmp'.  Entries added to `/var/run/utmpx' will be
converted to the old format and will be added to `/var/run/utmp' and
vice versa.  This way both libc5 and glibc2 see the same information
in the same fields of `struct utmp'. Of course libc5 programs see only
part of the information that glibc2 programs see because not all
members of the glibc2 `struct utmp' are present in the libc5 `struct
utmp'.  For the same reason libc5 will see a truncated version of
those fields where the length of the glibc2 field is larger than the
corresponding libc5 field (ut_user, ut_line, ut_host).


Troubleshooting
===============

If user accounting is not working on your system, e.g. programs like
`who' or `logname' return rubbish, or you cannot login, make
sure that:

*  The file `/var/run/utmpx' exists.

*  The file `/var/log/wtmpx' exists.

*  No program linked against the GNU C Library (libc6) is accessing
   `/var/run/utmp' directly (see the section on `Programming' below).

If that does not solve your problems, please use the `glibcbug' script
to report the problem to <bugs@gnu.org>.

The `utmpd' daemon uses `syslogd' to report problems.  It uses the
`daemon' facility and `warning' and `error' levels.  Alternatively you
could use the following option to ease debugging:

`--debug'
    Use this option if you want the daemon to output its warnings and
    error messages to the terminal instead of sending them to the
    system logger (`syslogd').  When using this option the daemon does
    not auto-background itself.

To use this option you should first kill the daemon that is already
running, and start a fresh one with the desired option:

    kill `cat /var/run/utmpd.pid`
    utmpd --debug

Please include any warnings or error messages from `utmpd' in your
bug reports.


Programming
===========

In order for the `utmpd' approach to work it is essential that NO
program EVER accesses the UTMP and WTMP files directly.  Instead, a
program should use ONLY the available library functions:

     * utmpname()	Select the database used (UTMP, WTMP, ...).
     * setutent()	Open the database.
     * getutent()	Read the next entry from the database.
     * getutid()	Search for the next entry with a specific ID.
     * getutline()	Search for the next entry for a specific line.
     * pututline()	Write an entry to the database.
     * endutent()	Close the database.
     * updwtmp()	Add an entry to a database (WTMP, ...).

For details, please refer to `The GNU C Library Reference Manual',
which also contains information about some additional functions
derived from BSD and XPG that may be of interest.  The command

    info libc "User Accounting Database"

should point you at the right location.

If you encounter a program that reads from or, even worse, writes to
the UTMP and WTMP files directly, please report this as a bug to the
author of that program.  Note that the files referred to by the macros
`_PATH_UTMP' and `_PATH_WTMP' might even disappear in the future, so
please do not use these, except in a call to `utmpname()' or
`updwtmp()', not even to check their existence.