[ic] Require include appears to be broken

Peter peter at pajamian.dhs.org
Thu Jul 8 10:44:26 UTC 2021


So I'm trying to do this to add a separate directory for user-specific 
perl modules for use with Interchange:

Require include /etc/interchange/lib

But getting this:

- - - [01/July/2021:09:18:50 -0400] - - Required  include not present. 
Aborting Interchange daemon.
 > In line 8 of the configuration file '/etc/interchange/interchange.cfg':

Short version: Is this intentional or a bug?


TLDR version:

So looking at the source code in Config.pm, the error message itself 
comes from line 2742:

    2740         else {
    2741                 $carptype = \&config_error;
    2742                 $error_message ||= 'Required %s %s not present. 
Aborting '
    2743                         . ($C ? 'catalog' : 'Interchange 
daemon') . '.';
    2744         }

...but is actually sent from line 2884:

    2879         for(@requires) {
    2880                 $vref->{"MV_REQUIRE_${uname}_$_"} = 1;
    2881                 next if defined $require->{$_};
    2882                 next if $testsub->($_);
    2883                 delete $vref->{"MV_REQUIRE_${uname}_$_"};
    2884                 $carptype->( $error_message, $name, $_ );
    2885         }

...so what's happening is that neither is a sub pushed to $require nor 
is $testsub set, I would have expected $testsub to be set on line 2840:

    2836         elsif ($val =~ s/^(?:perl)?include\s+//i) {
    2837                 my $path = Vend::File::make_absolute_file($val, 1);
    2838                 $require = {};
    2839                 $name = 'Perl include path';
    2840                 $testsub =
    2841                         sub {
    2842                                 if (-d $path) {
    2843                                         unshift @INC, $path;
    2844                                         return 1;
    2845                                 }
    2846                                 return 0;
    2847                         };
    2848         }

...but it isn't.  The key here is careful examination of the error 
message itself, there is a double-space between the words "Required" and 
"include".  This suggests that $name is not set but only $_.  Since 
$name should be set on line 2839 it suggests that the block of code from 
2836 to 2848 is not being run at all, which suggests that the regexp is 
not matching.  So a careful look at the regexp on line 2836 shows that 
it expects the word "perlinclude" or "include" followed by one or more 
whitespace characters.  "include /etc/interchange/lib" would seem to 
match this.

So after additional logging I found that this is affected by line 2728:

    2728         if($val =~ s%\s+((/[\w.-]+)+)%%) {
    2729                 $pathinfo = $1;
    2730         }

Where $val is trimmed to just "include" and the remainder is stored as a 
path in $pathinfo.  This includes removing the space that the regexp 
above is looking for, and therefore causing it to not match.

A bit more examination shows that this appears to affect some of the 
other "Require" commands as well.

So, either the regexp at line 2836 should be changed to allow for no 
space at the end, and to reference $pathinfo in the ensuing block, or 
line 2728 should be changed to not strip the space and following path 
from $val.

Looking for feedback before making any changes.


Peter


More information about the interchange-users mailing list