@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Validate all components of $PATH configuration

Summary: Fixes T3400. Users are crafty. Attempt to outwit them.

Test Plan: Added all kinds of nonsense to my PATH to hit all the errors. Verified sensible-looking error messages which I couldn't figure out any way to misread or outwit.

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T3400

Differential Revision: https://secure.phabricator.com/D6318

+95
+95
src/applications/config/check/PhabricatorSetupCheckPath.php
··· 25 25 ->setSummary($summary) 26 26 ->setMessage($message) 27 27 ->addPhabricatorConfig('environment.append-paths'); 28 + 29 + // Bail on checks below. 30 + return; 28 31 } 32 + 33 + // Users are remarkably industrious at misconfiguring software. Try to 34 + // catch mistaken configuration of PATH. 35 + 36 + $path_parts = explode(PATH_SEPARATOR, $path); 37 + $bad_paths = array(); 38 + foreach ($path_parts as $path_part) { 39 + if (!strlen($path_part)) { 40 + continue; 41 + } 42 + 43 + $message = null; 44 + $not_exists = false; 45 + foreach (Filesystem::walkToRoot($path_part) as $part) { 46 + if (!Filesystem::pathExists($part)) { 47 + $not_exists = $part; 48 + // Walk up so we can tell if this is a readability issue or not. 49 + continue; 50 + } else if (!is_dir(Filesystem::resolvePath($part))) { 51 + $message = pht( 52 + "The PATH component '%s' (which resolves as the absolute path ". 53 + "'%s') is not usable because '%s' is not a directory.", 54 + $path_part, 55 + Filesystem::resolvePath($path_part), 56 + $part); 57 + } else if (!is_readable($part)) { 58 + $message = pht( 59 + "The PATH component '%s' (which resolves as the absolute path ". 60 + "'%s') is not usable because '%s' is not readable.", 61 + $path_part, 62 + Filesystem::resolvePath($path_part), 63 + $part); 64 + } else if ($not_exists) { 65 + $message = pht( 66 + "The PATH component '%s' (which resolves as the absolute path ". 67 + "'%s') is not usable because '%s' does not exist.", 68 + $path_part, 69 + Filesystem::resolvePath($path_part), 70 + $not_exists); 71 + } else { 72 + // Everything seems good. 73 + break; 74 + } 75 + 76 + if ($message !== null) { 77 + break; 78 + } 79 + } 80 + 81 + if ($message === null) { 82 + if (!phutil_is_windows() && !@file_exists($path_part.'/.')) { 83 + $message = pht( 84 + "The PATH component '%s' (which resolves as the absolute path ". 85 + "'%s') is not usable because it is not traversable (its '+x' ". 86 + "permission bit is not set).", 87 + $path_part, 88 + Filesystem::resolvePath($path_part)); 89 + } 90 + } 91 + 92 + if ($message !== null) { 93 + $bad_paths[$path_part] = $message; 94 + } 95 + } 96 + 97 + if ($bad_paths) { 98 + foreach ($bad_paths as $path_part => $message) { 99 + $digest = substr(PhabricatorHash::digest($path_part), 0, 8); 100 + 101 + $this 102 + ->newIssue('config.PATH.'.$digest) 103 + ->setName(pht('$PATH Compontent Unusable')) 104 + ->setSummary( 105 + pht( 106 + "A component of the configured PATH can not be used by ". 107 + "the webserver: %s", 108 + $path_part)) 109 + ->setMessage( 110 + pht( 111 + "The configured PATH includes a component which is not usable. ". 112 + "Phabricator will be unable to find or execute binaries located ". 113 + "here:". 114 + "\n\n". 115 + "%s". 116 + "\n\n". 117 + "The user that the webserver runs as must be able to read all ". 118 + "the directories in PATH in order to make use of them.", 119 + $message)) 120 + ->addPhabricatorConfig('environment.append-paths'); 121 + } 122 + } 123 + 29 124 } 30 125 }