Boost Interprocess: Sharing memory among different users
Hello folks!I'm writing a software for the Linux environment. I'll need to share data between a daemon and a program running on the user's context. I chose to use shared memory because it's faster. I'm trying to use boost::interprocess::shared_memory_object but I'm facing a problem: When I access the shared memory in my test case running in the same user context, everything works fine. But when I access it using a program running in the current user when the shared memory was created as root, I get an access denied error. I searched in the documentation for a way to enable access to all users but I found nothing. Is there a way to do it? Thanks in advance. Silvio.
Silvio Reis Junior wrote:
Hello folks! I'm writing a software for the Linux environment. I'll need to share data between a daemon and a program running on the user's context. I chose to use shared memory because it's faster. I'm trying to use boost::interprocess::shared_memory_object but I'm facing a problem: When I access the shared memory in my test case running in the same user context, everything works fine. But when I access it using a program running in the current user when the shared memory was created as root, I get an access denied error. I searched in the documentation for a way to enable access to all users but I found nothing. Is there a way to do it?
Sorry for the late reply. The short answer is: not yet. We would need to change the interface so that the programmer can pass permissions to the creation of the shared memory object descriptor funcion. Another idea would be to use chmod to change permissions of the shared memory file so that it can be shared with users. I would want to add support for permissions, but I don't think I will have to do this for Boost 1.37.
Thanks in advance. Silvio.
Regards, Ion
participants (2)
-
Ion Gaztañaga
-
Silvio Reis Junior