diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-01-30 11:44:34 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-01-30 11:44:34 +0000 |
commit | 6591c3356242ba48627beb29345e4e44242c7068 (patch) | |
tree | 402220c75072909733e8d383ea5b999f30f1f527 /sysdeps | |
parent | 7f0ff1b04ad67b1a4f624a8ad54e7533d1c8aab3 (diff) | |
download | glibc-6591c3356242ba48627beb29345e4e44242c7068.tar glibc-6591c3356242ba48627beb29345e4e44242c7068.tar.gz glibc-6591c3356242ba48627beb29345e4e44242c7068.tar.bz2 glibc-6591c3356242ba48627beb29345e4e44242c7068.zip |
Update.
1998-01-30 19:58 Ulrich Drepper <drepper@cygnus.com>
* include/cpio.h: Move to ...
* posix/cpio.h: ...here.
* locale/programs/ld-collate.c: Fix typo.
* signal/signal.h: Declare _sys_siglist with NSIG+1 elements.
* stdio-common/tiformat.c: Add checks for %#.0o and friends.
* login/utmp_file.c (pututline_file): Don't always report success
if similar entry is found. Patch by Mark M. Kettenis.
1998-01-30 16:06 Philip Blundell <pb@nexus.co.uk>
* manual/Makefile: Don't try to install the info files if makeinfo
is not available.
1998-01-30 12:05 Philip Blundell <pb@nexus.co.uk>
* sysdeps/unix/sysv/linux/bits/ioctls.h: Include a copy of the
kernel's network ioctls, rather than using <linux/sockios.h> to
get them. This way we are sure of maintaining compatibility if
the kernel interface should change.
1998-01-30 15:52 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/Dist: Add netrose/rose.h.
1998-01-25 19:54 Philip Blundell <Philip.Blundell@pobox.com>
* sysdeps/unix/sysv/linux/netrose/rose.h: New file.
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Install it.
1998-01-27 22:29 Zack Weinberg <zack@rabi.phys.columbia.edu>
Implement System V pseudoterminal handling.
* login/Makefile
(routines): Add getpt, grantpt, unlockpt, ptsname.
(libutil-routines): Remove pty. Add openpty, forkpty.
(distribute): New internal header pty-internal.h.
(others): Add the helper program, pt_chown.
(install-others): Install it, in $(libexecdir), mode 4755.
* login/pty-internal.h: New file.
* login/openpty.c: New file.
* login/forkpty.c: New file.
* login/programs/pt_chown.c: New file.
* libc.map: Add getpt, grantpt, unlockpt, ptsname, ptsname_r.
* stdlib/stdlib.h: Prototype them.
* config.make.in: Define $(libexecdir).
* Makeconfig: Define $(inst_libexecdir).
* sysdeps/generic/pty.c: Removed.
* sysdeps/unix/sysv/linux/pty.c: Removed.
* sysdeps/generic/getpt.c: Stub out.
* sysdeps/generic/grantpt.c: Likewise.
* sysdeps/generic/ptsname.c: Likewise.
* sysdeps/generic/unlockpt.c: Likewise.
* sysdeps/unix/grantpt.c: New file.
* sysdeps/unix/bsd/getpt.c: New file.
* sysdeps/unix/bsd/unlockpt.c: New file.
* sysdeps/unix/sysv/linux/getpt.c: New file.
* sysdeps/unix/sysv/linux/ptsname.c: New file.
* sysdeps/unix/sysv/linux/unlockpt.c: New file.
1998-01-29 23:56 Ulrich Drepper <drepper@cygnus.com>
* localedata/locales/ru_RU: Fix YESEXPR. Patch by lav@yars.free.net.
1998-01-29 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* nss/Makefile (tests): Add rule for test-netdb.c.
* nss/test-netdb.c: New file.
1998-01-29 02:38 Ulrich Drepper <drepper@cygnus.com>
* elf/dl-open.c (_dl_open): Make sure the variable `reloc' is
really kept as a variable. Patch by Richard Henderson,
reported by Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz>.
* elf/rtld.c (dl_main): Call _dl_init_paths before handling preloading.
* elf/genrtldtbl.awk: Mark machine dependent directory of generated
entries as not existing.
1998-01-26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* stdio-common/vfprintf.c (process_arg): Fix printing of octal
zero in alternate form with precision of zero, which must produce
"0". Add braces to avoid ambiguous `else'.
1998-01-26 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/nss_compat/compat-grp.c: Fix memory leak and trailing null
problem with strncpy.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/comapt-spwd.c: Likewise.
1998-01-28 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* assert/assert.h (assert_perror): Correct test for errnum. Patch
by uch@nop.or.jp. [PR libc/437]
1997-12-20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* locales/pl_PL: Fix int_curr_symbol.
1998-01-26 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* nis/nis_cache.c: Include <unistd.h> for declaration of close.
1998-01-06 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* stdio-common/test-popen.c: Include <errno.h>.
* sysdeps/unix/sysv/linux/if_index.c: Include <unistd.h> for
close.
* inet/getnetgrent_r.c: Include <errno.h>.
* db2/db/db_conv.c: Include <string.h> for memcpy.
* gmon/bb_exit_func.c: Include <string.h> instead of <strings.h>
so that memcpy is declared.
* iconv/iconv_open.c: Include <stdlib.h> for alloca.
* misc/init-misc.c: Remove unneeded inclusion of <errno.h>.
1998-01-26 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* pwd/fgetpwent_r.c (__fgetpwent_r): Correctly handle buffer
overflow while reading line with fgets.
* grp/fgetgrent_r.c (__fgetgrent_r): Likewise.
1998-01-27 00:46 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/bits/types.h (__ipc_pid_t): Change to
unsigned short, not short.
Reported by Andreas Jaeger.
1998-01-06 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/unix/sysv/linux/mips/syscalls.list: Correct typo
(ccept->accept).
* sysdeps/generic/inttypes.h: Fix spelling.
1998-01-04 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/unix/sysv/linux/arm/Dist: Add bits/mman.h.
* sysdeps/unix/sysv/linux/alpha/Dist: Add net/route.h.
1998-01-27 00:30 Ulrich Drepper <drepper@cygnus.com>
* stdio-common/printf.h (struct print_info): Add new bitfield is_char.
* stdio-common/printf-parse.h (parse_one_spec): Fill in is_char
field for hh modifier.
* stdio-common/vfprint.c: Use is_char field and do not depend in
is_short having the value 2.
Bug reported by Andreas Jaeger.
1998-01-05 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* libio/freopen.c (freopen): Call _IO_old_freopen only if defined
PIC && DO_VERSIONING.
1998-01-24 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Rules: Add rules for $(common-objpfx)dummy$o.
Diffstat (limited to 'sysdeps')
23 files changed, 715 insertions, 160 deletions
diff --git a/sysdeps/generic/getpt.c b/sysdeps/generic/getpt.c new file mode 100644 index 0000000000..6dee1e12df --- /dev/null +++ b/sysdeps/generic/getpt.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <stdlib.h> +#include <errno.h> + +/* Open the master side of a pseudoterminal and return its file + descriptor, or -1 on error. */ +int +__getpt () +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (getpt, __getpt) + +stub_warning (getpt) +#include <stub-tag.h> diff --git a/sysdeps/generic/grantpt.c b/sysdeps/generic/grantpt.c new file mode 100644 index 0000000000..73c1821962 --- /dev/null +++ b/sysdeps/generic/grantpt.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <stdlib.h> +#include <errno.h> + +/* Given a fd on a master pseudoterminal, chown the file associated + with the slave to the calling process, and set its group and + mode appropriately. Note that this is an unprivileged operation. */ +int +grantpt (fd) + int fd __attribute__ ((unused)); +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (grantpt) +#include <stub-tag.h> diff --git a/sysdeps/generic/inttypes.h b/sysdeps/generic/inttypes.h index c5a74b8d2d..9ef0e8526a 100644 --- a/sysdeps/generic/inttypes.h +++ b/sysdeps/generic/inttypes.h @@ -1 +1 @@ -#error "This file must be written based on the data typs sizes of the target" +#error "This file must be written based on the data type sizes of the target" diff --git a/sysdeps/generic/ptsname.c b/sysdeps/generic/ptsname.c new file mode 100644 index 0000000000..7a442d0d69 --- /dev/null +++ b/sysdeps/generic/ptsname.c @@ -0,0 +1,46 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <stdlib.h> +#include <errno.h> + +/* Given the file descriptor of a master pty, return the pathname + of the associated slave. */ + +char * +ptsname (fd) + int fd __attribute__ ((unused)); +{ + __set_errno (ENOSYS); + return 0; +} + +char * +__ptsname_r (fd, buf, len) + int fd __attribute__ ((unused)); + char *buf __attribute__ ((unused)); + unsigned int len __attribute__ ((unused)); +{ + __set_errno (ENOSYS); + return 0; +} +weak_alias (__ptsname_r, ptsname_r) + +stub_warning(ptsname) +stub_warning(ptsname_r) diff --git a/sysdeps/generic/pty.c b/sysdeps/generic/pty.c deleted file mode 100644 index 75c7857f47..0000000000 --- a/sysdeps/generic/pty.c +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/cdefs.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <termios.h> -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <grp.h> -#include <pty.h> -#include <utmp.h> - -#ifndef REVOKE -# define REVOKE(Line) revoke (Line) -#endif - -int -openpty(amaster, aslave, name, termp, winp) - int *amaster, *aslave; - char *name; - struct termios *termp; - struct winsize *winp; -{ - char line[11]; - register const char *cp1, *cp2; - register int master, slave, ttygid; - size_t buflen = sysconf (_SC_GETGR_R_SIZE_MAX); - char buffer[buflen]; - struct group grbuffer; - struct group *gr; - - strcpy (line, "/dev/ptyXX"); - - if (getgrnam_r("tty", &grbuffer, buffer, buflen, &gr) >= 0) - ttygid = gr->gr_gid; - else - ttygid = -1; - - for (cp1 = "pqrs"; *cp1; cp1++) { - line[8] = *cp1; - for (cp2 = "0123456789abcdef"; *cp2; cp2++) { - line[9] = *cp2; - if ((master = open(line, O_RDWR, 0)) == -1) { - if (errno == ENOENT) - return (-1); /* out of ptys */ - } else { - line[5] = 't'; - (void) chown(line, getuid(), ttygid); - (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP); - REVOKE(line); - if ((slave = open(line, O_RDWR, 0)) != -1) { - *amaster = master; - *aslave = slave; - if (name) - strcpy(name, line); - if (termp) - (void) tcsetattr(slave, - TCSAFLUSH, termp); - if (winp) - (void) ioctl(slave, TIOCSWINSZ, - (char *)winp); - return (0); - } - (void) close(master); - line[5] = 'p'; - } - } - } - __set_errno (ENOENT); /* out of ptys */ - return (-1); -} - -int -forkpty(amaster, name, termp, winp) - int *amaster; - char *name; - struct termios *termp; - struct winsize *winp; -{ - int master, slave, pid; - - if (openpty(&master, &slave, name, termp, winp) == -1) - return (-1); - switch (pid = fork()) { - case -1: - return (-1); - case 0: - /* - * child - */ - (void) close(master); - login_tty(slave); - return (0); - } - /* - * parent - */ - *amaster = master; - (void) close(slave); - return (pid); -} diff --git a/sysdeps/generic/unlockpt.c b/sysdeps/generic/unlockpt.c new file mode 100644 index 0000000000..5ee130971e --- /dev/null +++ b/sysdeps/generic/unlockpt.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <stdlib.h> +#include <errno.h> + +/* Given a fd on a master pseudoterminal, clear a kernel lock so that + the slave can be opened. This is to avoid a race between opening the + master and calling grantpt() to take possession of the slave. */ +int +unlockpt (fd) + int fd __attribute__ ((unused)); +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (unlockpt) +#include <stub-tag.h> diff --git a/sysdeps/unix/bsd/getpt.c b/sysdeps/unix/bsd/getpt.c new file mode 100644 index 0000000000..cb47692fdd --- /dev/null +++ b/sysdeps/unix/bsd/getpt.c @@ -0,0 +1,60 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/types.h> +#include <fcntl.h> +#include <errno.h> +#include <stdlib.h> + +#include "pty-internal.h" + +/* Per the FreeBSD-3.0 manpages: pty masters are named + /dev/pty[p-sP-S][0-9a-v]. I hope EIO is the right + errno in the "already open" case; it doesn't say. */ +static const char pn1[] = "pqrsPQRS"; +static const char pn2[] = "0123456789abcdefghijklmnopqrstuv"; + +/* Open the master side of a pseudoterminal and return its file + descriptor, or -1 on error. BSD version. */ +int +__getpt () +{ + int fd; + const char *i, *j; + char namebuf[PTYNAMELEN]; + + strcpy (namebuf, "/dev/pty"); + namebuf[10] = '\0'; + for (i = pn1; *i; ++i) + { + namebuf[8] = *i; + for (j = pn2; *j; ++j) + { + namebuf[9] = *j; + fd = open (namebuf, O_RDWR); + if (fd != -1) + return fd; + if (errno != EIO) + return -1; + } + } + __set_errno (ENFILE); + return -1; +} +weak_alias (getpt, __getpt) diff --git a/sysdeps/unix/bsd/unlockpt.c b/sysdeps/unix/bsd/unlockpt.c new file mode 100644 index 0000000000..3de46eeda9 --- /dev/null +++ b/sysdeps/unix/bsd/unlockpt.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <stdlib.h> +#include <unistd.h> + +#include "pty-internal.h" + +/* Given a fd on a master pseudoterminal, clear a kernel lock so that + the slave can be opened. This is to avoid a race between opening the + master and calling grantpt() to take possession of the slave. + + BSD doesn't have this lock, but what it does have is revoke(). */ + +int +unlockpt (fd) + int fd; +{ + char buf[PTYNAMELEN]; + + if (ptsname_r (fd, buf, PTYNAMELEN)) + return -1; + + return revoke (buf); +} diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c new file mode 100644 index 0000000000..4837a7a128 --- /dev/null +++ b/sysdeps/unix/grantpt.c @@ -0,0 +1,111 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/resource.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/wait.h> + +#include <assert.h> + +#include "pty-internal.h" + +/* Given a fd on a master pseudoterminal, chown the file associated + with the slave to the calling process, and set its group and + mode appropriately. Note that this is an unprivileged operation. */ + +/* This "generic Unix" implementation works because we provide the program + /usr/libexec/pt_chown, and it only depends on ptsname() working. */ +static const char helper[] = LIBEXECDIR "/pt_chown"; +static const char *argv[] = { "pt_chown", NULL }; + +int +grantpt (fd) + int fd; +{ + struct stat st; + int w, pid; + char namebuf[PTYNAMELEN]; + + /* Some systems do it for us. */ + if (ptsname_r (fd, namebuf, PTYNAMELEN) == NULL) + return -1; + if (stat (namebuf, &st)) + return -1; + + if (st.st_uid == getuid ()) + return 0; + + /* We have to do it in user space. */ + + pid = fork (); + if (pid == -1) + return -1; + else if (pid == 0) + { + /* Disable core dumps in the child. */ + struct rlimit off = { 0, 0 }; + setrlimit (RLIMIT_CORE, &off); + + /* The helper does its thing on fd PTY_FD. */ + if (fd != PTY_FD) + if (dup2 (fd, PTY_FD) == -1) + _exit (FAIL_EBADF); + + execve (helper, (char *const *) argv, 0); + _exit (FAIL_EXEC); + } + else + { + if (waitpid (pid, &w, 0) == -1) + return -1; + if (!WIFEXITED (w)) + { + __set_errno (ENOEXEC); + return -1; + } + else + switch (WEXITSTATUS(w)) + { + case 0: + break; + case FAIL_EBADF: + __set_errno (EBADF); + return -1; + case FAIL_EINVAL: + __set_errno (EINVAL); + return -1; + case FAIL_EACCES: + __set_errno (EACCES); + return -1; + case FAIL_EXEC: + __set_errno (ENOEXEC); + return -1; + + default: + assert(! "getpt: internal error: invalid exit code from pt_chown"); + } + } + + /* Success. */ + return 0; +} diff --git a/sysdeps/unix/sysv/linux/Dist b/sysdeps/unix/sysv/linux/Dist index 6743794281..c1b6ec91c2 100644 --- a/sysdeps/unix/sysv/linux/Dist +++ b/sysdeps/unix/sysv/linux/Dist @@ -33,6 +33,7 @@ netinet/tcp.h netinet/udp.h netipx/ipx.h netrom/netrom.h +netrose/rose.h nfs/nfs.h rt_sigaction.c rt_sigpending.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 29f1566753..a71ee439a0 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -79,7 +79,8 @@ ifeq ($(subdir),inet) sysdep_headers += netinet/in_systm.h netinet/udp.h \ netinet/if_fddi.h netinet/if_tr.h netinet/igmp.h \ netinet/ip_fw.h netinet/ip_icmp.h netipx/ipx.h \ - sys/socketvar.h netax25/ax25.h netrom/netrom.h + sys/socketvar.h netax25/ax25.h netrom/netrom.h \ + netrose/rose.h endif ifeq ($(subdir),posix) diff --git a/sysdeps/unix/sysv/linux/alpha/Dist b/sysdeps/unix/sysv/linux/alpha/Dist index 715fda7bd3..5b5dca44da 100644 --- a/sysdeps/unix/sysv/linux/alpha/Dist +++ b/sysdeps/unix/sysv/linux/alpha/Dist @@ -9,6 +9,7 @@ ioperm.c kernel_sigaction.h kernel_stat.h kernel_termios.h +net/route.h sys/acct.h sys/io.h sys/procfs.h diff --git a/sysdeps/unix/sysv/linux/arm/Dist b/sysdeps/unix/sysv/linux/arm/Dist index 738b9cc542..d987285445 100644 --- a/sysdeps/unix/sysv/linux/arm/Dist +++ b/sysdeps/unix/sysv/linux/arm/Dist @@ -1 +1,2 @@ +bits/mman.h clone.S diff --git a/sysdeps/unix/sysv/linux/bits/ioctls.h b/sysdeps/unix/sysv/linux/bits/ioctls.h index a89724cd71..7208d3bd4f 100644 --- a/sysdeps/unix/sysv/linux/bits/ioctls.h +++ b/sysdeps/unix/sysv/linux/bits/ioctls.h @@ -1,4 +1,4 @@ -/* 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 @@ -22,4 +22,87 @@ /* Use the definitions from the kernel header files. */ #include <asm/ioctls.h> -#include <linux/sockios.h> + +/* Routing table calls. */ +#define SIOCADDRT 0x890B /* add routing table entry */ +#define SIOCDELRT 0x890C /* delete routing table entry */ +#define SIOCRTMSG 0x890D /* call to routing system */ + +/* Socket configuration controls. */ +#define SIOCGIFNAME 0x8910 /* get iface name */ +#define SIOCSIFLINK 0x8911 /* set iface channel */ +#define SIOCGIFCONF 0x8912 /* get iface list */ +#define SIOCGIFFLAGS 0x8913 /* get flags */ +#define SIOCSIFFLAGS 0x8914 /* set flags */ +#define SIOCGIFADDR 0x8915 /* get PA address */ +#define SIOCSIFADDR 0x8916 /* set PA address */ +#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ +#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ +#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ +#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ +#define SIOCGIFNETMASK 0x891b /* get network PA mask */ +#define SIOCSIFNETMASK 0x891c /* set network PA mask */ +#define SIOCGIFMETRIC 0x891d /* get metric */ +#define SIOCSIFMETRIC 0x891e /* set metric */ +#define SIOCGIFMEM 0x891f /* get memory address (BSD) */ +#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ +#define SIOCGIFMTU 0x8921 /* get MTU size */ +#define SIOCSIFMTU 0x8922 /* set MTU size */ +#define SIOCSIFHWADDR 0x8924 /* set hardware address */ +#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */ +#define SIOCSIFENCAP 0x8926 +#define SIOCGIFHWADDR 0x8927 /* Get hardware address */ +#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ +#define SIOCSIFSLAVE 0x8930 +#define SIOCADDMULTI 0x8931 /* Multicast address lists */ +#define SIOCDELMULTI 0x8932 +#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ +#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */ +#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */ +#define SIOCGIFPFLAGS 0x8935 +#define SIOCDIFADDR 0x8936 /* delete PA address */ +#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */ +#define SIOCGIFCOUNT 0x8938 /* get number of devices */ + +#define SIOCGIFBR 0x8940 /* Bridging support */ +#define SIOCSIFBR 0x8941 /* Set bridging options */ + +#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ +#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ + + +/* ARP cache control calls. */ + /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ +#define SIOCDARP 0x8953 /* delete ARP table entry */ +#define SIOCGARP 0x8954 /* get ARP table entry */ +#define SIOCSARP 0x8955 /* set ARP table entry */ + +/* RARP cache control calls. */ +#define SIOCDRARP 0x8960 /* delete RARP table entry */ +#define SIOCGRARP 0x8961 /* get RARP table entry */ +#define SIOCSRARP 0x8962 /* set RARP table entry */ + +/* Driver configuration calls */ + +#define SIOCGIFMAP 0x8970 /* Get device parameters */ +#define SIOCSIFMAP 0x8971 /* Set device parameters */ + +/* DLCI configuration calls */ + +#define SIOCADDDLCI 0x8980 /* Create new DLCI device */ +#define SIOCDELDLCI 0x8981 /* Delete DLCI device */ + +/* Device private ioctl calls. */ + +/* These 16 ioctls are available to devices via the do_ioctl() device + vector. Each device should include this file and redefine these + names as their own. Because these are device dependent it is a good + idea _NOT_ to issue them to random objects and hope. */ + +#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ + +/* + * These 16 ioctl calls are protocol private + */ + +#define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */ diff --git a/sysdeps/unix/sysv/linux/bits/types.h b/sysdeps/unix/sysv/linux/bits/types.h index 68cbf8ca7d..16111beed0 100644 --- a/sysdeps/unix/sysv/linux/bits/types.h +++ b/sysdeps/unix/sysv/linux/bits/types.h @@ -104,7 +104,7 @@ typedef struct typedef int __key_t; /* Used in `struct shmid_ds'. */ -typedef short int __ipc_pid_t; +typedef unsigned short int __ipc_pid_t; /* Types from the Large File Support interface. */ diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c new file mode 100644 index 0000000000..8eea2ffa82 --- /dev/null +++ b/sysdeps/unix/sysv/linux/getpt.c @@ -0,0 +1,76 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/types.h> +#include <fcntl.h> +#include <errno.h> +#include <stdlib.h> + +#include "pty-internal.h" + +/* Per Documentation/devices.txt: pty masters are /dev/pty[p-za-e][0-9a-f]. + These strings are used also in ptsname.c. */ +const char __ptyname1[] = "pqrstuvwxyzabcde"; +const char __ptyname2[] = "0123456789abcdef"; + +/* Open the master side of a pseudoterminal and return its file + descriptor, or -1 on error. Linux version. */ +int +__getpt () +{ + int fd; + const char *i, *j; + static int have_dev_ptmx = 1; + char namebuf[PTYNAMELEN]; + + /* The new way: */ + if (have_dev_ptmx) + { + fd = open ("/dev/ptmx", O_RDWR); + if (fd != -1) + return fd; + else + { + if (errno == ENOENT || errno == ENODEV) + have_dev_ptmx = 0; + else + return -1; + } + } + + /* The old way: */ + strcpy (namebuf, "/dev/pty"); + namebuf[10] = '\0'; + for (i = __ptyname1; *i; ++i) + { + namebuf[8] = *i; + for (j = __ptyname2; *j; ++j) + { + namebuf[9] = *j; + fd = open (namebuf, O_RDWR); + if (fd != -1) + return fd; + if (errno != EIO) + return -1; + } + } + __set_errno (ENFILE); + return -1; +} +weak_alias (__getpt, getpt) diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c index 2e0bc5bf8f..9d9bf0e0b2 100644 --- a/sysdeps/unix/sysv/linux/if_index.c +++ b/sysdeps/unix/sysv/linux/if_index.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 @@ -20,6 +20,7 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include <net/if.h> #include <sys/socket.h> #include <sys/ioctl.h> diff --git a/sysdeps/unix/sysv/linux/mips/syscalls.list b/sysdeps/unix/sysv/linux/mips/syscalls.list index 1c9c095ed3..d026910ee2 100644 --- a/sysdeps/unix/sysv/linux/mips/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/syscalls.list @@ -16,7 +16,7 @@ sigsuspend - sigsuspend 1 __sigsuspend sigsuspend # Socket functions; Linux/MIPS doesn't use the socketcall(2) wrapper; # it's provided for compatibility, though. # -ccept - accept 3 __libc_accept __accept accept +accept - accept 3 __libc_accept __accept accept bind - bind 3 __bind bind connect - connect 3 __libc_connect __connect connect getpeername - getpeername 3 __getpeername getpeername diff --git a/sysdeps/unix/sysv/linux/m68k/sigreturn.S b/sysdeps/unix/sysv/linux/netrose/rose.h index 34c0a91952..c158c66bb7 100644 --- a/sysdeps/unix/sysv/linux/m68k/sigreturn.S +++ b/sysdeps/unix/sysv/linux/netrose/rose.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Definitions for Rose packet radio address family. + Copyright (C) 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,14 +17,9 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <sysdep.h> +#ifndef _NETROSE_ROSE_H +#define _NETROSE_ROSE_H 1 -.text -ENTRY (__sigreturn) - addq.l #4, %sp /* Pop the return PC. */ - DO_CALL (#SYS_ify (sigreturn), 0) - /* Do the system call; it never returns. */ - /* NOTREACHED */ -END (__sigreturn) +#include <linux/rose.h> /* Ask, and the kernel will provide. */ -weak_alias (__sigreturn, sigreturn) +#endif diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c new file mode 100644 index 0000000000..04feadd436 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ptsname.c @@ -0,0 +1,108 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <termios.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +#include "pty-internal.h" + +#include <stdio-common/_itoa.h> +#include <sys/sysmacros.h> + +/* Given the file descriptor of a master pty, return the pathname + of the associated slave. */ + +static char namebuf[PTYNAMELEN]; +extern const char __ptyname1[], __ptyname2[]; /* defined in getpt.c */ + +char * +ptsname (fd) + int fd; +{ + return __ptsname_r (fd, namebuf, PTYNAMELEN); +} + +char * +__ptsname_r (fd, buf, len) + int fd; + char *buf; + unsigned int len; +{ + char nbuf[PTYNAMELEN], idbuf[6]; + int ptyno; + struct stat st; + +#ifdef TIOCGPTN + static int tiocgptn_works = 1; + if (tiocgptn_works) + { + if (!ioctl (fd, TIOCGPTN, &ptyno)) + goto gotit; + else + { + if(errno != EINVAL) + return 0; + else + tiocgptn_works = 0; + } + } +#endif + /* /dev/ptmx will make it into the kernel before 32 bit dev_t, so + this should be safe. */ + if (fstat (fd, &st)) + return 0; + + ptyno = minor (st.st_rdev); + +#ifdef TIOCGPTN +gotit: +#endif + /* Two different possible naming schemes for pty slaves: + the SVr4 way. */ + + idbuf[5] = '\0'; + stpcpy (stpcpy (nbuf, "/dev/pts/"), + _itoa_word (ptyno, &idbuf[4], 10, 0)); + if (!stat (nbuf, &st)) + { + strncpy (buf, nbuf, len); + return buf; + } + else + if (errno != ENOENT) + return NULL; + + /* ...and the BSD way. */ + nbuf[7] = 'y'; + nbuf[8] = __ptyname1[ptyno / 16]; + nbuf[9] = __ptyname2[ptyno % 16]; + nbuf[10] = '\0'; + + if (stat (nbuf, &st)) + return NULL; + + strncpy (buf, nbuf, len); + return buf; +} +weak_alias (__ptsname_r, ptsname_r) diff --git a/sysdeps/unix/sysv/linux/pty.c b/sysdeps/unix/sysv/linux/pty.c deleted file mode 100644 index e64261c8c4..0000000000 --- a/sysdeps/unix/sysv/linux/pty.c +++ /dev/null @@ -1,3 +0,0 @@ -/* Linux does not has the `revoke' function. */ -#define REVOKE(Line) -#include <sysdeps/generic/pty.c> diff --git a/sysdeps/unix/sysv/linux/siglist.c b/sysdeps/unix/sysv/linux/siglist.c index 43b229fc95..ae5ca6b8ec 100644 --- a/sysdeps/unix/sysv/linux/siglist.c +++ b/sysdeps/unix/sysv/linux/siglist.c @@ -1,3 +1,21 @@ +/* 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + #include <stddef.h> #include <signal.h> diff --git a/sysdeps/unix/sysv/linux/unlockpt.c b/sysdeps/unix/sysv/linux/unlockpt.c new file mode 100644 index 0000000000..e508b280c5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/unlockpt.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/ioctl.h> +#include <termios.h> +#include <errno.h> +#include <stdlib.h> + +/* Given a fd on a master pseudoterminal, clear a kernel lock so that + the slave can be opened. This is to avoid a race between opening the + master and calling grantpt() to take possession of the slave. */ +int +unlockpt (fd) + int fd __attribute__ ((unused)); +{ +#ifdef TIOCSPTLCK + int serrno = errno; + int unlock = 0; + + if (ioctl (fd, TIOCSPTLCK, &unlock)) + { + if(errno == EINVAL) + { + __set_errno (serrno); + return 0; + } + else + return -1; + } +#else + /* On pre-/dev/ptmx kernels this function should be a no-op. */ + return 0; +#endif +} |