waterWang opened a new pull request, #13967:
URL: https://github.com/apache/cloudstack/pull/13967

   ### Problem
   
   When `handleCreateEntityURLCommand` runs on the SSVM (Secondary Storage VM) 
to build a download URL for e.g. `getDiagnosticsData`, it creates 
`/var/www/html/userdata/<uuid>/` as the `www-data` user via `su www-data -c 
"mkdir -p ..."`. On stock systemvm templates (`systemvm-kvm-4.22.0`) the 
`/var/www/html/userdata` base directory does not exist, and `/var/www/html` is 
not writable by `www-data`, so the `mkdir` fails with:
   
   ```
   Unable to create a link for entity at 
diagnostics//diagnostics_files_<timestamp>.zip on ssvm,
   Error in creating directory =mkdir: cannot create directory 
'/var/www/html/userdata/<uuid>/': Permission denied
   ```
   
   This affects `getDiagnosticsData`, `extractVolume`, `extractTemplate` and 
any other operation that calls `CreateEntityDownloadURLCommand`.
   
   ### Fix
   
   Create the base extract directory (`/var/www/html/userdata/`) and set its 
ownership to `www-data:www-data` before the privilege-dropped `su www-data` 
call that creates the per-entity subdirectory. This self-heals the SSVM on 
first use -- the directory is created by the root process that owns the 
service, then handed over to `www-data` for the downstream Apache docroot 
operations.
   
   ### Changes
   
   **`UploadManagerImpl.java`** -- `handleCreateEntityURLCommand`: add `mkdir 
-p BASE_EXTRACT_PATH && chown www-data:www-data BASE_EXTRACT_PATH` before the 
existing `su www-data` subdirectory creation.
   
   +12 / -1 lines.
   
   Closes #13959


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to