Set umask for Apache2 PHP (Nextcloud app)

How to change umask for user www-data for Nextcloud service?
I have PHP 7.4, Apache2.
I try to set umask 002 in /etc/apache2/envvars but nothing changed.
All new folders created in nextcloud app have permissions 0755.

What exactly should be the goal of this? What do you like to achieve?

Goal is make directories and files writtable/editable for another user (example, dietpi) via samba. I add dietpi user to www-data group.
Simple example:

  1. Create directory Test in Nextcloud app files. It has rights 0755
  2. I want to add files or create subdir in Test via Samba from PC. But i can not, as have only read access.
  3. If I manually set 775 to Test directory - i can do all in 2.

I guess this is same question as you have File upload by user does not have group write permission while upload/create - ℹ️ Support - Nextcloud community

Mayb you can connect to that topic. Guys over there don’t recommend doing this. They point into the direction of using WebDav instead.

You are probably right…
I try to do exactly the same as in the link above. Upload or change files as network drive, then use file:scan in Nextcloud for files to be appeared there.
It is a bad idea)
Thank you.

For those interested it was addressed in version 25+
Add to config.php 'localstorage.umask' => 002,
While umask will still return 0022, new folders will be given group write permissions.


thx for sharing, maybe some running NC could verify the solution. :+1: