blob: e4dcc80c9da9f3df9e2c7aa779ef1d9af1960d86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/**
* Drop privileges when run as root
*/
function dropPrivileges(): void {
if (posix_getuid() !== 0) {
return;
}
$configPath = __DIR__ . '/config/config.php';
$uid = fileowner($configPath);
if ($uid === false) {
return;
}
$info = posix_getpwuid($uid);
if ($info === false) {
return;
}
posix_setuid($uid);
posix_setgid($info['gid']);
}
dropPrivileges();
require_once __DIR__ . '/console.php';
|