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

syntax error at /usr/sbin/spampd line 1386, near "}{" #30

Closed
realsimix opened this issue Jul 29, 2021 · 13 comments
Closed

syntax error at /usr/sbin/spampd line 1386, near "}{" #30

realsimix opened this issue Jul 29, 2021 · 13 comments

Comments

@realsimix
Copy link

Hi,

I've tried to update my spampd packages to 2.60 but got this error on RHEL7:

spampd: syntax error at /usr/sbin/spampd line 1386, near "}{"
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1387.
spampd: Global symbol "$k" requires explicit package name at /usr/sbin/spampd line 1388.
spampd: Global symbol "$k" requires explicit package name at /usr/sbin/spampd line 1388.
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1389.
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1389.
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1389.
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1390.
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1390.
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1390.
spampd: Global symbol "$k" requires explicit package name at /usr/sbin/spampd line 1391.
spampd: Global symbol "$v" requires explicit package name at /usr/sbin/spampd line 1391.
spampd: Global symbol "$exit" requires explicit package name at /usr/sbin/spampd line 1394.
spampd: Global symbol "$exit" requires explicit package name at /usr/sbin/spampd line 1394.
spampd: syntax error at /usr/sbin/spampd line 1395, near "}"
spampd: /usr/sbin/spampd has too many errors.

Commenting out the offending lines makes it start up:

--- /usr/sbin/spampd.orig	2021-07-28 17:00:23.000000000 +0200
+++ /usr/sbin/spampd	2021-07-29 12:25:18.402015655 +0200
@@ -1382,14 +1382,14 @@
   print "# Configuration options for ".ref($self)." v".$self->VERSION." with ".$type." values.\n";
   print "# This format is suitable as a configuration file. Just remove\n".
         "# the '#' marks (comment characters) and change values as needed.\n\n" if $exit > -1;
-  for my $k (sort keys %{$opts}) {
-    my $v = %{$opts}{$k};
-    next if ref($v) !~ /SCALAR|REF/;
-    $k = $1 if $k =~ /([\w-]+).*/;
-    $v = defined(${$v}) ? ${$v} : "(undefined)";
-    $v = join(":", @{$v}) if ref($v) eq 'ARRAY';
-    printf("# %-24s %s\n", $k, $v);
-  }
+#  for my $k (sort keys %{$opts}) {
+#    my $v = %{$opts}{$k};
+#    next if ref($v) !~ /SCALAR|REF/;
+#    $k = $1 if $k =~ /([\w-]+).*/;
+#    $v = defined(${$v}) ? ${$v} : "(undefined)";
+#    $v = join(":", @{$v}) if ref($v) eq 'ARRAY';
+#    printf("# %-24s %s\n", $k, $v);
+#  }

Maybe this is because perl is too old (perl-5.16.3)?
Do you have an idea how to make this work here?

Thank you from a long time spampd user,
Simon

@realsimix
Copy link
Author

Here is a second issue which I worked around by commenting out:

Error in option spec: "hh|??:s"
Error in option spec: "hhh|???:s"
Error in option spec: "hhhh|????|man:s"

@realsimix
Copy link
Author

And this one also:

Name "Data::Dumper::Sparseseen" used only once: possible typo at /usr/sbin/spampd line 1429.
Name "Data::Dumper::Quotekeys" used only once: possible typo at /usr/sbin/spampd line 1428.
Name "Data::Dumper::Sortkeys" used only once: possible typo at /usr/sbin/spampd line 1429.
Name "Data::Dumper::Bless" used only once: possible typo at /usr/sbin/spampd line 1428.

@mpaperno
Copy link
Owner

Hi Simon!

For the first one, please try replacing line 1386 with:

    my $v = $opts->{$k};

Not sure why I even used the other more obscure syntax in the first place.

Indeed, 5.16 is a bit dated... (though not as dated as spampd) :-) 5.28.1 is what I was mostly testing with... which is from 2018.

Error in option spec: "hh|??:s"

This is coming from Getopt::Long? If so I can only guess it's a version thing... since it's a Perl standard package. Not sure if you can update that separately... but in any case commenting those out won't hurt anything. I'd be curious if there was some version of those which worked (or what actually causes the error).

Name "Data::Dumper::Sparseseen" used only once: possible typo at /usr/sbin/spampd line 1429.

Is that an error or warning? I do vaguely remember those settings gave me some grief, but I'm not getting any errors or warnings now. I'll check their docs for clues. IIRC this should only affect the --show option... maybe there's an alternative for dumping arbitrary data objects.

Thanks for trying it and reporting!
-Max

@realsimix
Copy link
Author

realsimix commented Jul 29, 2021 via email

@mpaperno
Copy link
Owner

It works well this way!

Cool! I've got that queued up for an update.

On one of my test hosts it looks like it doesn't like multiple ?? in the definition.

Interesting... I guess I could just remove that syntax. Or make it Perl version dependent? It's always the small stuff!

Is there a way to silence the 4 messages created on lines 1428+1429?

I'm not sure... probably but I probably need to recreate it. I wish I could remember better now what my issue with those variables was before. I'm not even sure where exactly the messages are coming from at the moment.

But just to clarify, it runs OK, "just" with those annoying messages to stderr? And they appear even when not using any of the --show options?

Thanks!
-Max

@realsimix
Copy link
Author

realsimix commented Jul 29, 2021 via email

@realsimix
Copy link
Author

realsimix commented Jul 29, 2021 via email

@mpaperno
Copy link
Owner

Hi Simon, does it help to just add no warnings 'once';?

        use Data::Dumper;
        no warnings 'once';
        $Data::Dumper::Quotekeys = 0;
        $Data::Dumper::Bless = '';
        $Data::Dumper::Sortkeys = 1;
        $Data::Dumper::Sparseseen = 1;
        print("\n". Data::Dumper->Dump(\@dumps, \@dnames) ."\n");

I couldn't find any mention or record of Sparseseen being added anytime in the last decade, but there's plenty of references to those bogus warnings.

@mpaperno
Copy link
Owner

On one of my test hosts it looks like it doesn't like multiple ?? in the definition. Simply removing them seems to do it:

Could you try replacing from line 574 with the following?

  if (!$self->is_reloading()) {
    my ($q2, $q3, $q4) = ("|??", "|???", "|????");
    $q2 = $q3 = $q4 = "" if ($Getopt::Long::VERSION < 2.5);
    %options = (
      %options,
      'show=s@'           => \$spd_p->{show_dbg},
      'help|h|?:s'        => sub { $self->usage(0, 1, $_[1]); },
      'hh'.$q2.':s'       => sub { $self->usage(0, 2, $_[1]); },
      'hhh'.$q3.':s'      => sub { $self->usage(0, 3, $_[1]); },
      'hhhh'.$q4.'|man:s' => sub { $self->usage(0, 4, $_[1]); },
      'version|vers'      => sub { $self->version(); },
    );
  }

The version number is a bit of a guess but that's what I have installed and I know it works. I only see one relevant commit on this matter (sciurius/perl-Getopt-Long@0a8e314) but looks like it didn't make it until v2.51, so I'm not sure why it works with my v2.50.

Thanks!

@realsimix
Copy link
Author

realsimix commented Jul 30, 2021

Hi Maxim,

The no warnings 'once'; seems to do the trick. I've changed it back to require again because I think that was better:

        require Data::Dumper;
        no warnings 'once';
        $Data::Dumper::Quotekeys = 0;
        $Data::Dumper::Bless = '';
        $Data::Dumper::Sortkeys = 1;
        $Data::Dumper::Sparseseen = 1;
        print("\n". Data::Dumper->Dump(\@dumps, \@dnames) ."\n");

For the other issue with --??, it still doesn't work.

-?, --?, -h, --h, -hh, --hh, -hhh, --hhh they all work

-??, --?? -???... they don't work

Thanks,
Simon

@realsimix
Copy link
Author

My current patch for the -?? issue looks like this:

@@ -574,9 +574,9 @@ sub initial_options_map {
       %options,
       'show=s@'         => \$spd_p->{show_dbg},
       'help|h|?:s'      => sub { $self->usage(0, 1, $_[1]); },
-      'hh|??:s'         => sub { $self->usage(0, 2, $_[1]); },
-      'hhh|???:s'       => sub { $self->usage(0, 3, $_[1]); },
-      'hhhh|????|man:s' => sub { $self->usage(0, 4, $_[1]); },
+      'hh:s'            => sub { $self->usage(0, 2, $_[1]); },
+      'hhh:s'           => sub { $self->usage(0, 3, $_[1]); },
+      'hhhh|man:s'      => sub { $self->usage(0, 4, $_[1]); },
       'version|vers'    => sub { $self->version(); },
     );
   }
@@ -1595,9 +1594,9 @@ Options:
   --log-rules-hit or -rh     Log the names of each matched SA test per mail.
   --debug or -d [<areas>]    Controls extra debug logging.

-  --help | -h | -?   [txt]   Show basic command-line usage.
-          -hh | -??  [txt]   Show short option descriptions (this text).
-         -hhh | -??? [txt]   Show usage summary and full option descriptions.
+  --help | -h | -? [txt]     Show basic command-line usage.
+          -hh      [txt]     Show short option descriptions (this text).
+         -hhh      [txt]     Show usage summary and full option descriptions.
   --man [html|txt]           Show full docs a man page or HTML/plain text.
   --show defaults|<thing>    Print default option values or <thing> and exit.
   --version                  Print version information and exit.

@mpaperno
Copy link
Owner

Hi Simon,

Great on the silenced warnings, another one solved. Agreed about require and thanks for confirming that works.

My current patch for the -?? issue looks like this:

That's what my patch also does, essentially (removes the multi-? marks), except based on which Getopt::Long version it's running with. So...

For the other issue with --??, it still doesn't work.

If that means those options don't do anything on the command line, that would be correct (same as your patch). As long as the program runs w/out errors.

Unfortunately I don't know how to update the POD docs (and help text) dynamically as well! Probably not reasonably possible.

I'm actually trying to recreate the issue with ? marks and can't... trying different old Perls.. Could you run the following for me on one of the affected systems and tell me what the version number is?

perl -MGetopt::Long -e 'print $Getopt::Long::VERSION ."\n";'

Thanks,
-Max

@mpaperno
Copy link
Owner

perl -MGetopt::Long -e 'print $Getopt::Long::VERSION ."\n";'

Never mind... narrowed it down to v2.38... 2.39 works and sure enough there's a 10 yr old change there. sciurius/perl-Getopt-Long@ba1194f

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

No branches or pull requests

2 participants