Have a function in postgres like as:
CREATE OR REPLACE FUNCTION enroll_user()
RETURNS TRIGGER
LANGUAGE PLPYTHON3U
AS $$
import os
os.mkdir('/home/%s/data' % TD['new']['user'])
return "MODIFY"
$$;
But when call the function from trigger says: PermisionError[Errno 13] Permission denied: '/home/test/data'
.
Postgres database runs the function as postgres
user and /home/test
is owned by test
user. When need two users can access to same folder add a group to other user but in postgres can not add other group to access to other users folders.
How to postgres can access and create folders in other users without set a chmod 777 or open a security problem enabling to all other users to access to the test folder home?