I have a massive file ie 1TiB owned as 'filehandler', permitted rwx------. I mmap(2)-ed it into the 64bit address space, and all works successfully. This file handled by a process running as user 'filehandler'.
Other processes request services from this handler process running as other user than the filehandler. They login into handler through unix socket. They communicate by IPC rules, all is ok.
The entire file must not be shared to requesters due to security reasons. In the file only some parts are allowed to access for requester processes.
The best performance will be given if share of the memory, just the allowed parts of the file with the requesting processes.
For example the shm gives the key to access the segment for other processes, it is a practical targeting to requester.
Is there any way to share only the allowed parts of a mmap(2)-ed space to any processes identified like shm technology?
mmapd segment has a file associated, permissions are related to the permission bits of the file, so you'll only be able to access the whole file or nothing at all, depending on who are you whenmmaping the file.mprotectormunmapsome pages of the mapping after callingmmap. But I don't think this helps for IPC unless youfork()and then have the child processesmunmapthe parts they don't need before dropping privileges or something. I don't think you can hand mappings over a socket.