summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-06-22 17:08:51 +0000
committerUlrich Drepper <drepper@redhat.com>1998-06-22 17:08:51 +0000
commita53bad166c677459239011bcb3275b87c8c38584 (patch)
treec02a4e897a0cc8505b96167e1c5343c4a8246fe5
parent899d423eaf3f66e59ffffefe40b2ba2137bd0050 (diff)
Update.
1998-06-22 17:02 Ulrich Drepper <drepper@cygnus.com> * sysdeps/generic/enbl-secure.c: Don't use __libc_uid. * sysdeps/unix/sysv/linux/aio_sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/init-first.c: Don't initialize __libc_uid. 1998-06-02 Gordon Matzigkeit <gord@profitpress.com> * mach/Makefile: Change `mv' invocations to `mv -f'. * mach/Machrules: Likewise. 1998-06-22 Andreas Jaeger <aj@arthur.rhein-neckar.de> * config.make.in (old-glibc-headers): Add it. * configure.in: Add test for glibc 2.0.x headers. * Makefile (headers2_0): New variable - contains so far only Linux/Intel glibc 2.0.x headers. (remove-old-headers): New rule to remove headers from glibc 2.0.x. (install): Depend on remove-old-headers. 1998-06-19 Mark Kettenis <kettenis@phys.uva.nl> * sysdeps/generic/ftruncate.c: Define function as __ftruncate and make ftruncate a weak alias. * sysdeps/mach/hurd/ftruncate.c: Really define function as __ftruncate. * sysdeps/mach/hurd/truncate.c: Include <unistd.h>. (truncate): Fix function defenition to match prototype. 1998-06-20 Mark Kettenis <kettenis@phys.uva.nl> * manual/terminal.texi: Document ttyname_r, getpt, grantpt, unlockpt, ptsname, ptsname_r, openpty and forkpty. 1998-06-22 Ulrich Drepper <drepper@cygnus.com> * sysdeps/generic/glob.c: Make it possible to include glob.h before loading glob.c. Reported by Felix von Leitner <leitner@math.fu-berlin.de>. 1998-06-22 Andreas Jaeger <aj@arthur.rhein-neckar.de> * nscd/connections.c: Use poll() instead of select(). 1998-06-22 14:08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/generic/Dist: Fix typo. 1998-06-20 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * nis/nis_add.c: Avoid unnecessary strlen () calls. * nis/nis_addmember.c: Likewise. * nis/nis_call.c: Likewise. * nis/nis_creategroup.c: Likewise. * nis/nis_destroygroup.c: Likewise. * nis/nis_findserv.c: Likewise. * nis/nis_ismember.c: Likewise. * nis/nis_print.c: Likewise. * nis/nis_print_group_entry.c: Likewise. * nis/nis_removemember.c: Likewise. * nis/nis_verifygroup.c: Likewise. * nis/ypclnt.c: Likewise. * nis/nis_file.c: Close file handles. * nis/nis_callback.c: Fix typo.
-rw-r--r--ChangeLog70
-rw-r--r--Makefile26
-rw-r--r--config.make.in1
-rwxr-xr-xconfigure29
-rw-r--r--configure.in24
-rw-r--r--mach/Machrules4
-rw-r--r--mach/Makefile10
-rw-r--r--manual/terminal.texi289
-rw-r--r--nis/nis_add.c21
-rw-r--r--nis/nis_addmember.c13
-rw-r--r--nis/nis_call.c9
-rw-r--r--nis/nis_callback.c2
-rw-r--r--nis/nis_creategroup.c11
-rw-r--r--nis/nis_destroygroup.c13
-rw-r--r--nis/nis_file.c32
-rw-r--r--nis/nis_findserv.c2
-rw-r--r--nis/nis_ismember.c13
-rw-r--r--nis/nis_print.c6
-rw-r--r--nis/nis_print_group_entry.c13
-rw-r--r--nis/nis_removemember.c11
-rw-r--r--nis/nis_verifygroup.c11
-rw-r--r--nis/ypclnt.c2
-rw-r--r--nscd/connections.c63
-rw-r--r--sysdeps/generic/Dist2
-rw-r--r--sysdeps/generic/enbl-secure.c8
-rw-r--r--sysdeps/generic/ftruncate.c8
-rw-r--r--sysdeps/generic/glob.c18
-rw-r--r--sysdeps/mach/hurd/ftruncate.c4
-rw-r--r--sysdeps/mach/hurd/truncate.c9
-rw-r--r--sysdeps/unix/sysv/linux/aio_sigqueue.c7
-rw-r--r--sysdeps/unix/sysv/linux/init-first.c1
-rw-r--r--sysdeps/unix/sysv/linux/sigqueue.c8
32 files changed, 552 insertions, 188 deletions
diff --git a/ChangeLog b/ChangeLog
index 4da69ffed8..66df815bff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,73 @@
+1998-06-22 17:02 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/generic/enbl-secure.c: Don't use __libc_uid.
+ * sysdeps/unix/sysv/linux/aio_sigqueue.c: Likewise.
+ * sysdeps/unix/sysv/linux/sigqueue.c: Likewise.
+ * sysdeps/unix/sysv/linux/init-first.c: Don't initialize __libc_uid.
+
+1998-06-02 Gordon Matzigkeit <gord@profitpress.com>
+
+ * mach/Makefile: Change `mv' invocations to `mv -f'.
+ * mach/Machrules: Likewise.
+
+1998-06-22 Andreas Jaeger <aj@arthur.rhein-neckar.de>
+
+ * config.make.in (old-glibc-headers): Add it.
+
+ * configure.in: Add test for glibc 2.0.x headers.
+
+ * Makefile (headers2_0): New variable - contains so far only
+ Linux/Intel glibc 2.0.x headers.
+ (remove-old-headers): New rule to remove headers from glibc 2.0.x.
+ (install): Depend on remove-old-headers.
+
+1998-06-19 Mark Kettenis <kettenis@phys.uva.nl>
+
+ * sysdeps/generic/ftruncate.c: Define function as __ftruncate and
+ make ftruncate a weak alias.
+ * sysdeps/mach/hurd/ftruncate.c: Really define function as
+ __ftruncate.
+ * sysdeps/mach/hurd/truncate.c: Include <unistd.h>.
+ (truncate): Fix function defenition to match prototype.
+
+1998-06-20 Mark Kettenis <kettenis@phys.uva.nl>
+
+ * manual/terminal.texi: Document ttyname_r, getpt, grantpt,
+ unlockpt, ptsname, ptsname_r, openpty and forkpty.
+
+1998-06-22 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/generic/glob.c: Make it possible to include glob.h
+ before loading glob.c.
+ Reported by Felix von Leitner <leitner@math.fu-berlin.de>.
+
+1998-06-22 Andreas Jaeger <aj@arthur.rhein-neckar.de>
+
+ * nscd/connections.c: Use poll() instead of select().
+
+1998-06-22 14:08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * sysdeps/generic/Dist: Fix typo.
+
+1998-06-20 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
+
+ * nis/nis_add.c: Avoid unnecessary strlen () calls.
+ * nis/nis_addmember.c: Likewise.
+ * nis/nis_call.c: Likewise.
+ * nis/nis_creategroup.c: Likewise.
+ * nis/nis_destroygroup.c: Likewise.
+ * nis/nis_findserv.c: Likewise.
+ * nis/nis_ismember.c: Likewise.
+ * nis/nis_print.c: Likewise.
+ * nis/nis_print_group_entry.c: Likewise.
+ * nis/nis_removemember.c: Likewise.
+ * nis/nis_verifygroup.c: Likewise.
+ * nis/ypclnt.c: Likewise.
+
+ * nis/nis_file.c: Close file handles.
+
+ * nis/nis_callback.c: Fix typo.
+
1998-06-10 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/Makefile: Add nis-initgroups and compat-initgroups.
diff --git a/Makefile b/Makefile
index 57637f4494..fdfc6d7ca8 100644
--- a/Makefile
+++ b/Makefile
@@ -284,3 +284,29 @@ iconvdata/%:
# need the only-MD5 based one as well.
md5-crypt/libmd5crypt:
$(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
+
+# glibc 2.0 contains some header files which aren't used with glibc 2.1
+# anymore.
+# These rules should remove those headers
+ifeq (,$(install_root))
+ifeq ($(old-glibc-headers),yes)
+install: remove-old-headers
+endif
+endif
+
+headers2_0 := __math.h bytesex.h confname.h direntry.h elfclass.h \
+ errnos.h fcntlbits.h huge_val.h ioctl-types.h \
+ ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h \
+ mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h \
+ posix2_lim.h posix_opt.h resourcebits.h schedbits.h \
+ selectbits.h semaphorebits.h sigaction.h sigcontext.h \
+ signum.h sigset.h sockaddrcom.h socketbits.h stab.def \
+ statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h \
+ syscall-list.h termbits.h timebits.h ustatbits.h \
+ utmpbits.h utsnamelen.h waitflags.h waitstatus.h \
+ xopen_lim.h gnu/types.h sys/ipc_buf.h \
+ sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h \
+ sys/shm_buf.h sys/socketcall.h
+
+remove-old-headers:
+ rm -f $(addprefix $(inst_includedir)/, $(headers2_0))
diff --git a/config.make.in b/config.make.in
index 0a76b10ede..f87169fb38 100644
--- a/config.make.in
+++ b/config.make.in
@@ -35,6 +35,7 @@ elf = @elf@
have-initfini = @libc_cv_have_initfini@
need-nopic-initfini = @nopic_initfini@
with-cvs = @with_cvs@
+old-glibc-headers = @old_glibc_headers@
versioning = @VERSIONING@
no-whole-archive = @no_whole_archive@
diff --git a/configure b/configure
index 61f9f7ba50..7603d5a266 100755
--- a/configure
+++ b/configure
@@ -2795,17 +2795,21 @@ default) stdio=stdio ;;
esac
echo "$ac_t""$stdio" 1>&6
-echo $ac_n "checking ldap selection""... $ac_c" 1>&6
-echo "configure:2800: checking ldap selection" >&5
-
-case $add_ons in
-*ldap*)
- ldap=yes
- LDAP=ldap ;;
-*) ldap=no
- LDAP= ;;
-esac
-echo "$ac_t""$ldap" 1>&6
+# Test for old glibc 2.0.x headers so that they can be removed properly
+# Search only in includedir.
+echo $ac_n "checking for old glibc 2.0.x headers""... $ac_c" 1>&6
+echo "configure:2802: checking for old glibc 2.0.x headers" >&5
+if eval test -e "${includedir}/elfclass.h" -a -e "${includedir}/fcntlbits.h"
+then
+ old_glibc_headers=yes
+else
+ old_glibc_headers=no
+fi
+echo "$ac_t""$old_glibc_headers" 1>&6
+if test ${old_glibc_headers} = yes; then
+ echo "configure: warning: *** During \"make install\" old headers from glibc 2.0.x will" 1>&2
+ echo "configure: warning: *** be removed." 1>&2
+fi
@@ -2847,7 +2851,7 @@ if test $shared = default; then
fi
echo $ac_n "checking whether -fPIC is default""... $ac_c" 1>&6
-echo "configure:2851: checking whether -fPIC is default" >&5
+echo "configure:2855: checking whether -fPIC is default" >&5
if eval "test \"`echo '$''{'pic_default'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3060,7 +3064,6 @@ s%@uname_sysname@%$uname_sysname%g
s%@uname_release@%$uname_release%g
s%@uname_version@%$uname_version%g
s%@stdio@%$stdio%g
-s%@LDAP@%$LDAP%g
s%@libc_cv_slibdir@%$libc_cv_slibdir%g
s%@libc_cv_sysconfdir@%$libc_cv_sysconfdir%g
s%@libc_cv_rootsbindir@%$libc_cv_rootsbindir%g
diff --git a/configure.in b/configure.in
index 5084d8e9ff..997cace59b 100644
--- a/configure.in
+++ b/configure.in
@@ -1101,16 +1101,20 @@ default) stdio=stdio ;;
esac
AC_MSG_RESULT($stdio)
-AC_MSG_CHECKING(ldap selection)
-AC_SUBST(LDAP)
-case $add_ons in
-*ldap*)
- ldap=yes
- LDAP=ldap ;;
-*) ldap=no
- LDAP= ;;
-esac
-AC_MSG_RESULT($ldap)
+# Test for old glibc 2.0.x headers so that they can be removed properly
+# Search only in includedir.
+AC_MSG_CHECKING(for old glibc 2.0.x headers)
+if eval test -e "${includedir}/elfclass.h" -a -e "${includedir}/fcntlbits.h"
+then
+ old_glibc_headers=yes
+else
+ old_glibc_headers=no
+fi
+AC_MSG_RESULT($old_glibc_headers)
+if test ${old_glibc_headers} = yes; then
+ AC_MSG_WARN(*** During \"make install\" old headers from glibc 2.0.x will)
+ AC_MSG_WARN(*** be removed.)
+fi
AC_SUBST(libc_cv_slibdir)
AC_SUBST(libc_cv_sysconfdir)
diff --git a/mach/Machrules b/mach/Machrules
index b5ae381c05..f78b15db91 100644
--- a/mach/Machrules
+++ b/mach/Machrules
@@ -87,7 +87,7 @@ $(objpfx)%.ir: $(objpfx)%.uh $(objpfx)%.h
{ printf \"$*-calls += %s\\n\", \$$3 }" $< ;\
echo '$$($*-calls:%=$$(objpfx)R\%C_%.c): $$(objpfx)$*.ustamp ;';\
) > $@-new
- mv $@-new $@
+ mv -f $@-new $@
vpath Machrules ../mach # Find ourselves.
ifndef transform-user-stub-output
@@ -161,7 +161,7 @@ $(objpfx)%.h: $(objpfx)%.__h $(objpfx)%.uh
# The last line of foo.__h is "#endif _foo_user_".
# The first two lines of foo.uh are "#ifndef _foo_user_"/"#define _foo_user_".
(sed -e '$$d' $<; sed -e '1,2d' $(word 2,$^)) > $@-new
- mv $@-new $@
+ mv -f $@-new $@
interface-routines := $(foreach if,$(user-interfaces), \
$(addprefix RPC_,$($(if)-calls))) \
diff --git a/mach/Makefile b/mach/Makefile
index 12de148cfe..20812662df 100644
--- a/mach/Makefile
+++ b/mach/Makefile
@@ -77,7 +77,7 @@ $(objpfx)mach-syscalls.mk: syscalls.awk Makefile
sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
| $(AWK) -f $< > $@-new
cat $@-dep >> $@-new; rm -f $@-dep
- mv $@-new $@
+ mv -f $@-new $@
generated += mach-syscalls.mk
ifndef mach-syscalls
@@ -89,7 +89,7 @@ $(mach-syscalls:%=$(objpfx)%.S): $(objpfx)%.S: $(objpfx)mach-syscalls.mk
(echo '#include <sysdep.h>'; \
echo 'kernel_trap(__$*,$(sysno-$*),$(nargs-$*))'; \
echo 'weak_alias (__$*, $*)') > $@-new
- mv $@-new $@
+ mv -f $@-new $@
generated += $(mach-syscalls:=.S)
endif # mach-syscalls
@@ -119,7 +119,7 @@ $(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
$(objpfx)RPC_%_rpc.c
$(AWK) -v alias=$* -v call=__$* -v rpc=__$*_rpc \
-v syscall=__syscall_$* -f $^ > $@-new
- mv $@-new $@
+ mv -f $@-new $@
generated += $(mach-shortcuts:%=%.c)
endif # mach-shortcuts
@@ -134,7 +134,7 @@ $(objpfx)mach-shortcuts.h: $(objpfx)mach/mach_interface.h \
cat $^ | tr \\012 @ | sed s/@@/@%/g | tr % \\012 \
| grep '^/\* Routine [a-z0-9_]*_rpc \*/' \
| sed 's/_rpc//g' | tr @ \\012 > $@-new
- mv $@-new $@
+ mv -f $@-new $@
generated += mach-shortcuts.h
before-compile += $(objpfx)mach-shortcuts.h
@@ -149,4 +149,4 @@ generated += errsystems.c
$(objpfx)errsystems.c: errsystems.awk err_*.sub \
$(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
$(AWK) -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
- mv $@.n $@
+ mv -f $@.n $@
diff --git a/manual/terminal.texi b/manual/terminal.texi
index 4e4be880ff..e6dc36d6b8 100644
--- a/manual/terminal.texi
+++ b/manual/terminal.texi
@@ -22,6 +22,7 @@ descriptor is and how to open a file descriptor for a terminal device.
* Line Control:: Sending break sequences, clearing
terminal buffers @dots{}
* Noncanon Example:: How to read single characters without echo.
+* Pseudo-Terminals:: How to open a pseudo-terminal.
@end menu
@node Is It a Terminal
@@ -35,14 +36,14 @@ descriptor is associated with a terminal by using the @code{isatty}
function.
@pindex unistd.h
-Prototypes for both @code{isatty} and @code{ttyname} are declared in
-the header file @file{unistd.h}.
+Prototypes for the functions in this section are declared in the header
+file @file{unistd.h}.
@comment unistd.h
@comment POSIX.1
@deftypefun int isatty (int @var{filedes})
This function returns @code{1} if @var{filedes} is a file descriptor
-associated with an open terminal device, and @code{0} otherwise.
+associated with an open terminal device, and @math{0} otherwise.
@end deftypefun
If a file descriptor is associated with a terminal, you can get its
@@ -59,6 +60,30 @@ the terminal file. The value is a null pointer if the file descriptor
isn't associated with a terminal, or the file name cannot be determined.
@end deftypefun
+@comment unistd.h
+@comment POSIX.1
+@deftypefun int ttyname_r (int @var{filedes}, char *@var{buf}, size_t @var{len})
+The @code{ttyname_r} function is similar to the @code{ttyname} function
+except that it places its result into the user-specified buffer starting
+at @var{buf} with length @var{len}.
+
+The normal return value from @code{ttyname_r} is @math{0}. Otherwise an
+error number is returned to indicate the error. The following
+@code{errno} error conditions are defined for this function:
+
+@table @code
+@item EBADF
+The @var{filedes} argument is not a valid file descriptor.
+
+@item ENOTTY
+The @var{filedes} is not associated with a terminal.
+
+@item ERANGE
+The buffer length @var{len} is too small to store the string to be
+returned.
+@end table
+@end deftypefun
+
@node I/O Queues
@section I/O Queues
@@ -237,7 +262,7 @@ This function is used to examine the attributes of the terminal
device with file descriptor @var{filedes}. The attributes are returned
in the structure that @var{termios-p} points to.
-If successful, @code{tcgetattr} returns @code{0}. A return value of @code{-1}
+If successful, @code{tcgetattr} returns @math{0}. A return value of @math{-1}
indicates an error. The following @code{errno} error conditions are
defined for this function:
@@ -302,8 +327,8 @@ write to the terminal. The exception is if the calling process itself
is ignoring or blocking @code{SIGTTOU} signals, in which case the
operation is performed and no signal is sent. @xref{Job Control}.
-If successful, @code{tcsetattr} returns @code{0}. A return value of
-@code{-1} indicates an error. The following @code{errno} error
+If successful, @code{tcsetattr} returns @math{0}. A return value of
+@math{-1} indicates an error. The following @code{errno} error
conditions are defined for this function:
@table @code
@@ -997,27 +1022,27 @@ This function returns the input line speed stored in the structure
@comment POSIX.1
@deftypefun int cfsetospeed (struct termios *@var{termios-p}, speed_t @var{speed})
This function stores @var{speed} in @code{*@var{termios-p}} as the output
-speed. The normal return value is @code{0}; a value of @code{-1}
+speed. The normal return value is @math{0}; a value of @math{-1}
indicates an error. If @var{speed} is not a speed, @code{cfsetospeed}
-returns @code{-1}.
+returns @math{-1}.
@end deftypefun
@comment termios.h
@comment POSIX.1
@deftypefun int cfsetispeed (struct termios *@var{termios-p}, speed_t @var{speed})
This function stores @var{speed} in @code{*@var{termios-p}} as the input
-speed. The normal return value is @code{0}; a value of @code{-1}
+speed. The normal return value is @math{0}; a value of @math{-1}
indicates an error. If @var{speed} is not a speed, @code{cfsetospeed}
-returns @code{-1}.
+returns @math{-1}.
@end deftypefun
@comment termios.h
@comment BSD
@deftypefun int cfsetspeed (struct termios *@var{termios-p}, speed_t @var{speed})
This function stores @var{speed} in @code{*@var{termios-p}} as both the
-input and output speeds. The normal return value is @code{0}; a value
-of @code{-1} indicates an error. If @var{speed} is not a speed,
-@code{cfsetspeed} returns @code{-1}. This function is an extension in
+input and output speeds. The normal return value is @math{0}; a value
+of @math{-1} indicates an error. If @var{speed} is not a speed,
+@code{cfsetspeed} returns @math{-1}. This function is an extension in
4.4 BSD.
@end deftypefun
@@ -1035,7 +1060,7 @@ will succeed. But they do not check that a particular hardware device
can actually support the specified speeds---in fact, they don't know
which device you plan to set the speed for. If you use @code{tcsetattr}
to set the speed of a particular device to a value that it cannot
-handle, @code{tcsetattr} returns @code{-1}.
+handle, @code{tcsetattr} returns @math{-1}.
@strong{Portability note:} In the GNU library, the functions above
accept speeds measured in bits per second as input, and return speed
@@ -1629,7 +1654,7 @@ This function does nothing if the terminal is not an asynchronous serial
data port.
The return value is normally zero. In the event of an error, a value
-of @code{-1} is returned. The following @code{errno} error conditions
+of @math{-1} is returned. The following @code{errno} error conditions
are defined for this function:
@table @code
@@ -1659,7 +1684,7 @@ protected using cancelation handlers.
@c ref pthread_cleanup_push / pthread_cleanup_pop
The return value is normally zero. In the event of an error, a value
-of @code{-1} is returned. The following @code{errno} error conditions
+of @math{-1} is returned. The following @code{errno} error conditions
are defined for this function:
@table @code
@@ -1705,7 +1730,7 @@ Clear both queued input and output.
@end table
The return value is normally zero. In the event of an error, a value
-of @code{-1} is returned. The following @code{errno} error conditions
+of @math{-1} is returned. The following @code{errno} error conditions
are defined for this function:
@table @code
@@ -1759,7 +1784,7 @@ For more information about the STOP and START characters, see @ref{Special
Characters}.
The return value is normally zero. In the event of an error, a value
-of @code{-1} is returned. The following @code{errno} error conditions
+of @math{-1} is returned. The following @code{errno} error conditions
are defined for this function:
@table @code
@@ -1805,3 +1830,231 @@ a process is stopped or continued; see @ref{Job Control}. But some
existing shells do not actually do this, so you may wish to establish
handlers for job control signals that reset terminal modes. The above
example does so.
+
+
+@node Pseudo-Terminals
+@section Pseudo-Terminals
+@cindex pseudo-terminals
+
+A @dfn{pseudo-terminal} is a special interprocess communication channel
+that acts like a terminal. On one end of the channel is called the
+@dfn{master} side or @dfn{master pseudo-terminal device}, the other side
+is called the @dfn{slave} side. Data written to the the master side is
+received by the slave side as if it was the result of a user typing at
+an ordinary terminal, and data written to the slave side is sent to the
+master side as if it was written on an ordinary terminal.
+
+Pseudo terminals are the way programs like @code{xterm} and @code{emacs}
+implement their terminal emulation functionality.
+
+@menu
+* Allocation:: Allocating a pseudo terminal.
+* Pseudo-Terminal Pairs:: How to open both sides of a
+ pseudo-terminal in a single operation.
+@end menu
+
+@node Allocation
+@subsection Allocating Pseudo-Terminals
+@cindex allocating pseudo-terminals
+
+@pindex stdlib.h
+This subsection describes functions for allocating a pseudo-terminals,
+and for making this pseudo-terminal available for actual use. These
+functions are declared in the header file @file{stdlib.h}.
+
+@comment stdlib.h
+@comment GNU
+@deftypefun int getpt (void)
+The @code{getpt} function returns a new file descriptor for the next
+available master pseudo-terminal. The normal return value from
+@code{getpt} is a non-negative integer file descriptor. In the case of
+an error, a value of @math{-1} is returned instead. The following
+@code{errno} conditions are defined for this function:
+
+@table @code
+@item ENFILE
+There are no master pseudo-terminals available.
+@end table
+
+This function is a GNU extension.
+@end deftypefun
+
+@comment stdlib.h
+@comment SVID, XPG4.2
+@deftypefun int grantpt (int @var{filedes})
+The @code{grantpt} function changes the ownership and access permission
+of the slave pseudo-terminal device corresponding to the master
+pseudo-terminal device associated with the file descriptor
+@var{filedes}. The owner is set from the real user ID of the calling
+process (@pxref{Process Persona}), and the group is set to a special
+group (typically @dfn{tty}) or from the real group ID of the calling
+process. The access permission is set such that the file is both
+readable and writable by the owner and only writable by the group.
+
+On some systems this function is implemented by invoking a special
+@code{setuid} root program (@pxref{How Change Persona}). As a
+consequence, installing a signal handler for the @code{SIGCHLD} signal
+(@pxref{Job Control Signals}) may interfere with a call to
+@code{grantpt}.
+
+The normal return value from @code{grantpt} is @math{0}; a value of
+@math{-1} is returned in case of failure. The following @code{errno}
+error conditions are defined for this function:
+
+@table @code
+@item EBADF
+The @var{filedes} argument is not a valid file descriptor.
+
+@item ENINVAL
+The @var{filedes} argument is not associated with a master pseudo-terminal
+device.
+
+@item EACCESS
+The slave pseudo-terminal device corresponding to the master associated
+with @var{filedes} could not be accessed.
+@end table
+
+@end deftypefun
+
+@comment stdlib.h
+@comment SVID, XPG4.2
+@deftypefun int unlockpt (int @var{filedes})
+The @code{unlockpt} function unlocks the slave pseudo-terminal device
+corresponding to the master pseudo-terminal device associated with the
+file descriptor @var{filedes}. On many systems, the slave can only be
+opened after unlocking, so portable applications should always call
+@code{unlockpt} before trying to open the slave.
+
+The normal return value from @code{unlockpt} is @math{0}; a value of
+@math{-1} is returned in case of failure. The following @code{errno}
+error conditions are defined for this function:
+
+@table @code
+@item EBADF
+The @var{filedes} argument is not a valid file descriptor.
+
+@item EINVAL
+The @var{filedes} argument is not associated with a master pseudo-terminal
+device.
+@end table
+@end deftypefun
+
+@comment stdlib.h
+@comment SVID, XPG4.2
+@deftypefun {char *} ptsname (int @var{filedes})
+If the file descriptor @var{filedes} is associated with a
+master pseudo-terminal device, the @code{ptsname} function returns a
+pointer to a statically-allocated, null-terminated string containing the
+file name of the associated slave pseudo-terminal file. This string
+might be overwritten by subsequent calls to @code{ptsname}.
+@end deftypefun
+
+@comment stdlib.h
+@comment GNU
+@deftypefun int ptsname_r (int @var{filedes}, char *@var{buf}, size_t @var{len})
+The @code{ptsname_r} function is similar to the @code{ptsname} function
+except that it places its result into the user-specified buffer starting
+at @var{buf} with length @var{len}.
+
+This function is a GNU extension.
+@end deftypefun
+
+@strong{Portability Note:} On @w{System V} derived systems, the file
+returned by the @code{ptsname} and @code{ptsname_r} functions may be
+STREAMS-based, and therefore require additional processing after opening
+before it actually behaves as a pseudo terminal.
+@c FIXME: xref STREAMS
+
+Typical usage of these functions is illustrated by the following example:
+@smallexample
+int
+open_pty_pair (int *amaster, int *aslave)
+@{
+ int master, slave;
+ char *name
+
+ master = getpt ();
+ if (master < 0)
+ return 0;
+
+ if (grantpt (master) < 0 || unlockpt (master) < 0)
+ goto close_master;
+ name = ptsname (master);
+ if (name == NULL)
+ goto close_master;
+
+ slave open (name, O_RDWR);
+ if (slave == -1)
+ goto close_master;
+
+ if (isastream (slave))
+ @{
+ if (ioctl (slave, I_PUSH, "ptem") < 0
+ || ioctl (slave, I_PUSH, "ldterm") < 0)
+ goto close_slave;
+ @}
+
+ *amaster = master;
+ *aslave = slave;
+ return 1;
+
+close_slave:
+ close (slave);
+
+close_master:
+ close (master);
+ return 0;
+@}
+@end smallexample
+
+@node Pseudo-Terminal Pairs
+@subsection Opening a Pseudo-Terminal Pair
+@cindex opening a pseudo-terminal pair
+
+These functions, derived from BSD, are available in the separate
+@file{libutil} library, and declared in @file{pty.h}.
+
+@comment pty.h
+@comment BSD
+@deftypefun int openpty (int *@var{amaster}, int *@var{aslave}, char *@var{name}, struct termios *@var{termp}, struct winsize *@var{winp})
+This function allocates and opens a pseudo-terminal pair, returning the
+file descriptor for the master in @var{*amaster}, and the file
+descriptor for the slave in @var{*aslave}. If the argument @var{name}
+is not a null pointer, the name file name of the slave pseudo-terminal
+device is stored in @code{*name}. If @var{termp} is not a null pointer,
+the terminal attributes of the slave are set to the ones specified in
+the structure that @var{termp} points to (@pxref{Terminal Modes}).
+Likewise, if the @var{winp} is not a null pointer, the screen size of
+the slave is set to the values specified in the structure that
+@var{winp} points to.
+
+The normal return value from @code{openpty} is @math{0}; a value of
+@math{-1} is returned in case of failure.
+
+@strong{Warning:} Using the @code{openpty} with @var{name} not set to
+@code{NULL} is @strong{very dangerous} because it provides no protection
+against overflowing the string @var{name}. You should use the
+@code{ttyname} function on the file descriptor returned in @var{*slave}
+to find out the file name of the slave pseudo-terminal device instead.
+@end deftypefun
+
+@comment pty.h
+@comment BSD
+@deftypefun int forkpty (int *@var{amaster}, char *@var{name}, struct termios *@var{termp}, struct winsize *@var{winp})
+This function is similar to the @code{openpty} function, but in
+addition, forks creates a new process (@pxref{Creating a Process}) and
+makes the newly opened slave pseudo-terminal device the controlling
+terminal (@pxref{Controlling Terminal}) for the child process.
+
+If the operation is successful, there are then both parent and child
+processes and both see @code{forkpty} return, but with different values:
+it returns a value of @math{0} in the child process and returns the child's
+process ID in the parent process.
+
+If the allocation of a pseudo-terminal pair or the process creation
+failed, @code{forkpty} returns a value of @math{-1} in the parent
+process.
+
+@strong{Warning:} The @code{forkpty} function has the same problems with
+respect to the @var{name} argument as @code{openpty}.
+@end deftypefun
diff --git a/nis/nis_add.c b/nis/nis_add.c
index 07fa0fb1e9..10b46aff18 100644
--- a/nis/nis_add.c
+++ b/nis/nis_add.c
@@ -29,8 +29,9 @@ nis_add (const_nis_name name, const nis_object *obj2)
nis_result *res;
nis_error status;
struct ns_request req;
- char buf1 [strlen (name) + 20];
- char buf4 [strlen (name) + 20];
+ size_t namelen = strlen (name);
+ char buf1 [namelen + 20];
+ char buf4 [namelen + 20];
res = calloc (1, sizeof (nis_result));
if (res == NULL)
@@ -40,13 +41,13 @@ nis_add (const_nis_name name, const nis_object *obj2)
memcpy (&obj, obj2, sizeof (nis_object));
- if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
+ if (obj.zo_name == NULL || obj.zo_name[0] == '\0')
obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));
- if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
+ if (obj.zo_owner == NULL || obj.zo_owner[0] == '\0')
obj.zo_owner = nis_local_principal ();
- if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
+ if (obj.zo_group == NULL || obj.zo_group[0] == '\0')
obj.zo_group = nis_local_group ();
obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));
@@ -59,11 +60,11 @@ nis_add (const_nis_name name, const nis_object *obj2)
}
req.ns_object.ns_object_len = 1;
- if ((status = __do_niscall (req.ns_object.ns_object_val[0].zo_domain,
- NIS_ADD, (xdrproc_t) _xdr_ns_request,
- (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
- (caddr_t) res, MASTER_ONLY,
- NULL)) != RPC_SUCCESS)
+ status = __do_niscall (req.ns_object.ns_object_val[0].zo_domain,
+ NIS_ADD, (xdrproc_t) _xdr_ns_request,
+ (caddr_t) &req, (xdrproc_t) _xdr_nis_result,
+ (caddr_t) res, MASTER_ONLY, NULL);
+ if (status != RPC_SUCCESS)
NIS_RES_STATUS (res) = status;
nis_destroy_object (req.ns_object.ns_object_val);
diff --git a/nis/nis_addmember.c b/nis/nis_addmember.c
index 6d55bd0d07..2a31903572 100644
--- a/nis/nis_addmember.c
+++ b/nis/nis_addmember.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -23,11 +23,12 @@
nis_error
nis_addmember (const_nis_name member, const_nis_name group)
{
- if (group != NULL && strlen (group) > 0)
+ if (group != NULL && group[0] != '\0')
{
- char buf[strlen (group) + 14 + NIS_MAXNAMELEN];
- char leafbuf[strlen (group) + 2];
- char domainbuf[strlen (group) + 2];
+ size_t grouplen = strlen (group);
+ char buf[grouplen + 14 + NIS_MAXNAMELEN];
+ char leafbuf[grouplen + 2];
+ char domainbuf[grouplen + 2];
nis_result *res, *res2;
nis_error status;
char *cp, *cp2;
@@ -35,7 +36,7 @@ nis_addmember (const_nis_name member, const_nis_name group)
cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
cp = stpcpy (cp, ".groups_dir");
cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
- if (cp2 != NULL && strlen (cp2) > 0)
+ if (cp2 != NULL && cp2[0] != '\0')
{
*cp++ = '.';
stpcpy (cp, cp2);
diff --git a/nis/nis_call.c b/nis/nis_call.c
index ff9e768fe4..a2bbdb50c0 100644
--- a/nis/nis_call.c
+++ b/nis/nis_call.c
@@ -484,9 +484,10 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags,
case LOWER_NAME:
{
directory_obj *obj;
- char leaf [strlen (name) + 3];
- char domain [strlen (name) + 3];
- char ndomain [strlen (name) + 3];
+ size_t namelen = strlen (name);
+ char leaf [namelen + 3];
+ char domain [namelen + 3];
+ char ndomain [namelen + 3];
char *cp;
u_int run = 0;
@@ -494,7 +495,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags,
do
{
- if (strlen (domain) == 0)
+ if (domain[0] == '\0')
{
nis_free_directory (dir);
return NULL;
diff --git a/nis/nis_callback.c b/nis/nis_callback.c
index 4c5693a3b5..5c8828d1fc 100644
--- a/nis/nis_callback.c
+++ b/nis/nis_callback.c
@@ -313,7 +313,7 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
#else
cb->serv->pkey.n_len =0;
cb->serv->pkey.n_bytes = NULL;
- cb->serv->key_type = NIS_PK_DH;
+ cb->serv->key_type = NIS_PK_NONE;
#endif
}
diff --git a/nis/nis_creategroup.c b/nis/nis_creategroup.c
index 8333e09c89..cd882ca01d 100644
--- a/nis/nis_creategroup.c
+++ b/nis/nis_creategroup.c
@@ -23,11 +23,12 @@
nis_error
nis_creategroup (const_nis_name group, u_long flags)
{
- if (group != NULL && strlen (group) > 0)
+ if (group != NULL && group[0] != '\0')
{
- char buf[strlen (group) + 50];
- char leafbuf[strlen (group) + 2];
- char domainbuf[strlen (group) + 2];
+ size_t grouplen = strlen (group);
+ char buf[grouplen + 50];
+ char leafbuf[grouplen + 2];
+ char domainbuf[grouplen + 2];
nis_error status;
nis_result *res;
char *cp, *cp2;
@@ -36,7 +37,7 @@ nis_creategroup (const_nis_name group, u_long flags)
cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
cp = stpcpy (cp, ".groups_dir");
cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
- if (cp2 != NULL && strlen (cp2) > 0)
+ if (cp2 != NULL && cp2[0] != '\0')
{
*cp++ = '.';
stpcpy (cp, cp2);
diff --git a/nis/nis_destroygroup.c b/nis/nis_destroygroup.c
index 5b70a67b68..ad56513607 100644
--- a/nis/nis_destroygroup.c
+++ b/nis/nis_destroygroup.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -23,11 +23,12 @@
nis_error
nis_destroygroup (const_nis_name group)
{
- if (group != NULL && strlen (group) > 0)
+ if (group != NULL && group[0] != '\0')
{
- char buf[strlen (group) + 50];
- char leafbuf[strlen (group) + 3];
- char domainbuf[strlen (group) + 3];
+ size_t grouplen = strlen (group);
+ char buf[grouplen + 50];
+ char leafbuf[grouplen + 3];
+ char domainbuf[grouplen + 3];
nis_error status;
nis_result *res;
char *cp, *cp2;
@@ -35,7 +36,7 @@ nis_destroygroup (const_nis_name group)
cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
cp = stpcpy (cp, ".groups_dir");
cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
- if (cp2 != NULL && strlen (cp2) > 0)
+ if (cp2 != NULL && cp2[0] != '\0')
{
*cp++ = '.';
stpcpy (cp, cp2);
diff --git a/nis/nis_file.c b/nis/nis_file.c
index 4634e67f61..94fa4eb865 100644
--- a/nis/nis_file.c
+++ b/nis/nis_file.c
@@ -30,6 +30,7 @@ readColdStartFile (void)
{
XDR xdrs;
FILE *in;
+ bool_t status;
directory_obj obj;
in = fopen (cold_start_file, "rb");
@@ -37,10 +38,11 @@ readColdStartFile (void)
return NULL;
memset (&obj, '\0', sizeof (obj));
xdrstdio_create (&xdrs, in, XDR_DECODE);
- if (!_xdr_directory_obj (&xdrs, &obj))
- return NULL;
+ status = _xdr_directory_obj (&xdrs, &obj);
+ xdr_destroy (&xdrs);
+ fclose (in);
- return nis_clone_directory (&obj, NULL);
+ return status ? nis_clone_directory (&obj, NULL) : NULL;
}
bool_t
@@ -48,16 +50,18 @@ writeColdStartFile (const directory_obj *obj)
{
XDR xdrs;
FILE *out;
+ bool_t status;
out = fopen (cold_start_file, "wb");
if (out == NULL)
return FALSE;
xdrstdio_create (&xdrs, out, XDR_ENCODE);
- if (!_xdr_directory_obj (&xdrs, (directory_obj *) obj))
- return FALSE;
+ status = _xdr_directory_obj (&xdrs, (directory_obj *) obj);
+ xdr_destroy (&xdrs);
+ fclose (out);
- return TRUE;
+ return status;
}
nis_object *
@@ -65,6 +69,7 @@ nis_read_obj (const char *name)
{
XDR xdrs;
FILE *in;
+ bool_t status;
nis_object obj;
in = fopen (name, "rb");
@@ -73,10 +78,11 @@ nis_read_obj (const char *name)
memset (&obj, '\0', sizeof (obj));
xdrstdio_create (&xdrs, in, XDR_DECODE);
- if (!_xdr_nis_object (&xdrs, &obj))
- return NULL;
+ status =_xdr_nis_object (&xdrs, &obj);
+ xdr_destroy (&xdrs);
+ fclose (in);
- return nis_clone_object (&obj, NULL);
+ return status ? nis_clone_object (&obj, NULL) : NULL;
}
bool_t
@@ -84,14 +90,16 @@ nis_write_obj (const char *name, const nis_object *obj)
{
XDR xdrs;
FILE *out;
+ bool_t status;
out = fopen (name, "wb");
if (out == NULL)
return FALSE;
xdrstdio_create (&xdrs, out, XDR_ENCODE);
- if (!_xdr_nis_object (&xdrs, (nis_object *) obj))
- return FALSE;
+ status = _xdr_nis_object (&xdrs, (nis_object *) obj);
+ xdr_destroy (&xdrs);
+ fclose (out);
- return TRUE;
+ return status;
}
diff --git a/nis/nis_findserv.c b/nis/nis_findserv.c
index 0e9f01700d..832b6a541d 100644
--- a/nis/nis_findserv.c
+++ b/nis/nis_findserv.c
@@ -138,7 +138,7 @@ __nis_findfastest (dir_binding * bind)
if (strcmp (bind->server_val[i].ep.ep_val[j].family, "inet") == 0)
if ((bind->server_val[i].ep.ep_val[j].proto == NULL) ||
(strcmp (bind->server_val[i].ep.ep_val[j].proto, "-") == 0) ||
- (strlen (bind->server_val[i].ep.ep_val[j].proto) == 0))
+ (bind->server_val[i].ep.ep_val[j].proto[0] == '\0'))
{
sin.sin_addr.s_addr =
inetstr2int (bind->server_val[i].ep.ep_val[j].uaddr);
diff --git a/nis/nis_ismember.c b/nis/nis_ismember.c
index aadd19753a..4a33f02cff 100644
--- a/nis/nis_ismember.c
+++ b/nis/nis_ismember.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -27,9 +27,10 @@
static int
internal_ismember (const_nis_name principal, const_nis_name group)
{
- char buf[strlen (group) + 50];
- char leafbuf[strlen (group) + 2];
- char domainbuf[strlen (group) + 2];
+ size_t grouplen = strlen (group);
+ char buf[grouplen + 50];
+ char leafbuf[grouplen + 2];
+ char domainbuf[grouplen + 2];
nis_result *res;
char *cp, *cp2;
u_int i;
@@ -37,7 +38,7 @@ internal_ismember (const_nis_name principal, const_nis_name group)
cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
cp = stpcpy (cp, ".groups_dir");
cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
- if (cp2 != NULL && strlen (cp2) > 0)
+ if (cp2 != NULL && cp2[0] != '\0')
{
*cp++ = '.';
strcpy (cp, cp2);
@@ -117,7 +118,7 @@ internal_ismember (const_nis_name principal, const_nis_name group)
bool_t
nis_ismember (const_nis_name principal, const_nis_name group)
{
- if (group != NULL && strlen (group) > 0 && principal != NULL)
+ if (group != NULL && group[0] != '\0' && principal != NULL)
return internal_ismember (principal, group) == 1 ? TRUE : FALSE;
else
return FALSE;
diff --git a/nis/nis_print.c b/nis/nis_print.c
index 0e36017615..b578cbfb65 100644
--- a/nis/nis_print.c
+++ b/nis/nis_print.c
@@ -202,15 +202,15 @@ nis_print_directory (const directory_obj *dir)
for (j = 0; j < sptr->ep.ep_len; j++)
{
printf ("\t[%d] - ", j + 1);
- if (ptr->proto != NULL && strlen (ptr->proto) > 0)
+ if (ptr->proto != NULL && ptr->proto[0] != '\0')
printf ("%s, ", ptr->proto);
else
printf ("-, ");
- if (ptr->family != NULL && strlen (ptr->family) > 0)
+ if (ptr->family != NULL && ptr->family[0] != '\0')
printf ("%s, ", ptr->family);
else
printf ("-, ");
- if (ptr->uaddr != NULL && strlen (ptr->uaddr) > 0)
+ if (ptr->uaddr != NULL && ptr->uaddr[0] != '\0')
printf ("%s\n", ptr->uaddr);
else
fputs ("-\n", stdout);
diff --git a/nis/nis_print_group_entry.c b/nis/nis_print_group_entry.c
index fbc9ad11ba..d5cdda038c 100644
--- a/nis/nis_print_group_entry.c
+++ b/nis/nis_print_group_entry.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -23,11 +23,12 @@
void
nis_print_group_entry (const_nis_name group)
{
- if (group != NULL && strlen (group) > 0)
+ if (group != NULL && group[0] != '\0')
{
- char buf[strlen (group) + 50];
- char leafbuf[strlen (group) + 3];
- char domainbuf[strlen (group) + 3];
+ size_t grouplen = strlen (group);
+ char buf[grouplen + 50];
+ char leafbuf[grouplen + 3];
+ char domainbuf[grouplen + 3];
unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0;
unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0;
char **mem_exp, **mem_imp, **mem_rec;
@@ -39,7 +40,7 @@ nis_print_group_entry (const_nis_name group)
cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
cp = stpcpy (cp, ".groups_dir");
cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
- if (cp2 != NULL && strlen (cp2) > 0)
+ if (cp2 != NULL && cp2[0] != '\0')
{
*cp++ = '.';
stpcpy (cp, cp2);
diff --git a/nis/nis_removemember.c b/nis/nis_removemember.c
index 28050a1ac3..4fa8893a84 100644
--- a/nis/nis_removemember.c
+++ b/nis/nis_removemember.c
@@ -23,11 +23,12 @@
nis_error
nis_removemember (const_nis_name member, const_nis_name group)
{
- if (group != NULL && strlen (group) > 0)
+ if (group != NULL && group[0] != '\0')
{
- char buf[strlen (group) + 14 + NIS_MAXNAMELEN];
- char leafbuf[strlen (group) + 2];
- char domainbuf[strlen (group) + 2];
+ size_t grouplen = strlen (group);
+ char buf[grouplen + 14 + NIS_MAXNAMELEN];
+ char leafbuf[grouplen + 2];
+ char domainbuf[grouplen + 2];
nis_name *newmem;
nis_result *res, *res2;
nis_error status;
@@ -37,7 +38,7 @@ nis_removemember (const_nis_name member, const_nis_name group)
cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
cp = stpcpy (cp, ".groups_dir");
cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
- if (cp2 != NULL && strlen (cp2) > 0)
+ if (cp2 != NULL && cp2[0] != '\0')
{
cp = stpcpy (cp, ".");
stpcpy (cp, cp2);
diff --git a/nis/nis_verifygroup.c b/nis/nis_verifygroup.c
index 6d3ec7b7b7..e04a8386b9 100644
--- a/nis/nis_verifygroup.c
+++ b/nis/nis_verifygroup.c
@@ -23,11 +23,12 @@
nis_error
nis_verifygroup (const_nis_name group)
{
- if (group != NULL && strlen (group) > 0)
+ if (group != NULL && group[0] != '\0')
{
- char buf[strlen (group) + 50];
- char leafbuf[strlen (group) + 2];
- char domainbuf[strlen (group) + 2];
+ size_t grouplen = strlen (group);
+ char buf[grouplen + 50];
+ char leafbuf[grouplen + 2];
+ char domainbuf[grouplen + 2];
nis_result *res;
nis_error status;
char *cp, *cp2;
@@ -35,7 +36,7 @@ nis_verifygroup (const_nis_name group)
cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
cp = stpcpy (cp, ".groups_dir");
cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
- if (cp2 != NULL && strlen (cp2) > 0)
+ if (cp2 != NULL && cp2[0] != '\0')
{
*cp++ = '.';
stpcpy (cp, cp2);
diff --git a/nis/ypclnt.c b/nis/ypclnt.c
index e8c016d028..198c4775b5 100644
--- a/nis/ypclnt.c
+++ b/nis/ypclnt.c
@@ -64,7 +64,7 @@ __yp_bind (const char *domain, dom_binding **ypdb)
int is_new = 0;
int try;
- if ((domain == NULL) || (strlen (domain) == 0))
+ if ((domain == NULL) || (domain[0] == '\0'))
return YPERR_BADARGS;
if (ypdb != NULL)
diff --git a/nscd/connections.c b/nscd/connections.c
index 36e89fa25d..63deac598e 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -37,10 +38,11 @@
#include "dbg_log.h"
/* Socket 0 in the array is named and exported into the file namespace
- as a connection point for clients. */
+ as a connection point for clients. There's a one to one
+ correspondence between sock[i] and read_polls[i]. */
static int sock[MAX_NUM_CONNECTIONS];
static int socks_active;
-static fd_set read_set;
+static struct pollfd read_polls[MAX_NUM_CONNECTIONS];
static pthread_mutex_t sock_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -63,6 +65,7 @@ close_sockets (void)
dbg_log (_("socket [%d|%d] close: %s"), strerror (errno));
sock[i] = 0;
+ read_polls[i].fd = -1;
--socks_active;
}
@@ -79,12 +82,13 @@ close_socket (int conn)
close (sock[conn]);
sock[conn] = 0;
+ read_polls[conn].fd = -1;
--socks_active;
pthread_mutex_unlock (&sock_lock);
}
-/* Local rountine, assigns a socket to a new connection request. */
+/* Local routine, assigns a socket to a new connection request. */
static void
handle_new_connection (void)
{
@@ -107,7 +111,8 @@ handle_new_connection (void)
return;
}
++socks_active;
- FD_SET (sock[i], &read_set);
+ read_polls[i].fd = sock[i];
+ read_polls[i].events = POLLRDNORM;
if (debug_flag > 2)
dbg_log (_("handle_new_connection used socket %d|%d"), i,
sock[i]);
@@ -127,10 +132,9 @@ handle_new_connection (void)
pthread_mutex_unlock (&sock_lock);
}
-/* Local routine, reads a request off a socket indicated by a selectset. */
+/* Local routine, reads a request off a socket indicated by read_polls. */
static int
-handle_new_request (fd_set read_selects, int **connp, request_header **reqp,
- char **key)
+handle_new_request (int **connp, request_header **reqp, char **key)
{
ssize_t nbytes;
int i;
@@ -140,7 +144,7 @@ handle_new_request (fd_set read_selects, int **connp, request_header **reqp,
/* Find the descriptor. */
for (i = 1; i < MAX_NUM_CONNECTIONS; ++i)
- if (FD_ISSET(sock[i], &read_selects))
+ if (read_polls[i].revents & (POLLRDNORM|POLLERR))
break;
if (debug_flag > 2)
@@ -158,7 +162,7 @@ handle_new_request (fd_set read_selects, int **connp, request_header **reqp,
dbg_log (_("Real close socket %d|%d"), i, sock[i]);
pthread_mutex_lock (&sock_lock);
- FD_CLR (sock[i], &read_set);
+ read_polls[i].fd = -1;
close (sock[i]);
sock[i] = 0;
--socks_active;
@@ -191,7 +195,7 @@ handle_new_request (fd_set read_selects, int **connp, request_header **reqp,
dbg_log (_("Real close socket %d|%d"), i, sock[i]);
pthread_mutex_lock (&sock_lock);
- FD_CLR (sock[i], &read_set);
+ read_polls[i].fd = -1;
close (sock[i]);
sock[i] = 0;
--socks_active;
@@ -223,8 +227,8 @@ handle_new_request (fd_set read_selects, int **connp, request_header **reqp,
void
get_request (int *conn, request_header *req, char **key)
{
- int i, nr, done = 0;
- fd_set read_selects;
+ int done = 0;
+ int nr;
if (debug_flag)
dbg_log ("get_request");
@@ -233,35 +237,21 @@ get_request (int *conn, request_header *req, char **key)
is read in on an existing connection. */
while (!done)
{
- /* Set up the socket descriptor mask for the select.
- copy read_set into the local copy. */
-
- FD_ZERO (&read_selects);
- pthread_mutex_lock (&sock_lock);
- for (i = 0; i < MAX_NUM_CONNECTIONS; ++i)
- {
- if (FD_ISSET (sock[i], &read_set))
- FD_SET (sock[i], &read_selects);
- }
- pthread_mutex_unlock (&sock_lock);
- /* Poll active connections using select(). */
- nr = select (FD_SETSIZE, &read_selects, NULL, NULL, NULL);
+ /* Poll active connections. */
+ nr = poll (read_polls, MAX_NUM_CONNECTIONS, -1);
if (nr <= 0)
{
- perror (_("Select new reads"));
+ perror (_("Poll new reads"));
exit (1);
}
- if (FD_ISSET (sock[0], &read_selects))
+ if (read_polls[0].revents & (POLLRDNORM|POLLERR))
/* Handle the case of a new connection request on the named socket. */
handle_new_connection ();
else
{
/* Read data from client specific descriptor. */
- if (handle_new_request (read_selects, &conn, &req, key) == 0)
- {
- FD_CLR (sock[*conn], &read_set);
- done = 1;
- }
+ if (handle_new_request (&conn, &req, key) == 0)
+ done = 1;
}
} /* While not_done. */
}
@@ -270,10 +260,14 @@ void
init_sockets (void)
{
struct sockaddr_un sock_addr;
+ int i;
/* Initialize the connections db. */
socks_active = 0;
- FD_ZERO (&read_set);
+
+ /* Initialize the poll array. */
+ for (i = 0; i < MAX_NUM_CONNECTIONS; i++)
+ read_polls[i].fd = -1;
/* Create the socket. */
sock[0] = socket (AF_UNIX, SOCK_STREAM, 0);
@@ -301,7 +295,8 @@ init_sockets (void)
}
/* Add the socket to the server's set of active sockets. */
- FD_SET (sock[0], &read_set);
+ read_polls[0].fd = sock[0];
+ read_polls[0].events = POLLRDNORM;
++socks_active;
}
diff --git a/sysdeps/generic/Dist b/sysdeps/generic/Dist
index 5d4075402d..36133eb9fa 100644
--- a/sysdeps/generic/Dist
+++ b/sysdeps/generic/Dist
@@ -1,6 +1,6 @@
make_siglist.c signame.c signame.h
det_endian.c
entry.h
-errno-loc.c.
+errno-loc.c
getresgid.c
getresuid.c
diff --git a/sysdeps/generic/enbl-secure.c b/sysdeps/generic/enbl-secure.c
index 3f3fe23c54..7dcd4391fa 100644
--- a/sysdeps/generic/enbl-secure.c
+++ b/sysdeps/generic/enbl-secure.c
@@ -1,5 +1,5 @@
/* Define and initialize the `__libc_enable_secure' flag. Generic version.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,13 +26,9 @@
/* Safest assumption, if somehow the initializer isn't run. */
int __libc_enable_secure = 1;
-/* We often need the UID. */
-extern uid_t __libc_uid;
-
void
__libc_init_secure (void)
{
- __libc_uid = __getuid ();
- __libc_enable_secure = (__geteuid () != __libc_uid
+ __libc_enable_secure = (__geteuid () != __getuid ()
|| __getegid () != __getgid ());
}
diff --git a/sysdeps/generic/ftruncate.c b/sysdeps/generic/ftruncate.c
index 8e067ac2b8..ece306f994 100644
--- a/sysdeps/generic/ftruncate.c
+++ b/sysdeps/generic/ftruncate.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,13 +16,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <sys/types.h>
#include <errno.h>
+#include <sys/types.h>
#include <unistd.h>
/* Truncate the file FD refers to to LENGTH bytes. */
int
-ftruncate (fd, length)
+__ftruncate (fd, length)
int fd;
off_t length;
{
@@ -30,5 +30,7 @@ ftruncate (fd, length)
return -1;
}
+weak_alias (__ftruncate, ftruncate)
+
stub_warning (ftruncate)
#include <stub-tag.h>
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index 29697f4c55..c26b2a6115 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -253,14 +253,16 @@ extern char *alloca ();
/* Some system header files erroneously define these.
We want our own definitions from <glob.h> to take precedence. */
-#undef GLOB_ERR
-#undef GLOB_MARK
-#undef GLOB_NOSORT
-#undef GLOB_DOOFFS
-#undef GLOB_NOCHECK
-#undef GLOB_APPEND
-#undef GLOB_NOESCAPE
-#undef GLOB_PERIOD
+#ifndef __GNU_LIBRARY__
+# undef GLOB_ERR
+# undef GLOB_MARK
+# undef GLOB_NOSORT
+# undef GLOB_DOOFFS
+# undef GLOB_NOCHECK
+# undef GLOB_APPEND
+# undef GLOB_NOESCAPE
+# undef GLOB_PERIOD
+#endif
#include <glob.h>
static
diff --git a/sysdeps/mach/hurd/ftruncate.c b/sysdeps/mach/hurd/ftruncate.c
index 67f428e55d..2e384f242e 100644
--- a/sysdeps/mach/hurd/ftruncate.c
+++ b/sysdeps/mach/hurd/ftruncate.c
@@ -16,15 +16,15 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <sys/types.h>
#include <errno.h>
+#include <sys/types.h>
#include <unistd.h>
#include <hurd.h>
#include <hurd/fd.h>
/* Truncate the file FD refers to to LENGTH bytes. */
int
-ftruncate (fd, length)
+__ftruncate (fd, length)
int fd;
__off_t length;
{
diff --git a/sysdeps/mach/hurd/truncate.c b/sysdeps/mach/hurd/truncate.c
index ae1f7b887b..438015ee93 100644
--- a/sysdeps/mach/hurd/truncate.c
+++ b/sysdeps/mach/hurd/truncate.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 97, 98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,15 +16,16 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <sys/types.h>
#include <errno.h>
-#include <hurd.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <hurd.h>
/* Truncate FILE_NAME to LENGTH bytes. */
int
truncate (file_name, length)
- char *file_name;
+ const char *file_name;
off_t length;
{
error_t err;
diff --git a/sysdeps/unix/sysv/linux/aio_sigqueue.c b/sysdeps/unix/sysv/linux/aio_sigqueue.c
index b962396291..1520ee1a29 100644
--- a/sysdeps/unix/sysv/linux/aio_sigqueue.c
+++ b/sysdeps/unix/sysv/linux/aio_sigqueue.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,9 +24,8 @@
extern int __syscall_rt_sigqueueinfo (int, int, siginfo_t *);
-/* These variables are used quite often in the libc code. */
+/* This variable is used quite often in the libc code. */
extern pid_t __libc_pid;
-extern uid_t __libc_uid;
/* Return any pending signal or wait for one for the given time. */
@@ -46,7 +45,7 @@ __aio_sigqueue (sig, val)
__libc_pid = __getpid ();
info.si_pid = __libc_pid;
- info.si_uid = __libc_uid;
+ info.si_uid = getuid ();
info.si_value = val;
diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
index acaf5093a4..c6bf6fb1a4 100644
--- a/sysdeps/unix/sysv/linux/init-first.c
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -45,7 +45,6 @@ char **__libc_argv;
/* We often need the UID and PID. Cache these values. */
pid_t __libc_pid = 0xf00baa;
-uid_t __libc_uid = 0xf00baa;
static void
diff --git a/sysdeps/unix/sysv/linux/sigqueue.c b/sysdeps/unix/sysv/linux/sigqueue.c
index 92026ef153..495238660d 100644
--- a/sysdeps/unix/sysv/linux/sigqueue.c
+++ b/sysdeps/unix/sysv/linux/sigqueue.c
@@ -23,7 +23,6 @@ extern int __syscall_rt_sigqueueinfo (int, int, siginfo_t *);
/* These variables are used quite often in the libc code. */
extern pid_t __libc_pid;
-extern uid_t __libc_uid;
/* Return any pending signal or wait for one for the given time. */
@@ -40,14 +39,11 @@ __sigqueue (pid, sig, val)
info.si_errno = 0;
info.si_code = SI_QUEUE;
- if (__libc_pid ==0xf00baa)
+ if (__libc_pid == 0xf00baa)
__libc_pid = __getpid ();
info.si_pid = __libc_pid;
- if (__libc_uid ==0xf00baa)
- __libc_pid = __getuid ();
- info.si_uid = __libc_uid;
-
+ info.si_uid = __getuid ();
info.si_value = val;
return __syscall_rt_sigqueueinfo (pid, sig, &info);