Skip to content

User run-time dir stopped being created at boot #46

@godeater

Description

@godeater

I'm not sure what changed exactly, but I found today that systemd was reporting being in a degrade state, and when I investigated further I was finding that the user@1000.service was failing to start.

Sep 14 08:36:26 atlas (systemd)[782]: pam_systemd(systemd-user:session): Failed to stat() runtime directory '/run/user/1000': No such file or directory
Sep 14 08:36:26 atlas (systemd)[782]: pam_systemd(systemd-user:session): Not setting $XDG_RUNTIME_DIR, as the directory is not in order.
Sep 14 08:36:26 atlas systemd[782]: Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
Sep 14 08:36:26 atlas systemd[1]: user@1000.service: Main process exited, code=exited, status=1/FAILURE

Digging into it futher, it appeared that the shell script called by the user-runtime-dir@1000.service (/usr/lib/bottle-imp/imp-user-runtime-dir.sh) wasn't creating the directory any more.

I've monkey patched the shell script to the below to make it work again (new line is after the # We are the WSLg user, so leave the status quo)

#!/bin/sh

if [ ! -d /mnt/wslg/runtime-dir ]
then
    # WSLg is not present, so default to doing the standard thing.
    /lib/systemd/systemd-user-runtime-dir $1 $2
    exit
fi

# Get the UID of the WSLg runtime directory.
WSLGUID=$(stat -c "%u" /mnt/wslg/runtime-dir)

if [ "$1" = "start" ]
then
    # Setting up runtime dir.
    # At this point, the WSLg runtime dir will be mounted at this point anyway;
    # regardless of UID.
    if [ $2 -eq $WSLGUID ]
    then
        # We are the WSLg user, so leave the status quo.
        /lib/systemd/systemd-user-runtime-dir $1 $2
        exit
    fi

    # Otherwise, unmount the runtime dir, and then default to the standard.
    /bin/umount /run/user/$2
    /lib/systemd/systemd-user-runtime-dir $1 $2
    exit
fi

if [ $1 = "stop" ]
then
    # Unsetting up runtime dir.
    if [ $2 -eq $WSLGUID ]
    then
        # We are the WSLg user, so leave the status quo.
        exit
    fi

    # Otherwise, default to the standard.
    /lib/systemd/systemd-user-runtime-dir $1 $2
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions