does anyone know if there is any way at all on linux to get the uid that sent a message to a message queue

@velartrill what kind of message queue? i don't think that is functionality things like activeMQ etc. have

@bonifartius yeah everyone seems to prefer sockets these days, to the point that it's almost all you see used

@velartrill i can't think of a reason why _i_ would need the message queues, but that doesn't mean anything :D

buuuut github.com/torvalds/linux/blob
the pid seems to be included! at least from what i see with my limited kernel knowledge :)

@bonifartius i use message queues for IPC in a couple of my projects, including the instance control bus for my social media server, but what i can do with it is kind of limited because you have to rely completely on kernel-level access control
@bonifartius tho come to think of it it might be possible to do something like, the client process creates its own receiver queue, then sends a message to the server with that queue's ID, then the server could use msgctl(IPC_STAT) to get the receiver queue creator pid and uid

that would be pretty minimally nasty for a system that involves two-way communication, tho doesn't solve the problem for fire-and-forget messages alas

@velartrill
> tho come to think of it it might be possible to do something like, the client process creates its own receiver queue, then sends a message to the server with that queue's ID, then the server could use msgctl(IPC_STAT) to get the receiver queue creator pid and uid

from my limited knowledge it sounds like a good solution

> that would be pretty minimally nasty for a system that involves two-way communication, tho doesn't solve the problem for fire-and-forget messages alas

maybe just open seperate queues for them too? shouldn't cost that much and you may just wrap that into a helper function

@bonifartius yeah, you could do it that way, it's just kind of a hack

then again i have no right to talk the last IPC bus i wrote involved a mix of shared memory, sysv mqs, and real-time signals
Follow

@velartrill
> yeah, you could do it that way, it's just kind of a hack

so many of the supposedly "good" libraries for these things are just hacks stacked above each other :)

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.