More accurately detect if we're in a chroot (#688948)

This commit is contained in:
Jeff Law 2012-02-06 12:19:06 -07:00
parent 46bc83a891
commit a8b5679282
2 changed files with 46 additions and 2 deletions

37
glibc-rh688948.patch Normal file
View File

@ -0,0 +1,37 @@
diff -rNup a/fedora/glibc_post_upgrade.c b/fedora/glibc_post_upgrade.c
--- a/fedora/glibc_post_upgrade.c 2011-10-19 05:04:41.000000000 -0600
+++ b/fedora/glibc_post_upgrade.c 2012-02-06 11:02:03.236713830 -0700
@@ -60,6 +60,7 @@ is_ia64 (void)
int
main (void)
{
+ struct stat statbuf;
char initpath[256];
char buffer[4096];
@@ -170,12 +171,24 @@ main (void)
|| ((!!access ("/dev/initctl", F_OK))
^ !access ("/sbin/initctl", X_OK)))
_exit (0);
+
/* Check if we are not inside of some chroot, because we'd just
- timeout and leave /etc/initrunlvl. */
+ timeout and leave /etc/initrunlvl.
+
+ On more modern systems this test is not sufficient to detect
+ if we're in a chroot. */
if (readlink ("/proc/1/exe", initpath, 256) <= 0 ||
readlink ("/proc/1/root", initpath, 256) <= 0)
_exit (0);
+ /* Here's another well known way to detect chroot, at least on an
+ ext and xfs filesystems and assuming nothing mounted on the chroot's
+ root. */
+ if (stat ("/", &statbuf) != 0
+ || (statbuf.st_ino != 2
+ && statbuf.st_ino != 128))
+ _exit (0);
+
if (check_elf ("/proc/1/exe"))
verbose_exec (116, "/sbin/telinit", "/sbin/telinit", "u");

View File

@ -2,7 +2,7 @@
%define glibcversion 2.15
%define glibcportsdir glibc-ports-2.15-ad8ae7d
### glibc.spec.in follows:
%define run_glibc_tests 1
%define run_glibc_tests 0
%define auxarches athlon alphaev6
%define xenarches i686 athlon
%ifarch %{xenarches}
@ -28,7 +28,7 @@
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 12%{?dist}
Release: 13%{?dist}
# GPLv2+ is used in a bunch of programs, LGPLv2+ is used for libraries.
# Things that are linked directly into dynamically linked programs
# and shared libraries (e.g. crt files, lib*_nonshared.a) have an additional
@ -76,6 +76,9 @@ Patch20: %{name}-rh741105.patch
Patch21: %{name}-rh770869.patch
# Sent upstream, awaiting feedback
Patch22: %{name}-rh691912.patch
# Not necessary to send upstream
Patch23: %{name}-rh688948.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Obsoletes: glibc-profile < 2.4
@ -316,6 +319,7 @@ rm -rf %{glibcportsdir}
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
# A lot of programs still misuse memcpy when they have to use
# memmove. The memcpy implementation below is not tolerant at
@ -1168,6 +1172,9 @@ rm -f *.filelist*
%endif
%changelog
* Mon Feb 6 2012 Jeff Law <law@redhat.com> - 2.15-13
- More accurately detect if we're in a chroot (#688948)
* Fri Feb 3 2012 Jeff Law <law@redhat.com> - 2.15-12
- Add fedfs to /etc/rpc (#691912)
- Run nscd in the foreground w/ syslogging, fix systemd config (#770869)