The 2nd argument to msg_get_queue is int $permissions = 0666
, which could be set to 0660
to restrict use of the queue to the current group.
Is there any way to specify which of a user's groups is the current group before calling this command, without using elevated privileges?
In my case, I want the queue to be available to group apache
, so it can be accessed by user apache
and other members of that group. However, this only works if user apache
is the first one to call the method, and that can't be guaranteed.
My Answer:
Unfortunately, there is no direct way to specify the group ownership of the queue before calling msg_get_queue without using elevated privileges. The group ownership of the queue is determined by the group of the user who creates the queue.
One workaround could be to create a wrapper script that is owned by the desired group (e.g. apache) and set the setgid bit on the script. This way, when the script is executed, it will run with the group ownership of the script rather than the user who executed it. This would allow you to ensure that the queue is created with the desired group ownership.
Another option could be to have a separate process or script that runs with elevated privileges (e.g. as root) and creates the queue with the desired group ownership. This process could then communicate with the main application or script to pass the queue ID or other necessary information.
Overall, it may require some creative solutions or workarounds to achieve the desired group ownership of the queue without using elevated privileges.
Rate this post
3 of 5 based on 5218 votesComments