From 6783dc1312f52f2578ea5d556b68f61371b96afe Mon Sep 17 00:00:00 2001 From: Lee Porte Date: Wed, 22 May 2024 16:24:52 +0100 Subject: [PATCH 1/6] Fixed #12299: permissions on storage dir in Docker Fixes #12299, where currently there is no recursive permissions set on /var/www/html/storage/ during build time. As a result this requires users to run an exec into the container and change the permissions before they are able to initiate the setup. Without this a 500 error is thrown and little is evident in the docker logs as to what the issue is. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 88de52858b..bd363ccd18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -105,7 +105,7 @@ RUN \ && ln -fs "/var/lib/snipeit/keys/ldap_client_tls.cert" "/var/www/html/storage/ldap_client_tls.cert" \ && ln -fs "/var/lib/snipeit/keys/ldap_client_tls.key" "/var/www/html/storage/ldap_client_tls.key" \ && chown docker "/var/lib/snipeit/keys/" \ - && chown -h docker "/var/www/html/storage/" \ + && chown -Rh docker "/var/www/html/storage/" \ && chmod +x /var/www/html/artisan \ && echo "Finished setting up application in /var/www/html" From 3ab197075a883b3c8bb014991cd883af9dd96d20 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 May 2024 17:20:03 +0100 Subject: [PATCH 2/6] Nicer handling of erroring when filename+log do not match Signed-off-by: snipe --- .../Controllers/Users/UserFilesController.php | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Users/UserFilesController.php b/app/Http/Controllers/Users/UserFilesController.php index 87213f2498..ea729d6d5e 100644 --- a/app/Http/Controllers/Users/UserFilesController.php +++ b/app/Http/Controllers/Users/UserFilesController.php @@ -78,24 +78,29 @@ class UserFilesController extends Controller */ public function destroy($userId = null, $fileId = null) { - $user = User::find($userId); - $destinationPath = config('app.private_uploads').'/users'; + if ($user = User::find($userId)) { - if (isset($user->id)) { - $this->authorize('update', $user); - $log = Actionlog::find($fileId); - $full_filename = $destinationPath.'/'.$log->filename; - if (file_exists($full_filename)) { - unlink($destinationPath.'/'.$log->filename); + $this->authorize('delete', $user); + $rel_path = 'private_uploads/users'; + + if ($log = Actionlog::find($fileId)) { + + $full_filename = $rel_path.'/'.$log->filename; + + if (file_exists($full_filename)) { + Storage::delete($rel_path.'/'.$log->filename); + return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); + } + + $log->delete(); + return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); } - $log->delete(); - return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); + return redirect()->back()->with('success', trans('admin/users/message.user_not_found', ['id' => $userId])); + } - // Prepare the error message - $error = trans('admin/users/message.user_not_found', ['id' => $userId]); - // Redirect to the licence management page - return redirect()->route('users.index')->with('error', $error); + + return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', ['id' => $userId])); } From 37d7e89e93e2048479eb15b03032960fafee7932 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 May 2024 17:29:43 +0100 Subject: [PATCH 3/6] Fixed error message Signed-off-by: snipe --- app/Http/Controllers/Users/UserFilesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Users/UserFilesController.php b/app/Http/Controllers/Users/UserFilesController.php index ea729d6d5e..db6873a8a3 100644 --- a/app/Http/Controllers/Users/UserFilesController.php +++ b/app/Http/Controllers/Users/UserFilesController.php @@ -96,7 +96,7 @@ class UserFilesController extends Controller return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); } - return redirect()->back()->with('success', trans('admin/users/message.user_not_found', ['id' => $userId])); + return redirect()->back()->with('error', trans('admin/users/general.log_does_not_exist')); } From 5fd0f562583e43f5741873dabbe3bf0bd97369d3 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 May 2024 17:38:49 +0100 Subject: [PATCH 4/6] Use proper storage facade for checking if the file exists Signed-off-by: snipe --- app/Http/Controllers/Users/UserFilesController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Users/UserFilesController.php b/app/Http/Controllers/Users/UserFilesController.php index db6873a8a3..adc387fe32 100644 --- a/app/Http/Controllers/Users/UserFilesController.php +++ b/app/Http/Controllers/Users/UserFilesController.php @@ -87,13 +87,11 @@ class UserFilesController extends Controller $full_filename = $rel_path.'/'.$log->filename; - if (file_exists($full_filename)) { - Storage::delete($rel_path.'/'.$log->filename); + if (Storage::exists($rel_path.'/'.$full_filename)) { + Storage::delete($rel_path.'/'.$full_filename); + $log->delete(); return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); } - - $log->delete(); - return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); } return redirect()->back()->with('error', trans('admin/users/general.log_does_not_exist')); From 4bb7c1701f25ba9025d961e91be6cd6acb621759 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 May 2024 17:44:49 +0100 Subject: [PATCH 5/6] Fiddled with storage facade a little more Signed-off-by: snipe --- .../Controllers/Users/UserFilesController.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Users/UserFilesController.php b/app/Http/Controllers/Users/UserFilesController.php index adc387fe32..ded44f35f6 100644 --- a/app/Http/Controllers/Users/UserFilesController.php +++ b/app/Http/Controllers/Users/UserFilesController.php @@ -83,19 +83,20 @@ class UserFilesController extends Controller $this->authorize('delete', $user); $rel_path = 'private_uploads/users'; + if ($log = Actionlog::find($fileId)) { - - $full_filename = $rel_path.'/'.$log->filename; - - if (Storage::exists($rel_path.'/'.$full_filename)) { - Storage::delete($rel_path.'/'.$full_filename); - $log->delete(); + $filename = $log->filename; + $log->delete(); + + if (Storage::exists($rel_path.'/'.$filename)) { + Storage::delete($rel_path.'/'.$filename); return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); } + } - return redirect()->back()->with('error', trans('admin/users/general.log_does_not_exist')); - + // The log record doesn't exist somehow + return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); } return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', ['id' => $userId])); From 81704c1d40291a3f3d25c7c9bbf695e7cef71d53 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 May 2024 17:49:29 +0100 Subject: [PATCH 6/6] Bumped version Signed-off-by: snipe --- config/version.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/version.php b/config/version.php index 7baa73e80a..e35bee694d 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v6.4.1', - 'full_app_version' => 'v6.4.1 - build 13458-gf2cc9ec1dd', - 'build_version' => '13458', + 'app_version' => 'v6.4.2', + 'full_app_version' => 'v6.4.2 - build 13487-gb489c71fa2', + 'build_version' => '13487', 'prerelease_version' => '', - 'hash_version' => 'gf2cc9ec1dd', - 'full_hash' => 'v6.4.1-68-gf2cc9ec1dd', + 'hash_version' => 'gb489c71fa2', + 'full_hash' => 'v6.4.2-97-gb489c71fa2', 'branch' => 'develop', ); \ No newline at end of file