Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-analyzer/pnp4nagios/files/, net-analyzer/pnp4nagios/
Date: Sun, 06 Nov 2022 13:45:00
Message-Id: 1667741964.09842f299803969fff3faf26d75b5ab6f0f9c3c5.mjo@gentoo
1 commit: 09842f299803969fff3faf26d75b5ab6f0f9c3c5
2 Author: Tomáš Mózes <hydrapolic <AT> gmail <DOT> com>
3 AuthorDate: Sun Nov 6 11:26:22 2022 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 6 13:39:24 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=09842f29
7
8 net-analyzer/pnp4nagios: add snapshot with php 8.0 support
9
10 - adding latest snapshot from:
11 https://github.com/lingej/pnp4nagios/commits/master
12
13 - adding compatibility patches from:
14 https://github.com/Tontonitch/pnp4nagios
15
16 - adding php 8.0 patches that work on my instance
17
18 Closes: https://github.com/gentoo/gentoo/pull/28157
19 Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com>
20 Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>
21
22 net-analyzer/pnp4nagios/Manifest | 1 +
23 .../files/pnp4nagios-0.6.26_p20221106_compat.patch | 53 ++++++++++
24 .../files/pnp4nagios-0.6.26_p20221106_php80.patch | 42 ++++++++
25 .../pnp4nagios/pnp4nagios-0.6.26_p20221106.ebuild | 114 +++++++++++++++++++++
26 4 files changed, 210 insertions(+)
27
28 diff --git a/net-analyzer/pnp4nagios/Manifest b/net-analyzer/pnp4nagios/Manifest
29 index e33adf3e6b1d..083f4e6e612e 100644
30 --- a/net-analyzer/pnp4nagios/Manifest
31 +++ b/net-analyzer/pnp4nagios/Manifest
32 @@ -1 +1,2 @@
33 DIST pnp4nagios-0.6.26.tar.gz 3039265 BLAKE2B 1adb3c41222e6bc93671af955a1564387d77901ce118f5d309d101d88c691140e0feef1c2594bc5db44706ff01505a4fcf99b79b6a0c5b5cb923838dd00f1ff0 SHA512 caf6dcced74967174d9e6f09dd1a5bee17397c10a68d0f577c37dcc836f928d78c20d75a0189539e9ffa93715ab7b6e732e9f36b9698cf4dd9c09cfb65184427
34 +DIST pnp4nagios-0.6.26_p20221106.tar.gz 3029704 BLAKE2B 5866f4dbfef9b1028255eb3e47ac57fa260c1e2caca50fcb1c5ff93a3dc9bee9f14152e3a269ecf12daab59e50e1f4dfcd6513f9ce3dc5da35de50b944c38260 SHA512 cd0c3ad3d4983c43f7e1a100e8a2e6a530b573ca6bed60125c87b22ab33c2486c5ce99c6f52d641cdc7468984925a22a6ee7e1ac330ea2278ec2439acb910d04
35
36 diff --git a/net-analyzer/pnp4nagios/files/pnp4nagios-0.6.26_p20221106_compat.patch b/net-analyzer/pnp4nagios/files/pnp4nagios-0.6.26_p20221106_compat.patch
37 new file mode 100644
38 index 000000000000..21f9c89ed94f
39 --- /dev/null
40 +++ b/net-analyzer/pnp4nagios/files/pnp4nagios-0.6.26_p20221106_compat.patch
41 @@ -0,0 +1,53 @@
42 +# https://github.com/Tontonitch/pnp4nagios/commits/master
43 +
44 +diff --git a/share/pnp/application/views/graph_content.php b/share/pnp/application/views/graph_content.php
45 +index 3ea99dc0..00469ce0 100644
46 +--- a/share/pnp/application/views/graph_content.php
47 ++++ b/share/pnp/application/views/graph_content.php
48 +@@ -88,7 +88,8 @@
49 + # treated like a url fragment when zooming
50 + $gid = array();
51 + parse_str(ltrim($this->url, '?'), $gid);
52 +- $gid = htmlentities("?host=".urlencode($gid["host"])."&srv=".urlencode($gid["srv"]));
53 ++ $srv = isset($gid['srv']) ? $gid['srv'] : '';
54 ++ $gid = htmlentities("?host=".urlencode($gid["host"])."&srv=".urlencode($srv));
55 +
56 + echo "<div start=".$value['TIMERANGE']['start']." end=".$value['TIMERANGE']['end']." style=\"width:".$value['GRAPH_WIDTH']."px; height:".$value['GRAPH_HEIGHT']."px; position:absolute; top:33px\" class=\"graph\" id=\"".$gid."\" ></div>";
57 +
58 +diff --git a/share/pnp/application/vendor/fpdf/fpdf.php b/share/pnp/application/vendor/fpdf/fpdf.php
59 +index cfc09593..efb53b4e 100755
60 +--- a/share/pnp/application/vendor/fpdf/fpdf.php
61 ++++ b/share/pnp/application/vendor/fpdf/fpdf.php
62 +@@ -1040,8 +1040,11 @@ protected function _dochecks()
63 + if(ini_get('mbstring.func_overload') & 2)
64 + $this->Error('mbstring overloading must be disabled');
65 + // Ensure runtime magic quotes are disabled
66 +- if(get_magic_quotes_runtime())
67 +- @set_magic_quotes_runtime(0);
68 ++# if(get_magic_quotes_runtime())
69 ++# @set_magic_quotes_runtime(0);
70 ++ if (PHP_VERSION_ID < 70400 && get_magic_quotes_runtime()) {
71 ++ set_magic_quotes_runtime(0);
72 ++ }
73 + }
74 +
75 + protected function _checkoutput()
76 +diff --git a/share/pnp/application/vendor/fpdf/fpdi_pdf_parser.php b/share/pnp/application/vendor/fpdf/fpdi_pdf_parser.php
77 +index 9e6d521a..c044f200 100755
78 +--- a/share/pnp/application/vendor/fpdf/fpdi_pdf_parser.php
79 ++++ b/share/pnp/application/vendor/fpdf/fpdi_pdf_parser.php
80 +@@ -305,6 +305,7 @@ protected function _getPageRotation($obj)
81 + }
82 +
83 + $res = $this->_getPageRotation($obj[1][1]['/Parent']);
84 ++ if(false == $res) return false;
85 + if ($res[0] == pdf_parser::TYPE_OBJECT)
86 + return $res[1];
87 +
88 +@@ -344,4 +345,4 @@ protected function _readPages(&$pages, &$result)
89 + }
90 + }
91 + }
92 +-}
93 +\ No newline at end of file
94 ++}
95
96 diff --git a/net-analyzer/pnp4nagios/files/pnp4nagios-0.6.26_p20221106_php80.patch b/net-analyzer/pnp4nagios/files/pnp4nagios-0.6.26_p20221106_php80.patch
97 new file mode 100644
98 index 000000000000..2407bb6c51e9
99 --- /dev/null
100 +++ b/net-analyzer/pnp4nagios/files/pnp4nagios-0.6.26_p20221106_php80.patch
101 @@ -0,0 +1,42 @@
102 +diff --git a/lib/kohana/system/core/utf8.php b/lib/kohana/system/core/utf8.php
103 +index 9f20f42..b349c68 100644
104 +--- a/lib/kohana/system/core/utf8.php
105 ++++ b/lib/kohana/system/core/utf8.php
106 +@@ -49,17 +49,6 @@ if ( ! extension_loaded('iconv'))
107 + );
108 + }
109 +
110 +-if (extension_loaded('mbstring') AND (ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING))
111 +-{
112 +- trigger_error
113 +- (
114 +- 'The <a href="http://php.net/mbstring">mbstring</a> extension is overloading PHP\'s native string functions. '.
115 +- 'Disable this by setting mbstring.func_overload to 0, 1, 4 or 5 in php.ini or a .htaccess file.'.
116 +- 'This application cannot be run without UTF-8 support.',
117 +- E_USER_ERROR
118 +- );
119 +-}
120 +-
121 + // Check PCRE support for Unicode properties such as \p and \X.
122 + $ER = error_reporting(0);
123 + define('PCRE_UNICODE_PROPERTIES', (bool) preg_match('/^\pL$/u', 'ñ'));
124 +@@ -740,4 +729,4 @@ final class utf8 {
125 + return _from_unicode($arr);
126 + }
127 +
128 +-} // End utf8
129 +\ No newline at end of file
130 ++} // End utf8
131 +diff --git a/share/pnp/application/models/data.php b/share/pnp/application/models/data.php
132 +index 576c8ec..20cdade 100644
133 +--- a/share/pnp/application/models/data.php
134 ++++ b/share/pnp/application/models/data.php
135 +@@ -266,7 +266,7 @@ class Data_Model extends System_Model
136 + $xml = array();
137 + if (file_exists($xmlfile)) {
138 + libxml_use_internal_errors(TRUE);
139 +- libxml_clear_errors(TRUE);
140 ++ libxml_clear_errors();
141 + if(! $xml = simplexml_load_file($xmlfile) ){;
142 + if( $throw_exception == TRUE ){
143 + $errors = '<br>';
144
145 diff --git a/net-analyzer/pnp4nagios/pnp4nagios-0.6.26_p20221106.ebuild b/net-analyzer/pnp4nagios/pnp4nagios-0.6.26_p20221106.ebuild
146 new file mode 100644
147 index 000000000000..1ce42b2d29c9
148 --- /dev/null
149 +++ b/net-analyzer/pnp4nagios/pnp4nagios-0.6.26_p20221106.ebuild
150 @@ -0,0 +1,114 @@
151 +# Copyright 1999-2022 Gentoo Authors
152 +# Distributed under the terms of the GNU General Public License v2
153 +
154 +EAPI=8
155 +
156 +DESCRIPTION="A performance data analyzer for nagios"
157 +HOMEPAGE="http://www.pnp4nagios.org/"
158 +GH_COMMIT="5e09f538373ac4310a13355746bb3d3a10eb7bef"
159 +SRC_URI="https://github.com/lingej/pnp4nagios/archive/${GH_COMMIT}.tar.gz -> ${P}.tar.gz"
160 +S="${WORKDIR}/${PN}-${GH_COMMIT}"
161 +
162 +LICENSE="GPL-2"
163 +SLOT="0"
164 +IUSE="apache2 icinga +nagios"
165 +KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
166 +
167 +REQUIRED_USE="^^ ( icinga nagios )"
168 +
169 +# Some things (sync mode, for one) are broken with nagios-4.x, but since
170 +# nagios-3.x has been end-of-life'd, we don't have much choice here but
171 +# to accept it.
172 +DEPEND="net-analyzer/rrdtool[graph,perl]
173 + icinga? (
174 + acct-group/icinga
175 + acct-user/icinga
176 + )
177 + nagios? (
178 + acct-group/nagios
179 + acct-user/nagios
180 + )"
181 +
182 +# A list of modules used in our Apache config file.
183 +APACHE_MODS="apache2_modules_alias," # "Alias" directive
184 +APACHE_MODS+="apache2_modules_authz_core," # "Require" directive
185 +APACHE_MODS+="apache2_modules_rewrite" # "RewriteEngine" and friends
186 +
187 +RDEPEND="${DEPEND}
188 + dev-lang/php:*[filter,gd,json(+),simplexml,xml,zlib]
189 + media-fonts/dejavu
190 + virtual/perl-Getopt-Long
191 + virtual/perl-Time-HiRes
192 + apache2? ( >=www-servers/apache-2.4[${APACHE_MODS}] )"
193 +
194 +PATCHES=(
195 + "${FILESDIR}/${PN}-0.6.14-makefile.patch"
196 + "${FILESDIR}/${PN}-0.6.26_p20221106_compat.patch"
197 + "${FILESDIR}/${PN}-0.6.26_p20221106_php80.patch"
198 +)
199 +
200 +src_configure() {
201 + local user_group=nagios
202 + use icinga && user_group=icinga
203 +
204 + local myeconfargs=(
205 + --sysconfdir="${EPREFIX}"/etc/pnp
206 + --datarootdir="${EPREFIX}"/usr/share/pnp
207 + --localstatedir="${EPREFIX}"/var/lib/pnp
208 + --with-nagios-user="${user_group}"
209 + --with-nagios-group="${user_group}"
210 + --with-perfdata-logfile="${EPREFIX}"/var/log/pnp/process_perfdata.log
211 + )
212 +
213 + econf "${myeconfargs[@]}"
214 +}
215 +
216 +src_compile() {
217 + # The default target just shows a help
218 + emake all
219 +}
220 +
221 +src_install() {
222 + # Don't use INSTALL_OPTS because they set insecure permissions on
223 + # all of /etc/pnp (https://github.com/lingej/pnp4nagios/issues/140).
224 + emake INSTALL_OPTS="" DESTDIR="${D}" install install-config
225 + einstalldocs
226 + newinitd "${FILESDIR}"/npcd.initd npcd
227 + rm "${ED}/usr/share/pnp/install.php" || \
228 + die "unable to remove ${ED}/usr/share/pnp/install.php"
229 +
230 + # Fix CVE-2012-3457 (Gentoo bug 430358)
231 + fperms o-rwx /etc/pnp/process_perfdata.cfg
232 +
233 + if use apache2 ; then
234 + insinto /etc/apache2/modules.d
235 + newins "${FILESDIR}"/98_pnp4nagios-2.4.conf 98_pnp4nagios.conf
236 + fi
237 +
238 + # The nagios or icinga user needs to write performance data to the
239 + # perfdata-dir...
240 + local user_group=nagios
241 + use icinga && user_group=icinga
242 + fowners ":${user_group}" /var/lib/pnp/{,perfdata,spool}
243 + fperms g+rwx /var/lib/pnp/{,perfdata,spool}
244 +
245 + # and likewise for its logs...
246 + dodir /var/log/pnp
247 + fowners ":${user_group}" /var/log/pnp
248 + fperms g+rwx /var/log/pnp
249 +
250 + # and its statistics. This one is arguably the responsibility of the
251 + # build system, since process_perfdata.cfg refers to this location.
252 + dodir /var/lib/pnp/stats
253 + fowners ":${user_group}" /var/lib/pnp/stats
254 + fperms g+rwx /var/lib/pnp/stats
255 +}
256 +
257 +pkg_postinst() {
258 + elog "To enable the pnp4nagios web front-end, please visit"
259 + elog "${EROOT}/etc/conf.d/apache2 and add \"-D PNP -D PHP\""
260 + elog "to APACHE2_OPTS. Then pnp4nagios will be available at,"
261 + elog
262 + elog " http://localhost/pnp4nagios"
263 + elog
264 +}