Bug#999921: xymon: depends on obsolete pcre3 library

2024-02-12 Thread Yavor Doganov
Hi Roland,

Roland Rosenfeld wrote:
> Oh, now I see the problem: pcre_copy_substring() returns the length of
> the string on match, while pcre2_substring_copy_bynumber() returns 0
> on success.  So the above has to be changed from "> 0" to "== 0".

Of course...  Many thanks for finding and fixing my mistakes!

> For showgraph.c this fixes the issue, but there are more places where
> the return code of pcre2_substring_copy_bynumber() is checked, which
> also may need adoption.  I found the following places:

Right, thanks again.  Have you found some other issues?  I tried to
trigger as much PCRE-related code as possible but as I'm not familiar
with this program I'm afraid I couldn't manage.



Bug#999921: xymon: depends on obsolete pcre3 library

2024-02-12 Thread Roland Rosenfeld
Hi Yavor!

> This one seems to loose the @RRDPARAM@ parameter when calling rrdtool,
> if the pcre2 patch is applied.  I'm still debugging but didn't find
> out yet why this happens, since the patch doesn't seem to touch
> rrdparam.

Digging deeper shows me, that the issue seems to be in the following
part of the patch:

--- xymon.orig/web/showgraph.c
+++ xymon/web/showgraph.c
@@ -1021,7 +1027,7 @@
 
/* We have a matching file! */
rrddbs[rrddbcount].rrdfn = strdup(d->d_name);
-   if (pcre_copy_substring(d->d_name, ovector, result, 1, 
param, sizeof(param)) > 0) {
+   if (pcre2_substring_copy_bynumber(ovector, 1, param, 
) > 0) {
/*
 * This is ugly, but I cannot find a pretty way 
of un-mangling
 * the disk- and http-data that has been 
molested by the back-end.

Debugging this, I see, that rrddbs[rrddbcount].rrdfn is filled (for
example with "inode,root.rrd" or "inode,var.rrd" or the like), but
after this I observe that the "else" part of
  if (pcre2_substring_copy_bynumber(ovector, 1, param, ) > 0)
is executed (while I expected that the "then" part is executed where
  rrddbs[rrddbcount].rrdparam
should be set to some useful value (while it now is set to NULL in the
else part).

Oh, now I see the problem: pcre_copy_substring() returns the length of
the string on match, while pcre2_substring_copy_bynumber() returns 0
on success.  So the above has to be changed from "> 0" to "== 0".

+   if (pcre2_substring_copy_bynumber(ovector, 1, param, 
) == 0) {

For showgraph.c this fixes the issue, but there are more places where
the return code of pcre2_substring_copy_bynumber() is checked, which
also may need adoption.  I found the following places:

 --- a/lib/acknowledgementslog.c
 +++ b/lib/acknowledgementslog.c
@@ -1083,7 +1084,7 @@ Last-Update: 2023-12-21
/* We have a matching file! */
rrddbs[rrddbcount].rrdfn = strdup(d->d_name);
 -  if (pcre_copy_substring(d->d_name, ovector, result, 1, 
param, sizeof(param)) > 0) {
-+  if (pcre2_substring_copy_bynumber(ovector, 1, param, 
) > 0) {
++  if (pcre2_substring_copy_bynumber(ovector, 1, param, 
) == 0) {
/*
 * This is ugly, but I cannot find a pretty way 
of un-mangling
 * the disk- and http-data that has been 
molested by the back-end.
@@ -1240,7 +1241,7 @@ Last-Update: 2023-12-21
char delaytxt[4096];
 -  if (pcre_copy_substring(subjectline, ovector, result, 1, 
delaytxt, sizeof(delaytxt)) > 0) {
 +  l = sizeof(delaytxt);
-+  if (pcre2_substring_copy_bynumber(ovector, 1, delaytxt, ) > 
0) {
++  if (pcre2_substring_copy_bynumber(ovector, 1, delaytxt, ) == 
0) {
duration = durationvalue(delaytxt);
}
}
@@ -1261,7 +1262,7 @@ Last-Update: 2023-12-21
char msgtxt[4096];
 -  if (pcre_copy_substring(subjectline, ovector, result, 1, 
msgtxt, sizeof(msgtxt)) > 0) {
 +  l = sizeof(msgtxt);
-+  if (pcre2_substring_copy_bynumber(ovector, 1, msgtxt, ) > 0) {
++  if (pcre2_substring_copy_bynumber(ovector, 1, msgtxt, ) == 0) 
{
firsttxtline = strdup(msgtxt);
}
}
diff --git a/web/showgraph.c b/web/showgraph.c
index c6b891e..b3741ac 100644
--- a/web/showgraph.c
+++ b/web/showgraph.c
@@ -1027,7 +1027,7 @@ void generate_graph(char *gdeffn, char *rrddir, char 
*graphfn)
 
/* We have a matching file! */
rrddbs[rrddbcount].rrdfn = strdup(d->d_name);
-   if (pcre2_substring_copy_bynumber(ovector, 1, param, 
) > 0) {
+   if (pcre2_substring_copy_bynumber(ovector, 1, param, 
) == 0) {
/*
 * This is ugly, but I cannot find a pretty way 
of un-mangling
 * the disk- and http-data that has been 
molested by the back-end.
diff --git a/xymond/xymon-mailack.c b/xymond/xymon-mailack.c
index 1c66942..7ee7cc0 100644
--- a/xymond/xymon-mailack.c
+++ b/xymond/xymon-mailack.c
@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
if (result >= 0) {
char delaytxt[4096];
l = sizeof(delaytxt);
-   if (pcre2_substring_copy_bynumber(ovector, 1, delaytxt, ) > 
0) {
+   if (pcre2_substring_copy_bynumber(ovector, 1, delaytxt, ) == 
0) {
duration = durationvalue(delaytxt);
}
}
@@ -145,7 +145,7 @@ int main(int argc, char *argv[])
if (result >= 0) {
char msgtxt[4096];
   

Bug#999921: xymon: depends on obsolete pcre3 library

2024-02-12 Thread Roland Rosenfeld
Hi Yavor!

On Do, 21 Dez 2023, Yavor Doganov wrote:

> Please find a patch which I've been testing for a while with no ill
> effects AFAICT.  However, I'm not familiar at all with this package so
> it's possible that I've missed something.  I also couldn't test all
> available functionality.

Really great job!  I was still hoping, that someone will do this.
I just tried it out and it works very good, except an issue in
web/showgraph.c.

This one seems to loose the @RRDPARAM@ parameter when calling rrdtool,
if the pcre2 patch is applied.  I'm still debugging but didn't find
out yet why this happens, since the patch doesn't seem to touch
rrdparam.

Greetings
Roland



Bug#999921: xymon: depends on obsolete pcre3 library

2023-12-21 Thread Axel Beckert
Hi Yavor,

Yavor Doganov wrote:
> Please find a patch which I've been testing for a while with no ill
> effects AFAICT.  However, I'm not familiar at all with this package so
> it's possible that I've missed something.  I also couldn't test all
> available functionality.

Thanks a lot also for that patch! I have enough servers and clients
around to test the patch. (And thanks in general that you seemingly
crawl through all these annoying PCRE3→2 bugs and provide patches.
Much appreciated!)

Upstream said, they're having it on their roadmap, too, but I haven't
seen anything in that direction yet in the upstream SVN repo. (And I'm
tracking trunk.)

So I'll also forward the patch there, maybe first notify them, then
test it and then forward it.

> Unfortunately the patch does not apply cleanly to the latest upstream
> release (4.4-alpha) but I am ready and willing to rebase it, whenever
> you decide to package it.  Just let me know.

Also on my todo list, but that's first planned for experimental, not
yet unstable.

So I wouldn't say no to a rebased patch set for 4.4alpha as that's
where upstream is currently working on.

Will likely work on these (and ccze) over the holidays.

Regards, Axel
-- 
 ,''`.  |  Axel Beckert , https://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5
  `-|  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE



Bug#999921: xymon: depends on obsolete pcre3 library

2023-12-21 Thread Yavor Doganov
Control: tags -1 + patch

Please find a patch which I've been testing for a while with no ill
effects AFAICT.  However, I'm not familiar at all with this package so
it's possible that I've missed something.  I also couldn't test all
available functionality.

Unfortunately the patch does not apply cleanly to the latest upstream
release (4.4-alpha) but I am ready and willing to rebase it, whenever
you decide to package it.  Just let me know.
>From d626686d8e004bbb9e1f5f0074ff825f27d1c2e5 Mon Sep 17 00:00:00 2001
From: Yavor Doganov 
Date: Thu, 21 Dec 2023 18:44:44 +0200
Subject: [PATCH] Port to PCRE2 (#21).

---
 debian/changelog  |5 +
 debian/control|2 +-
 debian/patches/93_pcre2.patch | 2167 +
 debian/patches/series |1 +
 debian/rules  |2 +-
 5 files changed, 2175 insertions(+), 2 deletions(-)
 create mode 100644 debian/patches/93_pcre2.patch

diff --git a/debian/changelog b/debian/changelog
index b406ada..1c01d47 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -37,6 +37,11 @@ xymon (4.3.30-2) UNRELEASED; urgency=medium
   * xymon: update xymonserver.cfg: ntpdate obsoleted the "-p" option.
 (Closes: #1057044)
 
+  [ Yavor Doganov ]
+  * debian/patches/93_pcre2.patch: New; port to PCRE2 (Closes: #21).
+  * debian/control (Build-Depends): Replace libpcre3-dev with libpcre2-dev.
+  * debian/rules (override_dh_auto_configure): Use pcre2-config.
+
  -- Axel Beckert   Mon, 10 Aug 2020 04:39:28 +0200
 
 xymon (4.3.30-1) unstable; urgency=medium
diff --git a/debian/control b/debian/control
index 6766762..aaa40b3 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Build-Depends: debhelper-compat (= 13),
imagemagick,
libc-ares-dev,
libldap2-dev,
-   libpcre3-dev,
+   libpcre2-dev,
librrd-dev,
libssl-dev,
libtirpc-dev,
diff --git a/debian/patches/93_pcre2.patch b/debian/patches/93_pcre2.patch
new file mode 100644
index 000..7c163fd
--- /dev/null
+++ b/debian/patches/93_pcre2.patch
@@ -0,0 +1,2167 @@
+Description: Port to PCRE2.
+Bug-Debian: https://bugs.debian.org/21
+Author: Yavor Doganov 
+Forwarded: no
+Last-Update: 2023-12-21
+---
+
+--- xymon.orig/lib/acknowledgementslog.c
 xymon/lib/acknowledgementslog.c
+@@ -26,7 +26,8 @@
+ #include 
+ #include 
+ 
+-#include 
++#define PCRE2_CODE_UNIT_WIDTH 8
++#include 
+ 
+ #include "libxymon.h"
+ 
+@@ -103,16 +104,17 @@
+   char title[200];
+ 
+   /* For the PCRE matching */
+-  const char *errmsg = NULL;
+-  int errofs = 0;
+-  pcre *pageregexp = NULL;
+-  pcre *expageregexp = NULL;
+-  pcre *hostregexp = NULL;
+-  pcre *exhostregexp = NULL;
+-  pcre *testregexp = NULL;
+-  pcre *extestregexp = NULL;
+-  pcre *rcptregexp = NULL;
+-  pcre *exrcptregexp = NULL;
++  int err;
++  PCRE2_SIZE errofs;
++  pcre2_code *pageregexp = NULL;
++  pcre2_code *expageregexp = NULL;
++  pcre2_code *hostregexp = NULL;
++  pcre2_code *exhostregexp = NULL;
++  pcre2_code *testregexp = NULL;
++  pcre2_code *extestregexp = NULL;
++  pcre2_code *rcptregexp = NULL;
++  pcre2_code *exrcptregexp = NULL;
++  pcre2_match_data *ovector;
+ 
+   if (maxminutes && (fromtime || totime)) {
+   fprintf(output, "Only one time interval type is 
allowed!");
+@@ -147,14 +149,14 @@
+ 
+   if (!maxcount) maxcount = 100;
+ 
+-  if (pageregex && *pageregex) pageregexp = pcre_compile(pageregex, 
PCRE_CASELESS, , , NULL);
+-  if (expageregex && *expageregex) expageregexp = 
pcre_compile(expageregex, PCRE_CASELESS, , , NULL);
+-  if (hostregex && *hostregex) hostregexp = pcre_compile(hostregex, 
PCRE_CASELESS, , , NULL);
+-  if (exhostregex && *exhostregex) exhostregexp = 
pcre_compile(exhostregex, PCRE_CASELESS, , , NULL);
+-  if (testregex && *testregex) testregexp = pcre_compile(testregex, 
PCRE_CASELESS, , , NULL);
+-  if (extestregex && *extestregex) extestregexp = 
pcre_compile(extestregex, PCRE_CASELESS, , , NULL);
+-  if (rcptregex && *rcptregex) rcptregexp = pcre_compile(rcptregex, 
PCRE_CASELESS, , , NULL);
+-  if (exrcptregex && *exrcptregex) exrcptregexp = 
pcre_compile(exrcptregex, PCRE_CASELESS, , , NULL);
++  if (pageregex && *pageregex) pageregexp = pcre2_compile(pageregex, 
strlen(pageregex), PCRE2_CASELESS, , , NULL);
++  if (expageregex && *expageregex) expageregexp = 
pcre2_compile(expageregex, strlen(expageregex), PCRE2_CASELESS, , , 
NULL);
++  if (hostregex && *hostregex) hostregexp = pcre2_compile(hostregex, 
strlen(hostregex), PCRE2_CASELESS, , , NULL);
++  if (exhostregex && *exhostregex) exhostregexp = 
pcre2_compile(exhostregex, strlen(exhostregex), PCRE2_CASELESS, , , 
NULL);
++  if (testregex && *testregex) testregexp = pcre2_compile(testregex, 
strlen(testregex), 

Processed: Re: Bug#999921: xymon: depends on obsolete pcre3 library

2023-12-21 Thread Debian Bug Tracking System
Processing control commands:

> tags -1 + patch
Bug #999921 [src:xymon] xymon: depends on obsolete pcre3 library
Added tag(s) patch.

-- 
21: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=21
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems