Changeset 1214702
- Timestamp:
- 08/07/2015 09:00:37 AM (11 years ago)
- Location:
- angry-creative-logger/trunk
- Files:
-
- 3 edited
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
routines/file_permissions.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
angry-creative-logger/trunk/plugin.php
r1214050 r1214702 4 4 Plugin URI: http://angrycreative.se 5 5 Description: Inspects and logs possible issues with your Wordpress installation. 6 Version: 0.8. 16 Version: 0.8.2 7 7 Author: Robin Björklund, Sammy Nordström, Angry Creative AB 8 8 */ 9 9 10 define( 'ACI_PLUGIN_VERSION', '0.8. 1' );10 define( 'ACI_PLUGIN_VERSION', '0.8.2' ); 11 11 12 12 define( 'ACI_PLUGIN_DIR', dirname( __FILE__ ) ); -
angry-creative-logger/trunk/readme.txt
r1214050 r1214702 1 1 === Angry Creative Inspector === 2 2 Contributors: ac-robin, samface, angrycreative 3 Tags: inspect, inspection, monitor, monitoring, log, logging, check, checking, validate, validation, permissions, install, installation 3 Tags: inspect, inspection, monitor, monitoring, log, logging, check, checking, validate, validation, permissions, install, installation, wp-cli 4 4 Requires at least: 4.0 5 Tested up to: 4.2. 26 Stable tag: 0.8. 15 Tested up to: 4.2.4 6 Stable tag: 0.8.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Inspects and logspossible issues with your Wordpress installation.10 Inspects, logs and with the aid of WP-CLI it may even repair possible issues with your Wordpress installation. 11 11 12 12 == Description == 13 13 14 Inspects and logs possible issues with your Wordpress installation. 14 Inspects, logs and with the aid of WP-CLI it may even repair possible issues with your Wordpress installation. 15 16 TO-DO: Documentation :) 15 17 16 18 == Installation == -
angry-creative-logger/trunk/routines/file_permissions.php
r1214050 r1214702 89 89 90 90 if ( is_link( rtrim( ABSPATH, '/' ) ) ) { 91 self::$_real_abspath = rea dlink( rtrim( ABSPATH, '/') );91 self::$_real_abspath = realpath( readlink( rtrim( ABSPATH, '/' ) ) ); 92 92 } else { 93 93 self::$_real_abspath = rtrim( ABSPATH, '/' ); … … 141 141 } 142 142 143 $original_gid = posix_getegid(); 143 144 $original_uid = posix_geteuid(); 144 145 145 if ( !posix_seteuid( $httpd_usr['uid'] ) ) { 146 if ( !posix_setegid( $httpd_usr['gid'] ) || $httpd_usr['gid'] != posix_getegid() ) { 147 $groupinfo = posix_getgrgid( $httpd_usr['gid'] ); 148 AC_Inspector::log( 'Unable change the group of the current process to ' . $groupinfo['name'] . ' (gid: ' . $httpd_usr['gid'] . '), do you have the appropriate sudo privileges?', __CLASS__, array( 'error' => true ) ); 149 return; 150 } 151 152 if ( !posix_seteuid( $httpd_usr['uid'] ) || $httpd_usr['uid'] != posix_geteuid() ) { 146 153 AC_Inspector::log( 'Unable change the owner of the current process to ' . HTTPD_USER . ' (uid: ' . $httpd_usr['uid'] . '), do you have the appropriate sudo privileges?', __CLASS__, array( 'error' => true ) ); 147 154 return; … … 162 169 163 170 if ( is_link( self::$_real_abspath.'/'.$folder_base ) ) { 164 $resolved_folder_path = rea dlink( self::$_real_abspath.'/'.$folder_base);171 $resolved_folder_path = realpath( readlink( self::$_real_abspath.'/'.$folder_base ) ); 165 172 } else { 166 173 $resolved_folder_path = self::$_real_abspath.'/'.$folder_base; … … 221 228 $response = cli\choose( "Bad file permissions detected, continue the inspection", $choices = 'yn', $default = 'n' ); 222 229 if ( $response !== 'y' ) { 223 if ( !posix_seteuid( $original_uid ) ) { 224 AC_Inspector::log( 'Unable restore the owner of the current process (uid: ' . $original_uid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 230 if ( !posix_setegid( $original_gid ) || $original_gid != posix_getegid() ) { 231 AC_Inspector::log( 'Unable to restore the group of the current process (gid: ' . $original_gid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 232 } 233 if ( !posix_seteuid( $original_uid ) || $original_uid != posix_geteuid() ) { 234 AC_Inspector::log( 'Unable to restore the owner of the current process (uid: ' . $original_uid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 225 235 } 226 236 return; … … 239 249 $file = str_replace('//', '/', $file); 240 250 241 if ( !$allowed_dir && is_writable( $file) ) {251 if ( !$allowed_dir && @touch($file, date('U', filemtime($file)), time() ) ) { 242 252 $bad_file_perm = true; 243 253 AC_Inspector::log( "Writable file `$file` is in a file directory that should not be writeable. Check your file permissions.", __CLASS__ ); 244 } else if ( $allowed_dir && ! is_writable( $file) ) {254 } else if ( $allowed_dir && !@touch($file, date('U', filemtime($file)), time() ) ) { 245 255 $bad_file_perm = true; 246 256 AC_Inspector::log( "Unwritable file `$file` is in a file directory that should be writeable. Check your file permissions.", __CLASS__ ); … … 250 260 $response = cli\choose( "Bad file permissions detected, continue the inspection", $choices = 'yn', $default = 'n' ); 251 261 if ( $response !== 'y' ) { 252 if ( !posix_seteuid( $original_uid ) ) { 253 AC_Inspector::log( 'Unable restore the owner of the current process (uid: ' . $original_uid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 262 if ( !posix_setegid( $original_gid ) || $original_gid != posix_getegid() ) { 263 AC_Inspector::log( 'Unable to restore the group of the current process (gid: ' . $original_gid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 264 } 265 if ( !posix_seteuid( $original_uid ) || $original_uid != posix_geteuid() ) { 266 AC_Inspector::log( 'Unable to restore the owner of the current process (uid: ' . $original_uid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 254 267 } 255 268 return; … … 285 298 if ( defined( 'WP_CLI' ) && WP_CLI ) { 286 299 287 if ( !posix_seteuid( $original_uid ) ) { 288 AC_Inspector::log( 'Unable restore the owner of the current process (uid: ' . $original_uid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 300 if ( !posix_setegid( $original_gid ) || $original_gid != posix_getegid() ) { 301 AC_Inspector::log( 'Unable to restore the group of the current process (gid: ' . $original_gid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 302 } 303 if ( !posix_seteuid( $original_uid ) || $original_uid != posix_geteuid() ) { 304 AC_Inspector::log( 'Unable to restore the owner of the current process (uid: ' . $original_uid . '). File permissions will have to be repaired manually.', __CLASS__, array( 'error' => true ) ); 289 305 } 290 306 … … 304 320 305 321 if ( is_link( $path ) ) { 306 $path = rea dlink( $path);322 $path = realpath( readlink( $path ) ); 307 323 } 308 324 … … 325 341 if ( !empty( $group ) ) { 326 342 try { 327 $chowned = @ch own( $path, $group );343 $chowned = @chgrp( $path, $group ); 328 344 if ( !$chowned ) { 329 345 throw new Exception( "Failed changing group ownership of directory '$path' to '$group'" ); … … 341 357 } 342 358 343 $ownership_str = ( $owner) ? 'user ' . $owner : '';359 $ownership_str = ( !empty( $owner ) ) ? 'user ' . $owner : ''; 344 360 if ( !empty( $group ) ) { 345 361 if ( empty( $ownership_str ) ) { 346 362 $ownership_str = 'group ' . $group; 347 363 } else { 348 $ownership_str = ' and group ' . $group;364 $ownership_str .= ' and group ' . $group; 349 365 } 350 366 } … … 355 371 $fullpath = $path . '/' . $file; 356 372 if ( is_link( $fullpath ) ) { 357 $fullpath = rea dlink( $fullpath);373 $fullpath = realpath( readlink( $fullpath ) ); 358 374 } 359 375 if ( $recursive || !is_dir( $fullpath ) ) { … … 416 432 417 433 if ( is_link( $path ) ) { 418 $path = rea dlink( $path);434 $path = realpath( readlink( $path ) ); 419 435 } 420 436 … … 441 457 $fullpath = $path . '/' . $file; 442 458 if ( is_link( $fullpath ) ) { 443 $fullpath = rea dlink( $fullpath);459 $fullpath = realpath( readlink( $fullpath ) ); 444 460 } 445 461 if ( $recursive || !is_dir( $fullpath ) ) { … … 483 499 public static function repair() { 484 500 485 if ( !function_exists( 'posix_get uid' ) ) {501 if ( !function_exists( 'posix_geteuid' ) ) { 486 502 AC_Inspector::log( 'Repairing file permissions requires a POSIX-enabled PHP server.', __CLASS__, array( 'error' => true ) ); 487 503 return; 488 504 } 489 505 490 if ( posix_get uid() !== 0 ) {506 if ( posix_geteuid() !== 0 ) { 491 507 AC_Inspector::log( 'Repairing file permissions must be performed as root.', __CLASS__, array( 'error' => true ) ); 492 508 return; … … 533 549 534 550 if ( is_link( self::$_real_abspath.'/'.$folder_base ) ) { 535 $resolved_folder_path = rea dlink( self::$_real_abspath.'/'.$folder_base);551 $resolved_folder_path = realpath( readlink( self::$_real_abspath.'/'.$folder_base ) ); 536 552 } else { 537 553 $resolved_folder_path = self::$_real_abspath.'/'.$folder_base;
Note: See TracChangeset
for help on using the changeset viewer.