This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=48e33c40691596b3bf91b86b50a8aa164b585639 The following commit(s) were added to refs/heads/main by this push: new 48e33c406 dpkg-fsys-usrunmess: Special case untracked kernel module files 48e33c406 is described below commit 48e33c40691596b3bf91b86b50a8aa164b585639 (HEAD -> main) Author: Guillem Jover <[email protected]> AuthorDate: Tue Mar 29 01:41:34 2022 +0200 dpkg-fsys-usrunmess: Special case untracked kernel module files Kernel module files are required as part of the system boot, so we need to make sure any such files gets moved or the system might end up not being able to boot, once the initramfs images get regenerated. In particular, kernel module files are easily found on systems as untracked pathnames in the filesystem, either from custom built kernels, or as part of modules built via machinery such as DKMS. One complication is that there appears to be some documentation referencing /usr/lib/modules/ pathnames for at least apache, python and ruby module locations. Which we do not want to be moving. To limit these unknowns, and as we are dealing with untracked pathnames, we will restrict moving subdirectories that start with a digit, which matches Linux and kFreeBSD module locations, in addition to the modprobe.conf filename. Closes: #1008316 --- scripts/dpkg-fsys-usrunmess.pl | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/scripts/dpkg-fsys-usrunmess.pl b/scripts/dpkg-fsys-usrunmess.pl index d11017101..526bf2297 100755 --- a/scripts/dpkg-fsys-usrunmess.pl +++ b/scripts/dpkg-fsys-usrunmess.pl @@ -27,6 +27,7 @@ our $ADMINDIR = '/var/lib/dpkg/'; use POSIX; use File::Temp qw(tempdir); +use File::Find; use Getopt::Long qw(:config posix_default bundling_values no_ignorecase); eval q{ @@ -149,6 +150,13 @@ my %aliased_pathnames; foreach my $dir (@aliased_dirs) { push @search_args, "$dir/*"; } + +# We also need to track /usr/lib/modules to then be able to compute its +# complement when looking for untracked kernel module files under aliased +# dirs. +my %usr_mod_pathnames; +push @search_args, "/usr/lib/modules/*"; + open my $fh_paths, '-|', 'dpkg-query', '--search', @search_args or fatal("cannot execute dpkg-query --search: $!"); while (<$fh_paths>) { @@ -191,6 +199,30 @@ foreach my $selection (@selections) { close $fh_alts; } +# +# Unfortunately we need to special case untracked kernel module files, +# as these are required for system booting. To reduce potentially moving +# undesired non-kernel module files (such as apache, python or ruby ones), +# we only look for sub-dirs starting with a digit, which should match for +# both Linux and kFreeBSD modules, and also for the modprobe.conf filename. +# + +find({ + no_chdir => 1, + wanted => sub { + my $path = $_; + + if (exists $aliased_pathnames{$path}) { + # Ignore pathname already handled. + } elsif (exists $usr_mod_pathnames{"/usr$path"}) { + # Ignore pathname owned elsewhere. + } else { + add_pathname($path, 'untracked modules'); + } + }, +}, glob '/lib/modules/[0-9]* /lib/modules/modprobe.conf'); + + my $sroot = '/.usrunmess'; my @relabel; @@ -545,7 +577,10 @@ sub add_pathname { my ($pathname, $origin) = @_; - if ($pathname =~ m/$aliased_regex/) { + if ($pathname =~ m{^/usr/lib/modules/}) { + debug("tracking $origin = $pathname"); + $usr_mod_pathnames{$pathname} = 1; + } elsif ($pathname =~ m/$aliased_regex/) { debug("adding $origin = $pathname"); $aliased_pathnames{$pathname} = 1; } -- Dpkg.Org's dpkg

