openbsd-ports/net/icinga/web2/patches/patch-modules_setup_applica...

51 lines
3.3 KiB
Plaintext

Minimal patches to avoid showing confusing path to users in the welcome
screen (PHP is normally run chroot'ed on OpenBSD), and use group "_icingaweb2"
as per OpenBSD standard naming for groups from packages.
We don't have head -c / base64, use an alternative.
Index: modules/setup/application/views/scripts/form/setup-welcome.phtml
--- modules/setup/application/views/scripts/form/setup-welcome.phtml.orig
+++ modules/setup/application/views/scripts/form/setup-welcome.phtml
@@ -8,7 +8,7 @@ use Icinga\Web\Wizard;
$phpUser = Platform::getPhpUser();
$configDir = Icinga::app()->getConfigDir();
$setupTokenPath = rtrim($configDir, '/') . '/setup.token';
-$cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');
+$cliPath = '/var/www/icinga-web2/bin/icingacli';
$groupadd = null;
$docker = getenv('ICINGAWEB_OFFICIAL_DOCKER_IMAGE');
@@ -84,11 +84,11 @@ if (! (false === ($distro = Platform::getLinuxDistro(1
<?php if (! $docker): ?>
<p><?= $this->translate('In any case, make sure that all of the following applies to your environment:'); ?></p>
<ul>
- <li><?= $this->translate('A system group called "icingaweb2" exists'); ?></li>
+ <li><?= $this->translate('A system group called "_icingaweb2" exists'); ?></li>
<?php if ($phpUser): ?>
- <li><?= sprintf($this->translate('The user "%s" is a member of the system group "icingaweb2"'), $phpUser); ?></li>
+ <li><?= sprintf($this->translate('The user "%s" is a member of the system group "_icingaweb2"'), $phpUser); ?></li>
<?php else: ?>
- <li><?= $this->translate('Your webserver\'s user is a member of the system group "icingaweb2"'); ?></li>
+ <li><?= $this->translate('Your webserver\'s user is a member of the system group "_icingaweb2"'); ?></li>
<?php endif ?>
</ul>
<?php if (! ($groupadd === null || $usermod === null)) { ?>
@@ -101,14 +101,14 @@ if (! (false === ($distro = Platform::getLinuxDistro(1
<?php endif; ?>
<div class="code">
<?php if (! $docker): ?>
- <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup config directory --group icingaweb2<?= $configDir !== '/etc/icingaweb2' ? ' --config ' . $configDir : ''; ?>;</span>
+ <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup config directory --group _icingaweb2<?= $configDir !== '/etc/icingaweb2' ? ' --config ' . $configDir : ''; ?>;</span>
<?php endif; ?>
<span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup token create;</span>
</div>
<?php if (! $docker): ?>
<p><?= $this->translate('In case the IcingaCLI is missing you can create the token manually:'); ?></p>
<div class="code">
- <span>su <?= $phpUser ?: $this->translate('<your-webserver-user>'); ?> -s /bin/sh -c "mkdir -m 2770 <?= dirname($setupTokenPath); ?>; chgrp icingaweb2 <?= dirname($setupTokenPath); ?>; head -c 12 /dev/urandom | base64 | tee <?= $setupTokenPath; ?>; chmod 0660 <?= $setupTokenPath; ?>;";</span>
+ <span>su <?= $phpUser ?: $this->translate('<your-webserver-user>'); ?> -s /bin/sh -c "mkdir -m 2770 <?= dirname($setupTokenPath); ?>; chgrp _icingaweb2 <?= dirname($setupTokenPath); ?>; openssl rand -base64 12 | tee <?= $setupTokenPath; ?>; chmod 0660 <?= $setupTokenPath; ?>;";</span>
</div>
<?php endif; ?>
<p><?= sprintf(