diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index e7129a73..fc494007 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -1098,12 +1098,18 @@ EOSQL; /** - * Send a need-privileges error response. This function will never return. + * Send a need-privileges error response. This function will only return + * if the $href is not supplied and the current user has the specified + * permission for the request path. * - * @param string $href The unconstructed URI where we needed the privilege. * @param string $privilege The name of the needed privilege. + * @param string $href The unconstructed URI where we needed the privilege. */ - function NeedPrivilege( $href, $privilege ) { + function NeedPrivilege( $privilege, $href=null ) { + if ( !isset($href) ) { + if ( $request->AllowedTo($privilege) ) return; + } + $reply = new XMLDocument(); $xml = new XMLElement( 'need-privileges', new XMLElement( 'resource', array( diff --git a/inc/DAVResource.php b/inc/DAVResource.php index ef4eca9f..d77a0abe 100644 --- a/inc/DAVResource.php +++ b/inc/DAVResource.php @@ -509,6 +509,21 @@ EOQRY; } + /** + * Check if we have the needed privilege or send an error response. + * + * @param string $privilege The name of the needed privilege. + */ + function NeedPrivilege( $privilege ) { + global $request; + + if ( $this->HavePrivilegeTo($privilege) ) return; + + $request->NeedPrivilege( $privilege, $this->dav_name ); + exit(0); // Unecessary, but might clarify things + } + + /** * Returns the array of privilege names converted into XMLElements */ diff --git a/inc/caldav-ACL.php b/inc/caldav-ACL.php index 3e268acc..2628e799 100644 --- a/inc/caldav-ACL.php +++ b/inc/caldav-ACL.php @@ -12,9 +12,7 @@ dbg_error_log("ACL", "method handler"); require_once('DAVResource.php'); -if ( ! ( $request->AllowedTo('read-acl') || $request->AllowedTo('read-current-user-privilege-set') || $request->AllowedTo('write-acl') ) ) { - $request->DoResponse(403); -} +$request->NeedPrivilege('DAV::write-acl'); if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) { $fh = fopen('/tmp/MOVE.txt','w');