summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjimb <jimb@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2007-08-18 05:37:11 +0000
committerjimb <jimb@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2007-08-18 05:37:11 +0000
commitea7f5cc64354d6a83ba39b11403884748760c2db (patch)
treeca4dc73764cfdcce8fb96802037e40b48e9fa7db
parent1ad03c7a88f7c50e5ad8d563a6a9e09b8704c6ed (diff)
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. git-svn-id: svn://svn.eglibc.org/trunk@3185 7b3dc134-2b1b-0410-93df-9e9f96275f8d
-rw-r--r--libc/ChangeLog.eglibc28
-rw-r--r--libc/Makerules1
-rw-r--r--libc/debug/Makefile5
-rw-r--r--libc/login/Makefile14
-rw-r--r--libc/option-groups.def62
-rw-r--r--libc/option-groups.defaults3
-rw-r--r--libc/posix/Makefile8
-rw-r--r--libc/posix/glob.c18
-rw-r--r--libc/sysdeps/gnu/Makefile3
9 files changed, 125 insertions, 17 deletions
diff --git a/libc/ChangeLog.eglibc b/libc/ChangeLog.eglibc
index b47152330..f452f206f 100644
--- a/libc/ChangeLog.eglibc
+++ b/libc/ChangeLog.eglibc
@@ -1,5 +1,33 @@
2007-08-17 Jim Blandy <jimb@codesourcery.com>
+ 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.
+
Implement the OPTION_EGLIBC_SPAWN option group.
* option-groups.def (OPTION_EGLIBC_SPAWN): New entry.
diff --git a/libc/Makerules b/libc/Makerules
index a3327566d..72dde69d0 100644
--- a/libc/Makerules
+++ b/libc/Makerules
@@ -417,6 +417,7 @@ modules += $(modules-y)
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)
diff --git a/libc/debug/Makefile b/libc/debug/Makefile
index b9902cb4b..209a76893 100644
--- a/libc/debug/Makefile
+++ b/libc/debug/Makefile
@@ -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 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \
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
diff --git a/libc/login/Makefile b/libc/login/Makefile
index 2e414a3ee..097f84e62 100644
--- a/libc/login/Makefile
+++ b/libc/login/Makefile
@@ -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 @@ vpath %.c programs
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
diff --git a/libc/option-groups.def b/libc/option-groups.def
index 4ec45d6fd..b2e963c9a 100644
--- a/libc/option-groups.def
+++ b/libc/option-groups.def
@@ -144,6 +144,18 @@ config OPTION_EGLIBC_FSTAB
getfsent setfsent
getfsfile
+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
@@ -463,6 +475,56 @@ config OPTION_EGLIBC_SUNRPC
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
diff --git a/libc/option-groups.defaults b/libc/option-groups.defaults
index 1d88f0ab8..378a0f8ae 100644
--- a/libc/option-groups.defaults
+++ b/libc/option-groups.defaults
@@ -12,6 +12,7 @@ OPTION_EGLIBC_CATGETS = y
OPTION_EGLIBC_CHARSETS = y
OPTION_EGLIBC_ENVZ = y
OPTION_EGLIBC_FSTAB = y
+OPTION_EGLIBC_GETLOGIN = y
OPTION_EGLIBC_INET = y
OPTION_EGLIBC_LIBM = y
OPTION_EGLIBC_LOCALES = y
@@ -21,4 +22,6 @@ OPTION_EGLIBC_NSSWITCH = y
OPTION_EGLIBC_RCMD = y
OPTION_EGLIBC_SPAWN = y
OPTION_EGLIBC_SUNRPC = y
+OPTION_EGLIBC_UTMP = y
+OPTION_EGLIBC_UTMPX = y
OPTION_POSIX_REGEXP = y
diff --git a/libc/posix/Makefile b/libc/posix/Makefile
index de9a617da..e858c4f57 100644
--- a/libc/posix/Makefile
+++ b/libc/posix/Makefile
@@ -50,7 +50,7 @@ routines := \
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 \
@@ -73,6 +73,7 @@ routines-$(OPTION_EGLIBC_SPAWN) += \
spawnattr_getpgroup spawnattr_setpgroup spawn spawnp spawni \
spawnattr_getsigmask spawnattr_getschedpolicy spawnattr_getschedparam \
spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam
+routines-$(OPTION_EGLIBC_GETLOGIN) += getlogin getlogin_r
include ../Makeconfig
@@ -149,6 +150,8 @@ endif
# 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)
@@ -173,7 +176,8 @@ CFLAGS-spawnp.os = -fomit-frame-pointer
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
diff --git a/libc/posix/glob.c b/libc/posix/glob.c
index 6d8a89134..db009819f 100644
--- a/libc/posix/glob.c
+++ b/libc/posix/glob.c
@@ -564,6 +564,7 @@ glob (pattern, flags, errfunc, pglob)
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 @@ glob (pattern, flags, errfunc, pglob)
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 @@ glob (pattern, flags, errfunc, pglob)
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)
diff --git a/libc/sysdeps/gnu/Makefile b/libc/sysdeps/gnu/Makefile
index 5b9a0a56e..1cfc4588a 100644
--- a/libc/sysdeps/gnu/Makefile
+++ b/libc/sysdeps/gnu/Makefile
@@ -62,7 +62,8 @@ $(foreach o,$(object-suffixes) $(object-suffixes:=.d),\
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