clinuxopensusesusesysv-ipc

message queue (systemvipc) removed in OpenSUSE Leap 15.5 while working in SLES15 SP3 or under root user


I have a IPC mechanism auto removal issue happening on OpenSUSE Leap 15.5 Beta but not happening on SUSE Linux Enterprise Server SP3.

A simple scenario is this executable put in a service script:

# > cat ipc.c
#include <sys/msg.h>
#include <sys/stat.h>
#include <sys/ipc.h>

int main()
{
  int msqid;
  key_t  msgqKey = ftok("/home/",0);

  msqid = msgget(msgqKey, IPC_CREAT | 0766);
  return 0;
}
# >

and that executable runs under a certain user (non root). After I restart that service I can see for less than 10 seconds via ipcs -q that new message queue but then it dissapears.

If in the startup script I have this the message queue gets removed (automatically):

su my_user -c "exec /my/above/executable"

If in the startup script I have this the message queue is preserved:

exec /my/above/executable

The RemoveIPC and DynamicUser that I've found about seem to be ok according to the docs.

# systemctl show systemd-logind --property=DynamicUser --property=RemoveIPC
DynamicUser=no
RemoveIPC=no
# 

Any pointers or a way to read the docs more carefully is appreciated.


Solution

  • Apparently the reponsible is systemd-logind and, most likely,

    # systemctl show systemd-logind --property=DynamicUser --property=RemoveIPC
    DynamicUser=no
    RemoveIPC=no
    # 
    

    is not executed in the proper context.

    Putting explicitly in the config file this setting makes everything work fine:

    Assistant-linux:/home/engr # cat /etc/systemd/logind.conf | grep -v ^#
    
    [Login]
    RemoveIPC=no
    Assistant-linux:/home/engr #
    

    Looks like the systemd people have their own opinion related to legacy code, at least this is my impression: https://github.com/systemd/systemd/issues/2039