in reply to Re^2: [SOLVED] Configuring Apache VirtualHosts using mod_perl 2
in thread [SOLVED] Configuring Apache VirtualHosts using mod_perl 2

When getpwent returns undef, what is output of sub Fudge?
  • Comment on Re^3: [SOLVED] Configuring Apache VirtualHosts using mod_perl 2

Replies are listed 'Best First'.
Re^4: [SOLVED] Configuring Apache VirtualHosts using mod_perl 2
by FloydATC (Deacon) on Dec 03, 2014 at 14:17 UTC

    Let's see, I inserted the following into my Apache conf perl section:

    while ( my $user = getpwent() ) { $users{$user} = 1; } while ( my $group = getgrent() ) { $groups{$group} = 1; } open (my $fh, '>>', '/var/log/httpd/fudge.log'); print $fh Fudge(); close $fh; sub Fudge { use Errno(); join qq/\n/, "Error @_", map { " $_" } int( $! ) . q/ / . $!, int( $^E ) . q/ / . $^E, grep( { $!{$_} } keys %! ), q/ /; }

    Here's what I got after restarting httpd:

    Error 25 Inappropriate ioctl for device 25 Inappropriate ioctl for device ENOTTY Error 25 Inappropriate ioctl for device 25 Inappropriate ioctl for device ENOTTY

    All I can tell from this is that the config is indeed executed twice (as mentioned in the OP) but the actual messages don't mean much to me.

    If I had a gun pointed at me and had to guess, I'd say it has something to do with the environment presented to httpd by systemd.

    -- FloydATC

    Time flies when you don't know what you're doing

      All I can tell from this is that the config is indeed executed twice (as mentioned in the OP) but the actual messages don't mean much to me.

      Fudge() is only meaningful immediately after a system call, therefore

      my @fudge; while ( my $user = getpwent() ) { $users{$user} = 1; } push @fudge, Fudge(); while ( my $group = getgrent() ) { $groups{$group} = 1; } push @fudge, Fudge(); open (my $fh, '>>', '/var/log/httpd/fudge.log') or die Fudge("fudge.lo +g"); print $fh Fudge() or die Fudge("print fudge.log"); close $fh or die Fudge("close fudge.log"; undef @fudge; sub Fudge { use Errno(); join qq/\n/, "Error @_", map { " $_" } int( $! ) . q/ / . $!, int( $^E ) . q/ / . $^E, grep( { $!{$_} } keys %! ), q/ /; }

        Hmm. That didn't actually dump the array @fudge so I made one or two changes:

        # For the mongers my @fudge; while ( my $user = getpwent() ) { $users{$user} = 1; } push @fudge, Fudge()."\n"; while ( my $group = getgrent() ) { $groups{$group} = 1; } push @fudge, Fudge(),"\n"; open (my $fh, '>>', '/var/log/httpd/fudge.log') or die Fudge("fudge.lo +g"); print $fh Fudge() or die Fudge("print fudge.log"); foreach my $line (@fudge) { print $fh $line; } close $fh or die Fudge("close fudge.log"); undef @fudge; sub Fudge { use Errno(); join qq/\n/, "Error @_", map { " $_" } int( $! ) . q/ / . $!, int( $^E ) . q/ / . $^E, grep( { $!{$_} } keys %! ), q/ /; }

        Cleared the log and restarted httpd, this is what I got:

        $ cat /var/log/httpd/fudge.log Error 25 Inappropriate ioctl for device 25 Inappropriate ioctl for device ENOTTY Error 2 No such file or directory 2 No such file or directory ENOENT Error 2 No such file or directory 2 No such file or directory ENOENT Error 25 Inappropriate ioctl for device 25 Inappropriate ioctl for device ENOTTY Error 2 No such file or directory 2 No such file or directory ENOENT Error 2 No such file or directory 2 No such file or directory ENOENT
        -- FloydATC

        Time flies when you don't know what you're doing