[php-src] Issue #7848: Uploaded files are owned by root, only after calling fileowner function correct owner is set

From: Date: Thu, 03 Feb 2022 18:16:04 +0000
Subject: [php-src] Issue #7848: Uploaded files are owned by root, only after calling fileowner function correct owner is set
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239462@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7848 Comment Author: DevDavido > I ran sudo chown -R $(whoami):www-data . on my root directory. > Does this work for you? As I don't have a www-data group on my host (MacOS 10.15), it doesn't work. However, all files on host in that directory and its subdirectory src are owned by user devdavido and group staff. > Are the permission of the src directory and the other > non-mounted directory you tested with the same? No, I tested with the tmp directory which has different permissions (777). <img width="659" alt="Screenshot 2022-02-03" src="https://user-images.githubusercontent.com/997605/152399595-64c09b90-db7e-49bf-b362-f4a864a2223a.png"> Now I created a random (non-mounted) directory /test on the container system with the same owner root, group root and permissions 755 exactly like src and changed the upload path of index.php accordingly. Uploading a file will result in the error Warning: move_uploaded_file(/test/file.txt): Failed to open stream: Permission denied in /var/www/html/index.php on line 21 then. > Also, can you use ls -lah to list the directory? It's a > little hard to tell what is what with the UID instead of the user name. Yes, here we go: On host system: > drwxr-xr-x 4 devdavido staff 128B Feb 3 19:08 . > drwxr-xr-x 5 devdavido staff 160B Feb 3 13:15 .. > -rw-r--r-- 1 devdavido staff 901B Feb 3 19:08 file.txt > -rw-r--r-- 1 devdavido staff 832B Feb 3 19:07 index.php On container system: > drwxr-xr-x 4 root root 128 Feb 3 18:08 . > drwxr-xr-x 3 root root 4.0K Dec 21 19:30 .. > -rw-r--r-- 1 root root 901 Feb 3 18:08 file.txt > -rw-r--r-- 1 101 101 832 Feb 3 18:07 index.php On container system (non-mounted directory tmp): > drwxrwxrwt 1 root root 4.0K Feb 3 18:08 . > drwxr-xr-x 1 root root 4.0K Feb 3 17:46 ..

« previous php.bugs (#239462) next »