Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App keeps creating some cache data directories with owner root. #24

Closed
segln opened this issue Jan 10, 2024 · 1 comment
Closed

App keeps creating some cache data directories with owner root. #24

segln opened this issue Jan 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@segln
Copy link

segln commented Jan 10, 2024

Problem

App keeps creating some cache data directories with owner root.
As listed below, data/(parent) directory's owner is http.

I have to manually fix this almost every day by running rm -r framework/cache/.

Directory structure

Permissions Size User Date Modified Name     Permissions Size User Date Modified Name
drwxr-xr-x     - http 10 Jan 19:25   ./     drwxr-xr-x     - http  9 Jan 20:42   69/
drwxr-xr-x     - http  9 Jan 20:42   ../    drwxr-xr-x     - http 10 Jan 15:05   70/
drwxr-xr-x     - http 10 Jan 11:50   0b/    drwxr-xr-x     - http  9 Jan 21:45   71/
drwxr-xr-x     - http 10 Jan 11:50   00/    drwxr-xr-x     - http  9 Jan 20:42   73/
drwxr-xr-x     - http  9 Jan 20:42   05/    drwxr-xr-x     - http 10 Jan 11:50   74/
drwxr-xr-x     - http 10 Jan 18:20   07/    drwxr-xr-x     - http 10 Jan 09:40   75/
drwxr-xr-x     - http  9 Jan 20:42   09/    drwxr-xr-x     - http 10 Jan 19:25   77/
drwxr-xr-x     - http  9 Jan 20:42   1e/    drwxr-xr-x     - http  9 Jan 20:42   78/
drwxr-xr-x     - http  9 Jan 20:42   2c/    drwxr-xr-x     - http 10 Jan 11:50   81/
drwxr-xr-x     - http  9 Jan 20:42   3d/    drwxr-xr-x     - http 10 Jan 02:05   82/
drwxr-xr-x     - http 10 Jan 09:40   4a/    drwxr-xr-x     - http 10 Jan 19:25   84/
drwxr-xr-x     - http 10 Jan 08:35   4b/    drwxr-xr-x     - http  9 Jan 20:42   85/
drwxr-xr-x     - http  9 Jan 20:42   5d/    drwxr-xr-x     - http 10 Jan 17:15   86/
drwxr-xr-x     - http  9 Jan 20:42   5e/    drwxr-xr-x     - http  9 Jan 20:42   94/
drwxr-xr-x     - http  9 Jan 20:42   6a/    drwxr-xr-x     - http 10 Jan 05:20   95/
drwxr-xr-x     - http  9 Jan 20:42   6c/    drwxr-xr-x     - http 10 Jan 11:50   96/
drwxr-xr-x     - http 10 Jan 11:50   7c/    drwxr-xr-x     - http  9 Jan 20:42   98/
drwxr-xr-x     - http 10 Jan 04:15   7d/    drwxr-xr-x     - http 10 Jan 11:50   99/
drwxr-xr-x     - http  9 Jan 20:42   8c/    * drwxr-xr-x     - root  9 Jan 21:40   b2/
drwxr-xr-x     - http 10 Jan 11:50   8e/    drwxr-xr-x     - http 10 Jan 04:15   b3/
drwxr-xr-x     - http  9 Jan 20:42   9b/    drwxr-xr-x     - http  9 Jan 20:42   b7/
drwxr-xr-x     - http  9 Jan 20:42   9d/    drwxr-xr-x     - http  9 Jan 20:42   bd/
drwxr-xr-x     - http 10 Jan 19:25   15/    * drwxr-xr-x     - root  9 Jan 21:45   be/
drwxr-xr-x     - http  9 Jan 20:42   17/    drwxr-xr-x     - http  9 Jan 20:42   bf/
drwxr-xr-x     - http 10 Jan 19:25   20/    drwxr-xr-x     - http  9 Jan 20:42   c7/
drwxr-xr-x     - http 10 Jan 15:05   22/    drwxr-xr-x     - http 10 Jan 16:10   d1/
drwxr-xr-x     - http 10 Jan 08:35   27/    drwxr-xr-x     - http  9 Jan 23:55   d2/
drwxr-xr-x     - http 10 Jan 01:00   30/    drwxr-xr-x     - http 10 Jan 08:35   d7/
drwxr-xr-x     - http 10 Jan 10:45   31/    drwxr-xr-x     - http 10 Jan 11:50   d9/
drwxr-xr-x     - http  9 Jan 20:42   32/    drwxr-xr-x     - http  9 Jan 20:42   dd/
drwxr-xr-x     - http 10 Jan 19:25   33/    drwxr-xr-x     - http  9 Jan 20:42   e5/
drwxr-xr-x     - http 10 Jan 19:25   43/    drwxr-xr-x     - http  9 Jan 20:42   e9/
drwxr-xr-x     - http  9 Jan 20:42   45/    drwxr-xr-x     - http 10 Jan 14:00   f2/
drwxr-xr-x     - http 10 Jan 11:50   55/    drwxr-xr-x     - http 10 Jan 05:20   f3/
drwxr-xr-x     - http  9 Jan 20:42   58/    drwxr-xr-x     - http  9 Jan 20:42   f8/
drwxr-xr-x     - http  9 Jan 20:42   59/    drwxr-xr-x     - http  9 Jan 20:42   f9/
drwxr-xr-x     - http  9 Jan 20:42   63/    drwxr-xr-x     - http  9 Jan 21:45   fb/
* drwxr-xr-x     - root  9 Jan 21:45   65/

docker-compose.yml

version: "2"
services:
  rss:
    image: ghcr.io/ssddanbrown/rss:latest
    container_name: rss
    environment:
      - APP_NAME=RSS
    volumes:
      - ./rss-files:/app/storage
    ports:
      - "3007:80"
    restart: unless-stopped

Log

docker log
rss  |
rss  |    INFO  The [public/storage] link has been connected to [storagepublic].
rss  |
rss  |
rss  |    INFO  Nothing to migrate.
rss  |
rss  |
rss  |    INFO  Configuration cached successfully.
rss  |
rss  |
rss  |    INFO  Blade templates cached successfully.
rss  |
rss  | 2024-01-10 21:40:51,526 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
rss  | 2024-01-10 21:40:51,536 INFO supervisord started with pid 28
rss  | 2024-01-10 21:40:52,542 INFO spawned: 'cron' with pid 29
rss  | 2024-01-10 21:40:52,549 INFO spawned: 'nginx' with pid 30
rss  | 2024-01-10 21:40:52,558 INFO spawned: 'php-fpm' with pid 31
rss  | 2024-01-10 21:40:52,566 INFO spawned: 'php-queue-worker' with pid 32
rss  | 2024-01-10 21:40:53,763 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
rss  | 2024-01-10 21:40:53,764 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
rss  | 2024-01-10 21:40:53,764 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
rss  | 2024-01-10 21:40:53,765 INFO success: php-queue-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
laravel.log
[2024-01-10 12:06:17] production.ERROR: Unable to create lockable file: /app/storage/framework/cache/data/b2/52/b25295df9c5a528e4c31fe463a98472b82c3235c. Please ensure you have permission to create files in this location. {"exception":"[object] (Exception(code: 0): Unable to create lockable file: /app/storage/framework/cache/data/b2/52/b25295df9c5a528e4c31fe463a98472b82c3235c. Please ensure you have permission to create files in this location. at /app/vendor/laravel/framework/src/Illuminate/Filesystem/LockableFile.php:73)
[stacktrace]
#0 /app/vendor/laravel/framework/src/Illuminate/Filesystem/LockableFile.php(43): Illuminate\\Filesystem\\LockableFile->createResource()
#1 /app/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php(108): Illuminate\\Filesystem\\LockableFile->__construct()
#2 /app/vendor/laravel/framework/src/Illuminate/Cache/FileLock.php(14): Illuminate\\Cache\\FileStore->add()
#3 /app/vendor/laravel/framework/src/Illuminate/Cache/Lock.php(91): Illuminate\\Cache\\FileLock->acquire()
#4 /app/vendor/laravel/framework/src/Illuminate/Bus/UniqueLock.php(43): Illuminate\\Cache\\Lock->get()
#5 /app/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php(164): Illuminate\\Bus\\UniqueLock->acquire()
#6 /app/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php(188): Illuminate\\Foundation\\Bus\\PendingDispatch->shouldDispatch()
#7 /app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(388): Illuminate\\Foundation\\Bus\\PendingDispatch->__destruct()
#8 /app/app/Config/ConfiguredFeed.php(46): dispatch()
#9 /app/app/Config/ConfiguredFeedList.php(44): App\\Config\\ConfiguredFeed->startReloading()
#10 /app/app/Http/Controllers/PostViewController.php(23): App\\Config\\ConfiguredFeedList->reloadOutdatedFeeds()
#11 /app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\PostViewController->home()
#12 /app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction()
#13 /app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(260): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#14 /app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#15 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(799): Illuminate\\Routing\\Route->run()
#16 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#17 /app/vendor/inertiajs/inertia-laravel/src/Middleware.php(87): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#18 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Inertia\\Middleware->handle()
#19 /app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#20 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#21 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#22 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#23 /app/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#24 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#25 /app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#26 /app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#27 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
#28 /app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#30 /app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#31 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#32 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#33 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(800): Illuminate\\Pipeline\\Pipeline->then()
#34 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(777): Illuminate\\Routing\\Router->runRouteWithinStack()
#35 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(741): Illuminate\\Routing\\Router->runRoute()
#36 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(730): Illuminate\\Routing\\Router->dispatchToRoute()
#37 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#38 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#39 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#41 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#42 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#43 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#44 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#45 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#47 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#49 /app/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#50 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
#51 /app/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#52 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#53 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#54 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#55 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#56 /app/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#57 {main}
ssddanbrown added a commit that referenced this issue Jan 21, 2024
Think the cron action running as root is the cause of root-owned
cache files appearing in the app, causing permission issues when
attempted to write into the same folder by the nginx/worker process.

This changes the cron setup to load the cron command for the www-data
user instead.

Related to #24
@ssddanbrown ssddanbrown added the bug Something isn't working label Jan 21, 2024
@ssddanbrown
Copy link
Owner

Thanks for raising @segln.

I think, from testing, this was due to the cron/schedule-checking process running as root.
I've now updated the cron process to run as the same user as the webserver/queue, within commit 59dbeac.

I've just pushed this out via the v1.4.5 release.
So hopefully this will be solved now, although you may need to run the manual deletion an extra time (or set permissions) to clear the old root-only folders/files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants