Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix blacklisting of perl files via blacklist_interp #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bugfood
Copy link
Contributor

@bugfood bugfood commented Dec 6, 2024

In 0f80a34, the files() method started returning paths like:

/proc/521178/root//usr/share/perl5/Foo/Bar.pm

...rather than:

/usr/share/perl5/Foo/Bar.pm

This breaks the use of configuration such as:

$nrconf{blacklist_interp} = [
    @{$nrconf{blacklist_interp}},
    qr(^/usr/share/perl5/Foo/),
];

If I understand correctly, the intent is to scan files within the per-process root as described in proc_pid_root(5). This patch should still respect that.

Notes:

  • The code is already statting files within the per-process root; without this patch, the paths to stat have /proc/<pid>/root/ prepended twice, resulting in e.g.: /proc/521178/root//proc/521178/root//usr/share/perl5/Foo/Bar.pm With this patch, /proc/<pid>/root/ is only prepended once.
  • Without this patch, when files are read in _scan(), the executable script (e.g. /usr/local/bin/foo.pl) is not opened using the path to the per-process root. With this patch, all files are opened using the per-process root.
  • With this patch, needrestart -v prints paths without the per-process root, matching earlier behavior.
  • This behavior may apply to other interpreters as well; I have only examined the handling of Perl.

In 0f80a34, the files() method started
returning paths like:

    /proc/521178/root//usr/share/perl5/Foo/Bar.pm

...rather than:

    /usr/share/perl5/Foo/Bar.pm

This breaks the use of configuration such as:

    $nrconf{blacklist_interp} = [
        @{$nrconf{blacklist_interp}},
        qr(^/usr/share/perl5/Foo/),
    ];

If I understand correctly, the intent is to scan files within the
per-process root as described in proc_pid_root(5). This patch should
still respect that.

Notes:
* The code is already statting files within the per-process root;
  without this patch, the paths to stat have `/proc/<pid>/root/`
  prepended twice, resulting in e.g.:
  `/proc/521178/root//proc/521178/root//usr/share/perl5/Foo/Bar.pm`
  With this patch, `/proc/<pid>/root/` is only prepended once.
* Without this patch, when files are read in _scan(), the executable
  script (e.g. `/usr/local/bin/foo.pl`) is not opened using the path to
  the per-process root. With this patch, all files are opened using the
  per-process root.
* With this patch, `needrestart -v` prints paths without the per-process
  root, matching earlier behavior.
* This behavior may apply to other interpreters as well; I have only
  examined the handling of Perl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant