首页 > 解决方案 > 运行 php 的 msg_get_queue() 时,有没有办法指定队列的组所有权?

问题描述

msg_get_queue 的第二个参数是int $permissions = 0666,可以设置为0660将队列的使用限制为当前组。

有没有办法在调用此命令之前指定用户的哪个组是当前组,而不使用提升的权限?

就我而言,我希望队列可用于 group ,以便用户和该组的其他成员apache可以访问它。apache但是,这仅在用户apache是第一个调用该方法的人时才有效,并且不能保证。

标签: phpqueuesemaphore

解决方案


看起来它可以用 包装启动命令sg,例如,如果readqueue.php脚本调用msg_get_queue()可以运行:

sg apache 'php readqueue.php'

从手册页:

NAME
   sg - execute command as different group ID

SYNOPSIS
   sg [-] [group [-c ] command]

DESCRIPTION
   The sg command works similar to newgrp but accepts a command. The
   command will be executed with the /bin/sh shell...

推荐阅读