Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic permission fix message #3534

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions core/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@
];

foreach ($writable_check_paths as $path) {
if (is_dir($path) && !is_writable($path)) {
die('<p>Your website directory or a subdirectory is not writable. Please ensure all files and directories are owned by
the correct user.</p><p><strong>Example</strong> command to change owner recursively: <code>sudo chown -R www-data: ' . Output::getClean(ROOT_PATH) . '</code></p>');
if (is_dir($path) && is_writable($path)) {
$message = '<p>Your website directory or a subdirectory is not writable. Please ensure all files and directories are owned by
the correct user.</p>';

if (function_exists('posix_geteuid')) {
$uid = posix_geteuid();
$gid = posix_getegid();
$chown_command = 'sudo chown -R ' . $uid . ':' . $gid . ' ' . Output::getClean(ROOT_PATH);
$message .= '<p>The command to fix this for your system was determined to be: <code>' . $chown_command . '</code>. Please check if it makes sense before running it.</p>';
} else {
$message .= '<p><strong>Example</strong> command to change owner recursively: <code>sudo chown -R www-data: ' . Output::getClean(ROOT_PATH) . '</code></p>';
}

die($message);
}
}

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
- type: bind
source: .
target: /data
user: '1000' # set this to your user id!
user: '1000:1000' # set this to your user id!
depends_on: [php]
environment:
PHP_FPM: php:9000
Expand All @@ -42,7 +42,7 @@ services:
- type: bind
source: .
target: /data
user: '1000' # set this to your user id!
user: '1000:1000' # set this to your user id!
environment:
NAMELESS_HOSTNAME: localhost
NAMELESS_DATABASE_ADDRESS: db
Expand Down
Loading