--- docman.php 2002/07/28 13:08:21 1.15 +++ docman.php 2002/07/28 14:16:04 1.17 @@ -582,8 +582,6 @@ $self = $HTTP_SERVER_VARS["PHP_SELF"] ; - if ($relDir == "") $relDir = "/"; - $fsDir = $fsRoot.$relDir."/"; // current directory if (!is_dir($fsDir)) Error("Dir not found",$relDir,1) ; @@ -904,8 +902,6 @@ global $html, $HTTP_SERVER_VARS; $self = $HTTP_SERVER_VARS["PHP_SELF"] ; - if ($relDir == "") $relDir = "/" ; - include("$html/UploadPage.html"); } // end function UploadPage @@ -1375,12 +1371,14 @@ }//init_trustee function in_group($user,$group) { - return in_array($groups[$group],$user); + global $groups; + return in_array($user,$groups[$group]); } // helper function function unroll_perm($u,$t,$user,$perm) { - // check user + + // check user FIX if ($t & trmask_not && ($u==$user)) continue; if (!($t & trmask_not) && ($u!=$user)) continue; @@ -1406,9 +1404,7 @@ $path = "/"; while (count($path_arr)) { if (substr($path,strlen($path)-1,1) != "/") $path.="/"; - $path.=array_shift($path_arr); $tr = $trustees[$path]; - if (isset($tr)) { // first apply trustee for all if (isset($tr['*'])) { @@ -1416,21 +1412,20 @@ unset($tr['*']); } // then apply group policies - foreach ($tr as $u=>$t) { - if ($t & trmask_group && in_group($user,$u)) { + foreach ($tr as $g=>$t) { + if ($t & trmask_group && in_group($user,$g)) { // resolv user $t = $t & ~trmask_group; - $u = $user; - $perm = unroll_perm($u,$t,$user, $perm); - unset($tr[$u]); + $perm = unroll_perm($user,$t,$user, $perm); + unset($tr[$g]); } } - // then apply use policy + // then apply user policy if (isset($tr[$user])) { $perm = unroll_perm($user,$tr[$user],$user, $perm); unset($tr[$user]); } - + $path.=array_shift($path_arr); } } @@ -1446,6 +1441,7 @@ global $debug; $debug.="
check_perm: $path test perm ".display_trustee($perm)."
\n"; + $return = ! $HAVE_TRUSTEE; if ($HAVE_TRUSTEE) { $perm = check_trustee($gblLogin,$path); @@ -1548,8 +1544,6 @@ } // if no password, or empty password logout - $relogin = $HTTP_GET_VARS[relogin]; - $force_login = $HTTP_GET_VARS[force_login]; if ( isset($gblLogin) && ( !isset($relogin) || ( @@ -1573,8 +1567,12 @@ // get ACL informations $HAVE_TRUSTEE = init_trustee(); + // take additional login vars + $relogin = $HTTP_GET_VARS[relogin]; + $force_login = $HTTP_GET_VARS[force_login]; + if (strtolower($gblLogin) == "anonymous" || !isset($gblPasswd)) { - $perm = check_trustee($gblLogin,$path); + $perm = check_trustee("anonymous",$path); // browsing must be explicitly allowed for root directory // of repository for anonymous user to work! if ($perm[allow] & trperm_b) { @@ -1620,8 +1618,6 @@ $relDir = $D; } - if ($relDir == "/") $relDir = "" ; - $relScriptDir = dirname($SCRIPT_NAME) ; // i.e. /docman @@ -1630,7 +1626,7 @@ // i.e. /home/httpd/repository $fsDir = $gblFsRoot . $relDir ; // current directory - if ( !is_dir($fsDir) ) Error("Dir not found",$relDir,1) ; + if ( !is_dir($fsDir) ) Error("Dir not found","Can't find $relDir which points to $fsDir",1) ; if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") { $webRoot = "https://"; @@ -1826,8 +1822,10 @@ switch ($A) { case "U" : // upload to $relDir + if (! check_perm($relDir, trperm_w)) + Error("Write access denied","You don't have permission to write in $relDir"); if (!is_writeable($gblFsRoot . $relDir)) - Error("Write access denied",$relDir) ; + Error("Write access denied","User $gblLogin has permission on $relDir, but directory is not writable",1); $text = "Use this page to upload a single " ; $text .= "file to $realm." ; StartHTML("(Upload Page)", $text) ;