File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env php
22<?php
3+
4+ declare (strict_types=1 );
5+
6+ /**
7+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
8+ * SPDX-License-Identifier: AGPL-3.0-or-later
9+ */
10+
311/**
4- * SPDX-FileCopyrightText: 2014 ownCloud, Inc.
5- * SPDX-FileCopyrightText: 2014 Olivier Paroz
6- * SPDX-FileCopyrightText: 2013 Thomas Müller <[email protected] > 7- * SPDX-License-Identifier: AGPL-3.0-only
12+ * Drop privileges when run as root
813 */
14+ function dropPrivileges (): void {
15+ if (posix_getuid () !== 0 ) {
16+ return ;
17+ }
18+
19+ $ configPath = __DIR__ . '/config/config.php ' ;
20+ $ uid = fileowner ($ configPath );
21+ if ($ uid === false ) {
22+ return ;
23+ }
24+ $ info = posix_getpwuid ($ uid );
25+ if ($ info === false ) {
26+ return ;
27+ }
28+ posix_setuid ($ uid );
29+ posix_setgid ($ info ['gid ' ]);
30+ }
931
10- //$argv = $_SERVER['argv'] ;
32+ dropPrivileges () ;
1133require_once __DIR__ . '/console.php ' ;
You can’t perform that action at this time.
0 commit comments