[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patches] Implement OPTION_EGLIBC_UTMP, OPTION_EGLIBC_UTMPX, and OPTION_EGLIBC_GETLOGIN
- To: patches@xxxxxxxxxx
- Subject: [patches] Implement OPTION_EGLIBC_UTMP, OPTION_EGLIBC_UTMPX, and OPTION_EGLIBC_GETLOGIN
- From: Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
- Date: Fri, 17 Aug 2007 22:51:57 -0700
I've committed the following:
ChangeLog.eglibc:
2007-08-17 Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
Implement the OPTION_EGLIBC_UTMP, OPTION_EGLIBC_UTMPX, and
OPTION_EGLIBC_GETLOGIN option groups.
* option-groups.def (OPTION_EGLIBC_UTMP, OPTION_EGLIBC_UTMPX)
(OPTION_EGLIBC_GETLOGIN): New entry.
* option-groups.defaults (OPTION_EGLIBC_UTMP, OPTION_EGLIBC_UTMPX)
(OPTION_EGLIBC_GETLOGIN): Initialize.
* Makerules (sysdep_routines): Include value of sysdep_routines-y.
* debug/Makefile: Include option-groups.mak.
(routines): Put getlogin_r_chk in the OPTION_EGLIBC_GETLOGIN group.
* sysdeps/gnu/Makefile (sysdep_routines): For the login
subdirectory, put setutxent, getutxent, endutxent, getutxid,
getutxline, pututxline, utmpxname, updwtmpx, getutmpx, and getutmp
in the OPTION_EGLIBC_UTMPX group.
* login/Makefile: Include option-groups.mak.
(routines): Put getutent, getutent_r, getutid, getutline,
getutid_r, getutline_r, utmp_file, utmpname, and updwtmp in the
OPTION_EGLIBC_UTMP option group.
(others): Put utmpdump in the OPTION_EGLIBC_UTMP group.
(extra-libs): Put libutil in the OPTION_EGLIBC_UTMP group.
(extra-libs-others): Initialize from $(extra-libs-y).
* posix/glob.c (glob): If OPTION_EGLIBC_GETLOGIN is not defined,
don't try to call getlogin to find the username to use for tilde
expansion.
* posix/Makefile (routines): Put getlogin and getlogin_r in the
OPTION_EGLIBC_GETLOGIN group.
(CFLAGS-glob.c): Define OPTION_EGLIBC_GETLOGIN as appropriate.
Index: option-groups.def
===================================================================
--- option-groups.def (revision 3172)
+++ option-groups.def (working copy)
@@ -130,6 +130,18 @@
envz_entry envz_remove
envz_get envz_strip
+config OPTION_EGLIBC_GETLOGIN
+ bool "The getlogin function"
+ depends OPTION_EGLIBC_UTMP
+ help
+ This function group includes the 'getlogin' and 'getlogin_r'
+ functions, which return the user name associated by the login
+ activity with the current process's controlling terminal.
+
+ With this option group disabled, the 'glob' function will not
+ fall back on 'getlogin' to find the user's login name for tilde
+ expansion when the 'HOME' environment variable is not set.
+
config OPTION_EGLIBC_INET
bool "Networking support"
help
@@ -413,6 +425,56 @@
This option group includes support for the Sun RPC protocols,
including the 'rpcgen' and 'rpcinfo' programs.
+config OPTION_EGLIBC_UTMP
+ bool "Older access functions for 'utmp' login records"
+ help
+ This option group includes the older 'utent' family of
+ functions for accessing user login records in the 'utmp' file.
+ POSIX omits these functions in favor of the 'utxent' family,
+ and they are obsolete on systems other than Linux.
+
+ This option group includes the following functions:
+
+ endutent
+ getutent
+ getutent_r
+ getutid
+ getutid_r
+ getutline
+ getutline_r
+ logwtmp
+ pututline
+ setutent
+ updwtmp
+ utmpname
+
+ This option group includes the following libraries:
+
+ libutil.so (and libutil.a)
+
+config OPTION_EGLIBC_UTMPX
+ bool "POSIX access functions for 'utmp' login records"
+ depends OPTION_EGLIBC_UTMP
+ help
+ This option group includes the POSIX functions for reading and
+ writing user login records in the 'utmp' file (usually
+ '/var/run/utmp'). The POSIX functions operate on 'struct
+ utmpx' structures, as opposed to the family of older 'utent'
+ functions, which operate on 'struct utmp' structures.
+
+ This option group includes the following functions:
+
+ endutxent
+ getutmp
+ getutmpx
+ getutxent
+ getutxid
+ getutxline
+ pututxline
+ setutxent
+ updwtmpx
+ utmpxname
+
config OPTION_POSIX_REGEXP
bool "Regular expressions"
help
Index: debug/Makefile
===================================================================
--- debug/Makefile (revision 3172)
+++ debug/Makefile (working copy)
@@ -19,6 +19,8 @@
#
# Sub-makefile for debug portion of the library.
#
+include ../option-groups.mak
+
subdir := debug
headers := execinfo.h
@@ -38,12 +40,13 @@
wcpncpy_chk \
swprintf_chk vswprintf_chk wprintf_chk fwprintf_chk \
vwprintf_chk vfwprintf_chk fgetws_chk fgetws_u_chk \
- confstr_chk getgroups_chk ttyname_r_chk getlogin_r_chk \
+ confstr_chk getgroups_chk ttyname_r_chk \
gethostname_chk getdomainname_chk wcrtomb_chk mbsnrtowcs_chk \
wcsnrtombs_chk mbsrtowcs_chk wcsrtombs_chk mbstowcs_chk \
wcstombs_chk \
stack_chk_fail fortify_fail \
$(static-only-routines)
+routines-$(OPTION_EGLIBC_GETLOGIN) += getlogin_r_chk
static-only-routines := warning-nop stack_chk_fail_local
CFLAGS-backtrace.c = -fno-omit-frame-pointer
Index: sysdeps/gnu/Makefile
===================================================================
--- sysdeps/gnu/Makefile (revision 3172)
+++ sysdeps/gnu/Makefile (working copy)
@@ -62,7 +62,8 @@
endif
ifeq ($(subdir),login)
-sysdep_routines += setutxent getutxent endutxent getutxid getutxline \
+sysdep_routines-$(OPTION_EGLIBC_UTMPX) \
+ += setutxent getutxent endutxent getutxid getutxline \
pututxline utmpxname updwtmpx getutmpx getutmp
sysdep_headers += utmpx.h bits/utmpx.h
Index: Makerules
===================================================================
--- Makerules (revision 3172)
+++ Makerules (working copy)
@@ -417,6 +417,7 @@
others += $(others-y)
routines += $(routines-y)
static-only-routines += $(static-only-routines-y)
+sysdep_routines += $(sysdep_routines-y)
test-srcs += $(test-srcs-y)
tests += $(tests-y)
xtests += $(xtests-y)
Index: option-groups.defaults
===================================================================
--- option-groups.defaults (revision 3172)
+++ option-groups.defaults (working copy)
@@ -11,6 +11,7 @@
OPTION_EGLIBC_CATGETS = y
OPTION_EGLIBC_CHARSETS = y
OPTION_EGLIBC_ENVZ = y
+OPTION_EGLIBC_GETLOGIN = y
OPTION_EGLIBC_INET = y
OPTION_EGLIBC_LIBM = y
OPTION_EGLIBC_LOCALES = y
@@ -19,4 +20,6 @@
OPTION_EGLIBC_NSSWITCH = y
OPTION_EGLIBC_RCMD = y
OPTION_EGLIBC_SUNRPC = y
+OPTION_EGLIBC_UTMP = y
+OPTION_EGLIBC_UTMPX = y
OPTION_POSIX_REGEXP = y
Index: login/Makefile
===================================================================
--- login/Makefile (revision 3172)
+++ login/Makefile (working copy)
@@ -19,17 +19,21 @@
#
# Sub-makefile for login portion of the library.
#
+include ../option-groups.mak
subdir := login
headers := utmp.h bits/utmp.h lastlog.h pty.h
-routines := getutent getutent_r getutid getutline getutid_r getutline_r \
- utmp_file utmpname updwtmp getpt grantpt unlockpt ptsname
+routines := getpt grantpt unlockpt ptsname
+routines-$(OPTION_EGLIBC_UTMP) \
+ += getutent getutent_r getutid getutline getutid_r getutline_r \
+ utmp_file utmpname updwtmp
CFLAGS-grantpt.c = -DLIBEXECDIR='"$(libexecdir)"'
-others = utmpdump pt_chown
+others = pt_chown
+others-$(OPTION_EGLIBC_UTMP) += utmpdump
install-others = $(inst_libexecdir)/pt_chown
distribute := utmp-private.h utmp-equal.h pty-private.h
@@ -40,8 +44,8 @@
tests := tst-utmp tst-utmpx tst-grantpt
# Build the -lutil library with these extra functions.
-extra-libs := libutil
-extra-libs-others := $(extra-libs)
+extra-libs-$(OPTION_EGLIBC_UTMP) := libutil
+extra-libs-others := $(extra-libs-y)
libutil-routines:= login login_tty logout logwtmp openpty forkpty
Index: posix/glob.c
===================================================================
--- posix/glob.c (revision 3172)
+++ posix/glob.c (working copy)
@@ -564,6 +564,7 @@
if (home_dir == NULL || home_dir[0] == '\0')
home_dir = "c:/users/default"; /* poor default */
# else
+# if OPTION_EGLIBC_GETLOGIN
if (home_dir == NULL || home_dir[0] == '\0')
{
int success;
@@ -580,18 +581,18 @@
if (success)
{
struct passwd *p;
-# if defined HAVE_GETPWNAM_R || defined _LIBC
+# if defined HAVE_GETPWNAM_R || defined _LIBC
long int pwbuflen = GETPW_R_SIZE_MAX ();
char *pwtmpbuf;
struct passwd pwbuf;
int save = errno;
-# ifndef _LIBC
+# ifndef _LIBC
if (pwbuflen == -1)
/* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.
Try a moderate value. */
pwbuflen = 1024;
-# endif
+# endif
pwtmpbuf = (char *) __alloca (pwbuflen);
while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)
@@ -602,22 +603,23 @@
p = NULL;
break;
}
-# ifdef _LIBC
+# ifdef _LIBC
pwtmpbuf = extend_alloca (pwtmpbuf, pwbuflen,
2 * pwbuflen);
-# else
+# else
pwbuflen *= 2;
pwtmpbuf = (char *) __alloca (pwbuflen);
-# endif
+# endif
__set_errno (save);
}
-# else
+# else
p = getpwnam (name);
-# endif
+# endif
if (p != NULL)
home_dir = p->pw_dir;
}
}
+# endif /* OPTION_EGLIBC_GETLOGIN */
if (home_dir == NULL || home_dir[0] == '\0')
{
if (flags & GLOB_TILDE_CHECK)
Index: posix/Makefile
===================================================================
--- posix/Makefile (revision 3172)
+++ posix/Makefile (working copy)
@@ -50,7 +50,7 @@
getuid geteuid getgid getegid getgroups setuid setgid group_member \
getpgid setpgid getpgrp bsd-getpgrp setpgrp getsid setsid \
getresuid getresgid setresuid setresgid \
- getlogin getlogin_r setlogin \
+ setlogin \
pathconf sysconf fpathconf \
glob glob64 fnmatch \
confstr \
@@ -72,6 +72,7 @@
routines-$(OPTION_EGLIBC_INET) += getaddrinfo gai_strerror
routines-$(OPTION_POSIX_REGEXP) += regex
+routines-$(OPTION_EGLIBC_GETLOGIN) += getlogin getlogin_r
include ../Makeconfig
@@ -147,6 +148,8 @@
# eglibc: endif
OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+OPTION_EGLIBC_GETLOGIN-CFLAGS-$(OPTION_EGLIBC_GETLOGIN) \
+ = -DOPTION_EGLIBC_GETLOGIN
CFLAGS-regex.c = -Wno-strict-prototypes
CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions $(OPTION_EGLIBC_INET-CFLAGS-y)
@@ -171,7 +174,8 @@
CFLAGS-spawni.c = -fexceptions
CFLAGS-spawni.os = -fomit-frame-pointer
CFLAGS-pause.c = -fexceptions
-CFLAGS-glob.c = $(uses-callbacks) -fexceptions
+CFLAGS-glob.c = $(uses-callbacks) -fexceptions \
+ $(OPTION_EGLIBC_GETLOGIN-CFLAGS-y)
CFLAGS-glob64.c = $(uses-callbacks) -fexceptions
CFLAGS-getconf.c = -DGETCONF_DIR='"$(libexecdir)/getconf"'
CFLAGS-execve.os = -fomit-frame-pointer