summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/x11-common/xserver-nodm-init/X11/Xsession.d/13xdgbasedirs.sh
blob: 912f79761c690bfd25108092bb85aea2305f66fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Minimal/stub implementation of the XDG Base Directory specification.
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

# If the runtime directory hasn't been set already (for example by systemd,
# elogind, or pam) create a directory in TMPDIR.
if [ -z "$XDG_RUNTIME_DIR" ]; then
    XDG_RUNTIME_DIR=/run/user/$(id -u)
    export XDG_RUNTIME_DIR
fi

if [ -d "$XDG_RUNTIME_DIR" ]; then
    # If the directory exists, check the permissions and ownership
    if [ "$(stat -c %u-%a "$XDG_RUNTIME_DIR")" != "$(id -u)-700" ]; then
        echo "ERROR: $XDG_RUNTIME_DIR has incorrect permissions"
        exit 1
    fi
else
    mkdir --mode 0700 --parents "${XDG_RUNTIME_DIR}"
fi