schwende has asked for the wisdom of the Perl Monks concerning the following question:

To preface, my knowledge of perl extends to, it exists. However, I am dealing with a script that broke, after an os upgrade. The person who wrote the script, is no longer around. It is also the only server with perl script left.
I have an old rhel 6.10 server, extended support ends in a few months. I can easily upgrade the server, no problem. The issue arises with 1 script. All the other cgi scripts work fine, but 1.
It is a script that checks for ldap users. I've tried changing the shebang to the new version of perl, after the os upgrade, 5.26.3. It was 5.10.x. I've checked permissions.
there are a number of files, in /usr/share/perl5. I assume that this ldap search, triggers 1 of these .pm files. But I don't know how to check and see if this is the case, or which .pm it might be.
I am not even sure what what else I can provide, that would be helpful.
Any ideas are welcome. If more info is needed, let me know, and I'll try to get it. I might have to sanitize sensitive parts, or course.

Thank you

Replies are listed 'Best First'.
Re: os upgrade breaks cgi
by hv (Prior) on Mar 07, 2024 at 19:53 UTC

    First question: what do you mean by "it broke"? Does it give an error message, or just give incorrect behaviour?

    By default, perl will include a filename and line number on fatal errors unless they terminate in a newline. You can also modify the script to make a fatal error give a full stack trace in most cases, by adding something like this just after the shebang line:

    BEGIN { use Carp; $SIG{__DIE__} = sub { Carp::confess(@_) } }

    If the script is completing without a fatal error, but giving incorrect behaviour, you can insert this just after the shebang line to get a list of the paths to all modules that were loaded up to the point the script finishes:

    END { print for values %INC }

      That SIG DIE line can be replaced with

      use Carp::Always;

      Assuming you first install the module, of course.

Re: os upgrade breaks cgi
by eyepopslikeamosquito (Archbishop) on Mar 08, 2024 at 04:58 UTC

    G'day schwende,

    I am dealing with a script that broke, after an os upgrade ... Any ideas are welcome

    I'm not a Web programmer, never written a CGI program, so I'll just offer a few general ideas ... hoping they're welcome. :-)

    As strongly cautioned by Fletch:

    If you're doing anything serious with Perl you DO NOT want to use the OS' perl as that way lies much pain. Doing so couples you tightly to the OS' upgrade schedule for both the language and (if you're using its package manager for them) CPAN modules.

    Many of us have learnt the hard way not to meddle with the system Perl on Unix systems. Much less pain to roll your own that you can control and freely experiment with, without risking breaking the system Perl, and without the risk of OS upgrades to the system Perl breaking your production systems. The same basic arguments apply to Python and other scripting languages BTW.

    All the other cgi scripts work fine, but 1.

    Anything stand out as different in the one that doesn't work? Do they all use CGI.pm? I ask because CGI.pm is no longer in the Perl core (the last Perl core that included it was perl v5.20). Posting representative code snippets from the one that doesn't work vs the many that do might provoke a useful response.

    See also Re^9: XML tags using perl CGI by hippo, which mentions a few low-fat CGI modules that are preferable to CGI.pm nowadays.

    👁️🍾👍🦟
Re: os upgrade breaks cgi
by LanX (Saint) on Mar 07, 2024 at 23:04 UTC
    The (most likely) short answer is that your new installation is lacking a non standard module. Check for use statements and install missing modules with your package manager if you rely on system perl.

    Re: os upgrade breaks cgi is the better long answer.

    Normally the error logs of your webserver should already include those messages.

    Many CGIs can also meaningfully be started from the command line to see if they even compile. Compare the two installations for differences.

    Of course, like already stated by hv we need to know "what it broke means" to avoid more guess work.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

Re: os upgrade breaks cgi
by perlfan (Parson) on Mar 08, 2024 at 19:52 UTC
    You likely need to reinstall/rebuild any non-core modules that originally created any compiled objects or required modules that did that. Start with the list of modules that your cgi uses.
Re: os upgrade breaks cgi
by nikosv (Deacon) on Mar 11, 2024 at 19:50 UTC
    Have you tried

    use CGI::Carp qw(fatalsToBrowser)

    ?
Re: os upgrade breaks cgi
by schwende (Initiate) on Mar 12, 2024 at 17:29 UTC
    I will check out some of these ideas. I'm not sure what modules were used for compiling, But I'll see what I can find. I'll also try the mod first suggested. Thanks! I at least have a couple directions to try.