r44254 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44253‎ | r44254 | r44255 >
Date:17:25, 5 December 2008
Author:demon
Status:reverted (Comments)
Tags:
Comment:
Cleanup to wfGetNull():
* Add override in case /dev/null isn't accessible (bug 11009)
* Use wfGetNull() in ProxyTools rather than hardcoding it
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
@@ -166,7 +166,7 @@
167167 escapeshellarg( $port ),
168168 escapeshellarg( $url )
169169 ));
170 - exec( "php $params &>/dev/null &" );
 170+ exec( "php $params &>" . wfGetNull() . " &" );
171171 }
172172 # Set MemCached key
173173 $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2816,6 +2816,10 @@
28172817 * @return string
28182818 */
28192819 function wfGetNull() {
 2820+ global $wgNullFile;
 2821+ if ( $wgNullFile ) {
 2822+ return $wgNullFile;
 2823+ }
28202824 return wfIsWindows()
28212825 ? 'NUL'
28222826 : '/dev/null';
Index: trunk/phase3/includes/DefaultSettings.php
@@ -170,6 +170,13 @@
171171 $wgDirectoryMode = 0777;
172172
173173 /**
 174+ * Path to null output (/dev/null on *nix, NUL on Windows)
 175+ * Can be left unset unless you need to override it (ie:
 176+ * open_basedir won't let you hit /dev/null. See bug 11009)
 177+ */
 178+$wgNullFile = false;
 179+
 180+/**
174181 * New file storage paths; currently used only for deleted files.
175182 * Set it like this:
176183 *
Index: trunk/phase3/RELEASE-NOTES
@@ -68,6 +68,8 @@
6969 and should still be used in code meant to be compatible with v1.13 or older.
7070 * MediaWiki can be forced to use private IPs forwarded by a proxy server by
7171 using $wgUsePrivateIPs.
 72+* (bug 11009) The null file (ie: /dev/null) can be configured with $wgNullFile.
 73+ Useful for overriding if the normal file isn't accessible
7274
7375 === Migrated extensions ===
7476 The following extensions are migrated into MediaWiki 1.14:

Follow-up revisions

RevisionCommit summaryAuthorDate
r44428Revert r44254 "Cleanup to wfGetNull(): * Add override in case /dev/null isn't...brion22:58, 10 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   23:00, 10 December 2008

I've reverted this in r44428

Doesn't seem like a proper fix here... At best, this'll be dumping random crap to some random file unless the user has a local copy of the /dev/null device file, which seems.... wrong. :)

For anything generating command lines, it probably won't make any difference (assuming exec() is enabled at all!) since open_basedir won't be searching through the command line (I think).

Assuming the core use case actually happens (open_basedir is set, but proc_open() is available to run tidy), a more correct fix is probably to go ahead and read in stderr and toss the results, or maybe better pass it through to PHP's stderr FD instead of opening /dev/null ourselves. Tidy has a -q option which should suppress random "hi i'm tidy version XYZ" if it's currently present.

Status & tagging log