MediaWiki master
SqliteUtils.php
Go to the documentation of this file.
1<?php
2
4
6
16 public function checkDataDir( $dir ): Status {
17 if ( is_dir( $dir ) ) {
18 if ( !is_readable( $dir ) ) {
19 return Status::newFatal( 'config-sqlite-dir-unwritable', $dir );
20 }
21 } elseif ( !is_writable( dirname( $dir ) ) ) {
22 // Check the parent directory if $dir not exists
23 $webserverGroup = $this->maybeGetWebserverPrimaryGroup();
24 if ( $webserverGroup !== null ) {
25 return Status::newFatal(
26 'config-sqlite-parent-unwritable-group',
27 $dir, dirname( $dir ), basename( $dir ),
28 $webserverGroup
29 );
30 }
31
32 return Status::newFatal(
33 'config-sqlite-parent-unwritable-nogroup',
34 $dir, dirname( $dir ), basename( $dir )
35 );
36 }
37 return Status::newGood();
38 }
39
46 private function maybeGetWebserverPrimaryGroup() {
47 if ( !function_exists( 'posix_getegid' ) || !function_exists( 'posix_getpwuid' ) ) {
48 # I don't know this, this isn't UNIX.
49 return null;
50 }
51
52 # posix_getegid() *not* getmygid() because we want the group of the webserver,
53 # not whoever owns the current script.
54 $gid = posix_getegid();
55 return posix_getpwuid( $gid )['name'] ?? null;
56 }
57
58}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
checkDataDir( $dir)
Check if the data directory is writable or can be created.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54