aboutsummaryrefslogtreecommitdiff
path: root/app/install.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2021-01-23 17:04:01 -0500
committerGravatar GitHub <noreply@github.com> 2021-01-23 23:04:01 +0100
commit3e89086e45669de82c4005e11ded1ce8f60a1bc3 (patch)
tree1178c35dc1cdc3ce4d0055eb9889d597a731b1a0 /app/install.php
parent297d188a4689f5803fb91282f85646d5823b7e7e (diff)
Add username hint for permissions during install (#3373)
The username is retrieved by 2 different means to support different configurations and architectures. If there is no way to find the username, the "unknown" string is displayed instead. See #2758
Diffstat (limited to 'app/install.php')
-rw-r--r--app/install.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/app/install.php b/app/install.php
index cfd47910a..286e7cc69 100644
--- a/app/install.php
+++ b/app/install.php
@@ -363,17 +363,35 @@ function printStep0() {
}
function printStep1Template($key, $value, $messageParams = []) {
- $message = _t("install.check.{$key}.{$value}", ...$messageParams);
if ('ok' === $value) {
+ $message = _t("install.check.{$key}.ok", ...$messageParams);
?><p class="alert alert-success"><span class="alert-head"><?= _t('gen.short.ok') ?></span> <?= $message ?></p><?php
} else {
+ $message = _t("install.check.{$key}.nok", ...$messageParams);
?><p class="alert alert-error"><span class="alert-head"><?= _t('gen.short.damn') ?></span> <?= $message ?></p><?php
}
}
+function getProcessUsername() {
+ if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
+ $processUser = posix_getpwuid(posix_geteuid());
+ return $processUser['name'];
+ }
+
+ if (function_exists('exec')) {
+ exec('whoami', $output);
+ if (!empty($output[0])) {
+ return $output[0];
+ }
+ }
+
+ return _t('install.check.unknown_process_username');
+}
+
// @todo refactor this view with the check_install action
function printStep1() {
$res = checkRequirements();
+ $processUsername = getProcessUsername();
?>
<noscript><p class="alert alert-warn"><span class="alert-head"><?= _t('gen.short.attention') ?></span> <?= _t('install.javascript_is_better') ?></p></noscript>
@@ -388,11 +406,11 @@ function printStep1() {
printStep1Template('xml', $res['xml']);
printStep1Template('mbstring', $res['mbstring']);
printStep1Template('fileinfo', $res['fileinfo']);
- printStep1Template('data', $res['data'], [DATA_PATH]);
- printStep1Template('cache', $res['cache'], [CACHE_PATH]);
- printStep1Template('tmp', $res['tmp'], [TMP_PATH]);
- printStep1Template('users', $res['users'], [USERS_PATH]);
- printStep1Template('favicons', $res['favicons'], [DATA_PATH . '/favicons']);
+ printStep1Template('data', $res['data'], [DATA_PATH, $processUsername]);
+ printStep1Template('cache', $res['cache'], [CACHE_PATH, $processUsername]);
+ printStep1Template('tmp', $res['tmp'], [TMP_PATH, $processUsername]);
+ printStep1Template('users', $res['users'], [USERS_PATH, $processUsername]);
+ printStep1Template('favicons', $res['favicons'], [DATA_PATH . '/favicons', $processUsername]);
printStep1Template('http_referer', $res['http_referer']);
?>