[Interprocess] Growing resets permissions

I have a situation where I don't know how much shared memory I need, so I made the shared memory grow when it ran out of space. My shared memory is shared between a process running as root and postgres, which won't run as root. So I set the permissions to unrestricted (0666) when I create the shared memory. My problem is that when I grow the shared memory, the permissions are reset to (0644). This breaks things, as postgres can no longer open the shared memory for writing. I followed the code a bit and saw that it was using ftruncate. Checking the man page for ftruncate reveals, "the set-user-ID and set-group-ID permission bits may be cleared." Has anyone else ran into this? What is the easy solution? Should I just set the permissions manually after growing? Is this a bug in the interprocess library? --- Aaron Wright

El 10/09/2012 18:28, Aaron_Wright@selinc.com escribió:
I have a situation where I don't know how much shared memory I need, so I made the shared memory grow when it ran out of space. My shared memory is shared between a process running as root and postgres, which won't run as root. So I set the permissions to unrestricted (0666) when I create the shared memory. My problem is that when I grow the shared memory, the permissions are reset to (0644). This breaks things, as postgres can no longer open the shared memory for writing.
I followed the code a bit and saw that it was using ftruncate. Checking the man page for ftruncate reveals, "the set-user-ID and set-group-ID permission bits may be cleared."
Has anyone else ran into this? What is the easy solution? Should I just set the permissions manually after growing? Is this a bug in the interprocess library?
I didn't know about this ftruncate behavior. Please fill a ticket to Interprocess, as I think it should try to maintain original permissions. Best, Ion
participants (2)
-
Aaron_Wright@selinc.com
-
Ion Gaztañaga