Update.
* misc/daemon.c (daemon): Fail if !noclose and we cannot open the real /dev/null device. * sysdeps/generic/check_fds.c: Include device-nrs.h. * sysdeps/generic/device-nrs.h: New file. * sysdeps/unix/sysv/linux/device-nrs.h: New file. * misc/Makefile (distribute): Add device-nrs.h. * posix/wordexp.c (exec_comm_child): Likewise. * locale/nl_langinfo.c: Allow use of file for __nl_langinfo_l definition.
This commit is contained in:
parent
e5448d7ad2
commit
316ca440b0
12
ChangeLog
12
ChangeLog
@ -1,5 +1,13 @@
|
||||
2000-09-26 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* misc/daemon.c (daemon): Fail if !noclose and we cannot open the
|
||||
real /dev/null device.
|
||||
|
||||
* sysdeps/generic/check_fds.c: Include device-nrs.h.
|
||||
* sysdeps/generic/device-nrs.h: New file.
|
||||
* sysdeps/unix/sysv/linux/device-nrs.h: New file.
|
||||
* misc/Makefile (distribute): Add device-nrs.h.
|
||||
|
||||
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Use O_TRUNC to
|
||||
remove possible garbage at the end of the file.
|
||||
|
||||
@ -10,15 +18,17 @@
|
||||
* stdio-common/tempnam.c: Warn about insecure tempnam.
|
||||
* misc/mktemp.c: Warn about insecure mktemp.
|
||||
|
||||
* sysdeps/unix/sysv/linux/check_fds.c: New file.
|
||||
* sysdeps/generic/check_fds.c: Check that file opened is really
|
||||
/dev/null.
|
||||
* posix/wordexp.c (exec_comm_child): Likewise.
|
||||
|
||||
* elf/rtld.c (process_envvars): Open debug output file with O_NOFOLLOW.
|
||||
|
||||
* locale/Makefile (routines): Add nl_langinfo_l.
|
||||
* locale/Versions [libc] (GLIBC_2.2): Add __nl_langinfo_l.
|
||||
* locale/nl_langinfo_l.c: New file.
|
||||
* locale/nl_langinfo.c: Allow use of file for __nl_langinfo_l
|
||||
definition.
|
||||
|
||||
2000-09-23 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
|
@ -25,9 +25,16 @@
|
||||
|
||||
/* Return a string with the data for locale-dependent parameter ITEM. */
|
||||
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
char *
|
||||
__nl_langinfo_l (item, l)
|
||||
nl_item item;
|
||||
__locale_t l;
|
||||
#else
|
||||
char *
|
||||
nl_langinfo (item)
|
||||
nl_item item;
|
||||
#endif
|
||||
{
|
||||
int category = _NL_ITEM_CATEGORY (item);
|
||||
unsigned int index = _NL_ITEM_INDEX (item);
|
||||
@ -37,7 +44,11 @@ nl_langinfo (item)
|
||||
/* Bogus category: bogus item. */
|
||||
return (char *) "";
|
||||
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
data = l->__locales[category];
|
||||
#else
|
||||
data = *_nl_current[category];
|
||||
#endif
|
||||
|
||||
if (index >= data->nstrings)
|
||||
/* Bogus index for this category: bogus item. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991-1999, 2000 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
|
||||
@ -59,6 +59,8 @@ routines := brk sbrk sstk ioctl \
|
||||
getsysstats dirname regexp \
|
||||
getloadavg
|
||||
|
||||
distribute := device-nrs.h
|
||||
|
||||
include ../Makeconfig
|
||||
|
||||
aux := init-misc
|
||||
|
@ -34,6 +34,9 @@ static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <device-nrs.h>
|
||||
|
||||
int
|
||||
daemon(nochdir, noclose)
|
||||
@ -57,11 +60,23 @@ daemon(nochdir, noclose)
|
||||
(void)__chdir("/");
|
||||
|
||||
if (!noclose && (fd = __open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
|
||||
(void)__dup2(fd, STDIN_FILENO);
|
||||
(void)__dup2(fd, STDOUT_FILENO);
|
||||
(void)__dup2(fd, STDERR_FILENO);
|
||||
if (fd > 2)
|
||||
struct stat64 st;
|
||||
|
||||
if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) == 0
|
||||
&& __builtin_expect (S_ISCHR (st.st_mode), 1) != 0
|
||||
#if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR
|
||||
&& st.st_rdev == makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR)
|
||||
#endif
|
||||
) {
|
||||
(void)__dup2(fd, STDIN_FILENO);
|
||||
(void)__dup2(fd, STDOUT_FILENO);
|
||||
(void)__dup2(fd, STDERR_FILENO);
|
||||
if (fd > 2)
|
||||
(void)__close (fd);
|
||||
} else {
|
||||
(void)__close (fd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -44,6 +44,9 @@
|
||||
/* #define NDEBUG 1 */
|
||||
#include <assert.h>
|
||||
|
||||
/* Get some device information. */
|
||||
#include <device-nrs.h>
|
||||
|
||||
/*
|
||||
* This is a recursive-descent-style word expansion routine.
|
||||
*/
|
||||
@ -840,6 +843,7 @@ exec_comm_child (char *comm, int *fildes, int showerr, int noexec)
|
||||
/* Redirect stderr to /dev/null if we have to. */
|
||||
if (showerr == 0)
|
||||
{
|
||||
struct stat64 st;
|
||||
int fd;
|
||||
__close (2);
|
||||
fd = __open (_PATH_DEVNULL, O_WRONLY);
|
||||
@ -848,6 +852,18 @@ exec_comm_child (char *comm, int *fildes, int showerr, int noexec)
|
||||
__dup2 (fd, 2);
|
||||
__close (fd);
|
||||
}
|
||||
/* Be paranoid. Check that we actually opened the /dev/null
|
||||
device. */
|
||||
if (__builtin_expect (__fxstat64 (_STAT_VER, 2, &st), 0) != 0
|
||||
|| __builtin_expect (S_ISCHR (st.st_mode), 1) == 0
|
||||
#if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR
|
||||
|| st.st_rdev != makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR)
|
||||
#endif
|
||||
)
|
||||
/* It's not the /dev/null device. Stop right here. The
|
||||
problem is: how do we stop? We use _exit() with an
|
||||
hopefully unusual exit code. */
|
||||
_exit (90);
|
||||
}
|
||||
|
||||
/* Make sure the subshell doesn't field-split on our behalf. */
|
||||
|
@ -31,6 +31,8 @@
|
||||
# define ABORT_INSTRUCTION
|
||||
#endif
|
||||
|
||||
#include <device-nrs.h>
|
||||
|
||||
|
||||
/* Should other OSes (e.g., Hurd) have different versions which can
|
||||
be written in a better way? */
|
||||
|
25
sysdeps/generic/device-nrs.h
Normal file
25
sysdeps/generic/device-nrs.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* Device numbers of devices used in the implementation. Generic version.
|
||||
Copyright (C) 2000 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. */
|
||||
|
||||
#ifndef _DEVICE_NRS_H
|
||||
#define _DEVICE_NRS_H 1
|
||||
|
||||
/* By default we know no device numbers. */
|
||||
|
||||
#endif /* device-nrs.h */
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
/* Device numbers of devices used in the implementation. Linux version.
|
||||
Copyright (C) 2000 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,7 +17,11 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _DEVICE_NRS_H
|
||||
#define _DEVICE_NRS_H 1
|
||||
|
||||
/* /dev/null is (1,3). */
|
||||
#define DEV_NULL_MAJOR 1
|
||||
#define DEV_NULL_MINOR 3
|
||||
|
||||
#include <sysdeps/generic/check_fds.c>
|
||||
#endif /* device-nrs.h */
|
Loading…
Reference in New Issue
Block a user