pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/50772: perl and check_interpreter



>Number:         50772
>Category:       pkg
>Synopsis:       hard linked perl returns surprising name in $^X
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 05 15:05:00 +0000 2016
>Originator:     Patrick Welche
>Release:        NetBSD 7.99.26
>Organization:
>Environment:
NetBSD-7.99.26/amd64 and pkgsrc-current
>Description:
Our perl package installs perl as "perl" and as a binary with the
version number in the name, as hard links, e.g.:

$ ls -li /usr/pkg/bin/perl*
18781554 -rwxr-xr-x  2 root  wheel  11103 Dec 29 12:05 /usr/pkg/bin/perl
18781554 -rwxr-xr-x  2 root  wheel  11103 Dec 29 12:05 /usr/pkg/bin/perl5.22.1
...

The output of the following script comes as a surprise:
$ cat foo.pl
#! /usr/pkg/bin/perl
print "$^X\n"; # $EXECUTABLE_NAME in English
$ ./foo.pl
/usr/pkg/bin/perl5.22.1

Breaking the hard link with
# mv /usr/pkg/bin/perl5.22.1 /tmp; mv /tmp/perl5.22.1 /usr/pkg/bin

gets the expected:
$ ./foo.pl
/usr/pkg/bin/perl


This matters for rc.d scripts using command_interpreter="@PERL5@" to work
as rc.subr's _find_processes tries to match the command_interpreter
even given a valid pid file.

This manifested itself with spamassassin's spamd: on reload, it execs
itself with $^X, after which command_interpreter no longer matches and
status will show "not running".
>How-To-Repeat:
run
/etc/rc.d/spamd start
/etc/rc.d/spamd status
/etc/rc.d/spamd reload
/etc/rc.d/spamd status
>Fix:
Many possibilities, but which is closest to "correct"?
1) Don't hard link, but copy /usr/pkg/bin/perl.
2) Patch spamd to exec $perl_from_hashbang_line instead of $EXECUTABLE_NAME
   ( = $^X).
3) Patch /etc/rc.d/spamd to avoid using rc.subr with its command_interpreter
   checks.
4) Patch /etc/rc.subr to override procname match given pidfile.



Home | Main Index | Thread Index | Old Index