[linux] 06/08: linux-image: prerm: Ignore version of running kernel inside a container or chroot
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Fri May 27 13:53:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch master
in repository linux.
commit 9f4d29bb042e6190767cdcb7b539caa2e5c79ea6
Author: Ben Hutchings <ben at decadent.org.uk>
Date: Thu May 26 23:27:56 2016 +0100
linux-image: prerm: Ignore version of running kernel inside a container or chroot
---
debian/changelog | 2 ++
debian/templates/image.prerm.in | 25 ++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 0bbc567..f360cf5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -24,6 +24,8 @@ linux (4.6-1~exp2) UNRELEASED; urgency=medium
* linux-image: Add workaround for bug #817083 in debconf
* linux-image: prerm: Allow removal of running kernel if we can't ask debconf
questions (Closes: #825423)
+ * linux-image: prerm: Ignore version of running kernel inside a container or
+ chroot
[ Aurelien Jarno ]
* [mips64{,el}] Set CPU to MIPS64 R2.
diff --git a/debian/templates/image.prerm.in b/debian/templates/image.prerm.in
index 2c1b8cf..df10e11 100755
--- a/debian/templates/image.prerm.in
+++ b/debian/templates/image.prerm.in
@@ -4,6 +4,7 @@ use strict;
use warnings;
use POSIX ();
use Debconf::Client::ConfModule qw(:all);
+use FileHandle;
version('2.0');
my $capb=capb("backup");
@@ -43,9 +44,31 @@ if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
}
+# Are we in a container? Check for $container in pid 1's environment.
+sub in_container {
+ my $res = 0;
+ if (my $fh = new FileHandle('/proc/1/environ', 'r')) {
+ local $/ = "\0";
+ $res = grep(/^container=/, <$fh>);
+ close($fh);
+ }
+ return $res;
+}
+
+
+# Are we in in a chroot? Compare root device and inode numbers with pid 1.
+sub in_chroot {
+ my @my_root_st = stat('/');
+ my @pid1_root_st = stat('/proc/1/root');
+
+ return @my_root_st && @pid1_root_st &&
+ ($my_root_st[0] != $pid1_root_st[0] || $my_root_st[1] != $pid1_root_st[1]);
+}
+
+
# Check to see if we are trying to remove a running kernel.
chop($running=`uname -r`);
-if ($running eq $version) {
+if (!in_container() && !in_chroot() && $running eq $version) {
# If we can ask debconf questions, ask whether that's intended
# and abort if not.
if (exists($ENV{'DEBIAN_FRONTEND'}) &&
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git
More information about the Kernel-svn-changes
mailing list