I'm currently trying to get vsphere module to run, which requires the 
daemon to be started via icingacli. Unfortunately this doesn't work, 
because the module was enabled inside the chroot, which makes the 
destination path invalid for icingacli, which runs outside a chroot.

The following diff adds some extra logic to turn the absolute chroot
paths into relative paths.

This also allows us to enable and disable modules via icingacli
without breaking it inside the webroot.

OK?

martijn@

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/icinga/web2/Makefile,v
retrieving revision 1.28
diff -u -p -r1.28 Makefile
--- Makefile    22 Nov 2018 22:20:12 -0000      1.28
+++ Makefile    22 Jan 2019 06:42:59 -0000
@@ -6,6 +6,7 @@ GH_ACCOUNT =    Icinga
 GH_PROJECT =   icingaweb2
 GH_TAGNAME =   v2.6.2
 PKGNAME =      icinga-web2-${GH_TAGNAME:S/v//}
+REVISION =     0
 
 MODULES=       lang/php
 
Index: patches/patch-library_Icinga_Application_Modules_Manager_php
===================================================================
RCS file: patches/patch-library_Icinga_Application_Modules_Manager_php
diff -N patches/patch-library_Icinga_Application_Modules_Manager_php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-library_Icinga_Application_Modules_Manager_php        22 Jan 
2019 07:36:00 -0000
@@ -0,0 +1,36 @@
+$OpenBSD$
+
+Make icingacli <module> <command> available outside of chroot
+Index: library/Icinga/Application/Modules/Manager.php
+--- library/Icinga/Application/Modules/Manager.php.orig
++++ library/Icinga/Application/Modules/Manager.php
+@@ -285,7 +285,28 @@ class Manager
+             return $this;
+         }
+ 
+-        if (! @symlink($target, $link)) {
++        $relTarget = explode("/", $target);
++        $relLink = explode("/", $link);
++        while (end($relTarget) === "") {
++            array_pop($relTarget);
++        }
++        while (end($relLink) === "") {
++            array_pop($relLink);
++        }
++        while (reset($relTarget) === reset($relLink)) {
++            array_shift($relTarget);
++            array_shift($relLink);
++        }
++        array_pop($relLink);
++        if (empty($relLink)) {
++            array_unshift($relTarget, ".");
++        } else {
++            while (array_shift($relLink)) {
++                array_unshift($relTarget, "..");
++            }
++        }
++        $relTarget = implode("/", $relTarget);
++        if (! @symlink($relTarget, $link)) {
+             $error = error_get_last();
+             if (strstr($error["message"], "File exists") === false) {
+                 throw new SystemPermissionException(

Reply via email to