r65704 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65703‎ | r65704 | r65705 >
Date:18:20, 30 April 2010
Author:avar
Status:ok (Comments)
Tags:
Comment:
Don't advice the user to `chmod a+w config/' if we can help it

This is a nit I've had since forever. There's no reason to chmod a+w
config/ the directory, usually you want chgrp www-data && chmod g+w
config/. For some value of www-data of course.

Attempt to find out what the primary group of the webserver is,
this'll only work on POSIX systems. On other systems give the old
advice, but with a warning.

This needs testing in locked down environments under POSIX. There
might be some where the POSIX functions exist, but posix_getpwuid(
posix_getegid() ) doesn't do the right thing.
Modified paths:
  • /branches/new-installer/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /branches/new-installer/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: branches/new-installer/phase3/includes/installer/Installer.i18n.php
@@ -126,11 +126,23 @@
127127 'config-uri' => 'Script URI path: <code>$1</code>.',
128128 'config-no-uri' => "'''Error:''' Could not determine the current URI.
129129 Installation aborted.",
130 - 'config-dir-not-writable' => "'''Error:''' Cannot write config file.
 130+ 'config-dir-not-writable-group' => "'''Error:''' Cannot write config file.
131131 Installation aborted.
132132
133 -To make the directory writable on a Unix/Linux system:
 133+We've determined the user your webserver is running as. Make the
 134+<code><nowiki>config</nowiki></code> directory writable by it to continue. On a Unix/Linux system:
 135+
134136 <pre>cd $1
 137+chgrp $2 config
 138+chmod g+w config</pre>",
 139+ 'config-dir-not-writable-nogroup' => "'''Error:''' Cannot write config file.
 140+Installation aborted.
 141+
 142+We couldn't determine the user your webserver is running as. Make the
 143+<code><nowiki>config</nowiki></code> directory globally writable by it (and others!) to continue. On
 144+a Unix/Linux system do:
 145+
 146+<pre>cd $1
135147 chmod a+w config</pre>",
136148 'config-file-extension' => 'Installing MediaWiki with <code>$1</code> file extensions.',
137149 'config-shell-locale' => 'Detected shell locale "$1"',
@@ -505,12 +517,6 @@
506518 'config-uri' => 'Script URI-pad: <code>$1</code>.',
507519 'config-no-uri' => "'''Fout:''' de huidige URI kon niet vastgesteld worden.
508520 De installatie is afgebroken.",
509 - 'config-dir-not-writable' => "'''Fout:''' het bestand met instellingen kon niet weggeschreven worden.
510 -De installatie is afgebroken.
511 -
512 -Om de map beschrijfbaar te maken op een Unix/Linux-systeem:
513 -<pre>cd $1
514 -chmod a+w config</pre>",
515521 'config-file-extension' => 'MediaWiki wordt geinstalleerd met <code>$1</code> als bestandsextensie.',
516522 'config-shell-locale' => 'Als shelllocale is "$1" herkend',
517523 'config-uploads-safe' => 'De uploadmap is beveiligd tegen het arbitrair uitvoeren van scripts.',
Index: branches/new-installer/phase3/includes/installer/Installer.php
@@ -611,7 +611,12 @@
612612 $ipDir = $this->getVar( 'IP' );
613613 $configDir = $ipDir . '/config';
614614 if( !is_writeable( $configDir ) ) {
615 - $this->showMessage( 'config-dir-not-writable', $ipDir );
 615+ $webserverGroup = self::maybeGetWebserverPrimaryGroup();
 616+ if ( $webserverGroup !== null ) {
 617+ $this->showMessage( 'config-dir-not-writable-group', $ipDir, $webserverGroup );
 618+ } else {
 619+ $this->showMessage( 'config-dir-not-writable-nogroup', $ipDir, $webserverGroup );
 620+ }
616621 return false;
617622 }
618623 }
@@ -889,4 +894,30 @@
890895 $localSettings = new LocalSettings( $this );
891896 return $localSettings->writeLocalSettings();
892897 }
 898+
 899+ /*
 900+ * On POSIX systems return the primary group of the webserver we're running under.
 901+ * On other systems just returns null.
 902+ *
 903+ * This is used to advice the user that he should chgrp his config/data/images directory as the
 904+ * webserver user before he can install.
 905+ *
 906+ * Public because SqliteInstaller needs it, and doesn't subclass Installer.
 907+ *
 908+ * @return string
 909+ */
 910+ public static function maybeGetWebserverPrimaryGroup() {
 911+ if ( ! function_exists('posix_getegid') || ! function_exists('posix_getpwuid') ) {
 912+ # I don't know this, this isn't UNIX
 913+ return null;
 914+ }
 915+
 916+ # posix_getegid() *not* getmygid() because we want the group of the webserver,
 917+ # not whoever owns the current script
 918+ $gid = posix_getegid();
 919+ $getpwuid = posix_getpwuid( $gid );
 920+ $group = $getpwuid["name"];
 921+
 922+ return $group;
 923+ }
893924 }

Comments

#Comment by 😂 (talk | contribs)   22:46, 18 October 2010

This was ok. But irrelevant now since we don't write to config/

Status & tagging log