diff options
-rw-r--r-- | apps/admin_audit/appinfo/app.php | 4 | ||||
-rw-r--r-- | apps/admin_audit/lib/hooks_handlers.php | 20 | ||||
-rwxr-xr-x | apps/files_sharing/get.php | 1 | ||||
-rwxr-xr-x | apps/files_sharing/lib_share.php | 2 |
4 files changed, 27 insertions, 0 deletions
diff --git a/apps/admin_audit/appinfo/app.php b/apps/admin_audit/appinfo/app.php index 27a72de432c..e52f633cf14 100644 --- a/apps/admin_audit/appinfo/app.php +++ b/apps/admin_audit/appinfo/app.php @@ -12,3 +12,7 @@ OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, 'OC_ OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, 'OC_Admin_Audit_Hooks_Handlers', 'write'); OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_read, 'OC_Admin_Audit_Hooks_Handlers', 'read'); OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, 'OC_Admin_Audit_Hooks_Handlers', 'delete'); + +OCP\Util::connectHook('OC_Share', 'public', 'OC_Admin_Audit_Hooks_Handlers', 'share_public'); +OCP\Util::connectHook('OC_Share', 'public-download', 'OC_Admin_Audit_Hooks_Handlers', 'share_public_download'); +OCP\Util::connectHook('OC_Share', 'user', 'OC_Admin_Audit_Hooks_Handlers', 'share_user'); diff --git a/apps/admin_audit/lib/hooks_handlers.php b/apps/admin_audit/lib/hooks_handlers.php index 4cc3194eaf1..c5aec97d939 100644 --- a/apps/admin_audit/lib/hooks_handlers.php +++ b/apps/admin_audit/lib/hooks_handlers.php @@ -46,6 +46,26 @@ class OC_Admin_Audit_Hooks_Handlers { $user = OCP\User::getUser(); self::log('Delete "'.$path.'" by '.$user); } + static public function share_public($params) { + $path = $params['source']; + $token = $params['token']; + $user = OCP\User::getUser(); + self::log('Shared "'.$path.'" with public, token="'.$token.'" by '.$user); + } + static public function share_public_download($params) { + $path = $params['source']; + $token = $params['token']; + $user = $_SERVER['REMOTE_ADDR']; + self::log('Download of shared "'.$path.'" token="'.$token.'" by '.$user); + } + static public function share_user($params) { + $path = $params['source']; + $permissions = $params['permissions']; + $with = $params['with']; + $user = OCP\User::getUser(); + $rw = $permissions & OC_Share::WRITE ? 'w' : 'o'; + self::log('Shared "'.$path.'" (r'.$rw.') with user "'.$with.'" by '.$user); + } static protected function log($msg) { OCP\Util::writeLog('admin_audit', $msg, OCP\Util::INFO); } diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php index de3bc5f46dc..57ff6b6e200 100755 --- a/apps/files_sharing/get.php +++ b/apps/files_sharing/get.php @@ -74,6 +74,7 @@ if ($source !== false) { header("Content-Length: " . OC_Filesystem::filesize($source)); //download the file @ob_clean(); + OCP\Util::emitHook('OC_Share', 'public-download', array('source'=>$source, 'token'=>$token); OC_Filesystem::readfile($source); } } else { diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index d5cf3d0a1ba..14c61c620a1 100755 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -43,6 +43,7 @@ class OC_Share { $query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)"); if ($uid_shared_with == self::PUBLICLINK) { $token = sha1("$uid_shared_with-$source"); + OCP\Util::emitHook('OC_Share', 'public', array('source'=>$source, 'token'=>$token, 'permissions'=>$permissions)); $query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions)); $this->token = $token; } else { @@ -97,6 +98,7 @@ class OC_Share { if (isset($gid)) { $uid = $uid."@".$gid; } + OCP\Util::emitHook('OC_Share', 'user', array('source'=>$source, 'target'=>$target, 'with'=>$uid, 'permissions'=>$permissions)); $query->execute(array($uid_owner, $uid, $source, $target, $permissions)); // Add file to filesystem cache $userDirectory = "/".OCP\USER::getUser()."/files"; |