Use PHP sys_temp_dir by default (#10428)

* Fix installer not generating tmp directory directive

This fixes a usecase when open_basedir is set, not allowing php to write to default temp directory /tmp.
In that case, temp directory is set by `php_admin_value[sys_temp_dir] = /var/www/site/tmp`
Without setting config['temp_dir'] in generated config.php, LibreNMS will use /tmp regardless of what is set in fpm configuration.

* is_writeable and is_writable are both valid, but let's stay consistent

* Make $config['temp_dir'] non static

* Remove $config['temp_dir'] from standard config.php

* Make sys_get_temp_dir() fallback to '/tmp'

* Update defaults.inc.php

* Update install.php

* Update Config.php

* Update defaults.inc.php

* Update defaults.inc.php
This commit is contained in:
Orsiris de Jong
2019-08-22 19:08:42 +02:00
committed by Neil Lathwood
parent f16805b71d
commit ccf2d9a5c5
2 changed files with 24 additions and 0 deletions

View File

@ -461,6 +461,7 @@ class Config
self::setDefault('log_dir', '%s/logs', ['install_dir']);
self::setDefault('log_file', '%s/%s.log', ['log_dir', 'project_id']);
self::setDefault('plugin_dir', '%s/plugins', ['html_dir']);
self::setDefault('temp_dir', sys_get_temp_dir() ?: '/tmp');
// self::setDefault('email_from', '"%s" <%s@' . php_uname('n') . '>', ['project_name', 'email_user']); // FIXME email_from set because alerting config
// deprecated variables

View File

@ -210,6 +210,29 @@ if ($status == 'no') {
}
}
echo "</td></tr>";
if (is_writable(Config::get('temp_dir'))) {
$status = 'yes';
$row_class = 'success';
} else {
$status = 'no';
$row_class = 'danger';
$complete = false;
}
echo "<tr class='$row_class'><td>Temporary directory writable</td><td>$status</td><td>";
if ($status == 'no') {
echo Config::get('temp_dir') . ' is not writable';
if (function_exists('posix_getgrgid')) {
$group_info = posix_getgrgid(filegroup(session_save_path()));
if ($group_info['gid'] !== 0) { // don't suggest adding users to the root group
$group = $group_info['name'];
$user = get_current_user();
echo ", suggested fix <strong>chown $user:$group $php_temp_dir</strong>";
}
}
}
echo "</td></tr>";
?>
</table>
</div>