]> git.corax.cc Git - toolbox/commitdiff
include/ipc: Don't store private endpoints in per-user directories
authorMatthias Kruk <m@m10k.eu>
Tue, 27 Dec 2022 05:58:47 +0000 (14:58 +0900)
committerMatthias Kruk <m@m10k.eu>
Tue, 27 Dec 2022 06:08:36 +0000 (15:08 +0900)
Private endpoints are stored in per-user directories that are created
when the ipc module is loaded. However, the mode and ownership that
the directory is created with may be incorrect, depending on the mode
of the parent directory.

This commit modifies the ipc module so that endpoints are not created
in per-user directories, and moves the necessary directory creation
code to the Makefile, where it will be executed during installation.

Makefile
include/ipc.sh

index 1bff3bbc0ba750177beb352e5b52b45bb8ce1844..d9b2b0595066f192efcf0fd7214237dc4303d306 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,9 @@ clean:
 install:
        mkdir -p $(DESTDIR)/$(PREFIX)/share/toolbox
        mkdir -p $(DESTDIR)/$(PREFIX)/bin
-       mkdir -p $(DESTDIR)/var/lib/toolbox/ipc
+       mkdir -p $(DESTDIR)/var/lib/toolbox/ipc/{pub,priv,pubsub}
        mkdir -p $(DESTDIR)/var/lib/toolbox/uipc
+       chmod -R g+rwxs $(DESTDIR)/var/lib/toolbox/ipc
        cp toolbox.sh $(DESTDIR)/$(PREFIX)/share/toolbox/.
        cp -r include $(DESTDIR)/$(PREFIX)/share/toolbox/.
        cp -r utils   $(DESTDIR)/$(PREFIX)/share/toolbox/.
index 0dfeceda09b6eb84735702c0e9b04ddb9cccdcc9..2978e46e709af26852988f244dde30a1202059c3 100644 (file)
@@ -22,19 +22,10 @@ __init() {
        fi
 
        declare -gxr  __ipc_root="/var/lib/toolbox/ipc"
-       declare -gxr  __ipc_public="$__ipc_root/pub"
-       declare -gxr  __ipc_private="$__ipc_root/priv/$USER"
-       declare -gxr  __ipc_group="toolbox_ipc"
        declare -gxr  __ipc_pubsub_root="$__ipc_root/pubsub"
 
        declare -gxir __ipc_version=1
 
-       if ! mkdir -p "$__ipc_private" ||
-          ! chgrp "$__ipc_group" "$__ipc_private"; then
-               log_error "Could not initialize private IPC directory $__ipc_private"
-               return 1
-       fi
-
        return 0
 }
 
@@ -494,7 +485,7 @@ ipc_endpoint_open() {
                local self
 
                self="${0##*/}"
-               name="priv/$USER/$self.$$.$(date +"%s").$RANDOM"
+               name="priv/$USER.$self.$$.$(date +"%s").$RANDOM"
        fi
 
        endpoint="$__ipc_root/$name"