Reasons a user might not be able to open a shared memory object on Linux systems

元气小坏坏 提交于 2019-12-25 04:42:46

问题


I'm having some trouble with an application I'm supporting that, for various annoying reasons, forks worker processes to handle some tasks. These processes communicate status and sometimes results using a shared memory space. I'm using the boost interprocess library to accomplish this (using shared_memory_object and mapped_region types).

On one of the systems deployed to we have extremely limited access, making debugging on that system difficult. There's a whole process just to get a new version of the software installed. But on this target we're running into the issue where one user, attempting to launch the application, is able to do so just fine while another, with seemingly identical credentials, group affiliations, etc, is unable to create the shared memory object. The boost error is "permission denied". This is returned for any attempt to create a shared memory object, even if the name doesn't already exist.

I've only been able to reproduce this problem on my end by launching the application as root so the memory space is created with restricted privileges then re-running as a non-root user, which gives the same permission issue. This I was able to fix by calling the set_unrestricted routine on the permissions object as mentioned here. However, this is not what's occurring on this remote system as neither user is root and one user cannot make any named memory object, even new ones.

My question then is what other reasons might be preventing one user from opening shared memory objects? I've only found mention of the root / non-root restrictions but I've not been able to find any other possible explanations.

This is using boost 1.55 interprocess library to create a shared memory object on a Linux system.


回答1:


Check

  • /dev/shm permissions (also +x on /dev/ direntry)
  • availability/accessibility of librt.so
  • ulimit in effect
  • output of id for primary as well as secondary groups
  • SELinux configuration (getenforce, setenforce 0)
  • AppArmor (unlikely culprit on such a system, but still)

Also, not all kernels have SHM support compiled in, but that doesn't immediately seem to be the problem here.



来源:https://stackoverflow.com/questions/30850686/reasons-a-user-might-not-be-able-to-open-a-shared-memory-object-on-linux-systems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!