summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-04-13 19:40:33 +0200
committerBart Visscher <bartv@thisnet.nl>2012-05-07 09:04:07 +0200
commit2d581c675fb488df0875e4a489821cf88b7679ac (patch)
tree4180d67536e781d399e2b6336e2a8b49ca8abd7b
parenta2df8a4746dd9c355541501e78726daaa6dbec43 (diff)
downloadnextcloud-server-2d581c675fb488df0875e4a489821cf88b7679ac.tar.gz
nextcloud-server-2d581c675fb488df0875e4a489821cf88b7679ac.zip
Audit: Log sharing actions
-rw-r--r--apps/admin_audit/appinfo/app.php4
-rw-r--r--apps/admin_audit/lib/hooks_handlers.php20
-rwxr-xr-xapps/files_sharing/get.php1
-rwxr-xr-xapps/files_sharing/lib_share.php2
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";