You are not logged in.

#1 2021-09-18 19:07:00

ltsdw
Member
Registered: 2020-04-20
Posts: 76

[Solved] pam_systemd and creation of /run/user/$UID directory

Hi all,

So recently I created a new user like:

useradd -m myuser
passwd myuser
su - myuser
usermod -a -G wheel myuser

If I understand right, when login with su - user, it should 'start the shell as a login shell with an environment similar to a real login', as mentioned in the manpage, and so the systemd-login.service should kick in, 'User sessions are registered with logind via the pam_systemd(8) PAM module.' (systemd-logind.service(8)),  and pam_systemd would be the responsible for create something /run/user/$UID (pam_systemd(8)).

But that isn't exactly what is happening, when log in with su - myuser, some GUI application still trying to use the other user UID, resulting in some warning like:

unable to create directory '/run/user/1000/dconf': Permission denied.

it isn't creating a new directory like /run/user/1001.

The only way is killing Xorg and login again (or restart the session altogether and re-login).

Also I'm not using any display/login manager, I'm starting all with startx and using dwm as wm.

Is there a way, when switching users it to behave as I expect it to?

EDIT:

if the goal is setting a environment from a new user, it's better to use:

# loginctl enable-linger <user here>

Last edited by ltsdw (2021-09-28 17:17:22)

Offline

#2 2021-09-18 20:22:15

loqs
Member
Registered: 2014-03-06
Posts: 18,998

Re: [Solved] pam_systemd and creation of /run/user/$UID directory

What changes did you make to /etc/pam.d/su?

Offline

#3 2021-09-18 20:34:25

ltsdw
Member
Registered: 2020-04-20
Posts: 76

Re: [Solved] pam_systemd and creation of /run/user/$UID directory

loqs wrote:

What changes did you make to /etc/pam.d/su?

None, still as default:

#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth           sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth           required        pam_wheel.so use_uid
auth            required        pam_unix.so
account         required        pam_unix.so
session	        required        pam_unix.so
password        include         system-auth

su-l:

#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth           sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth           required        pam_wheel.so use_uid
auth            required        pam_unix.so
account         required        pam_unix.so
session	        required        pam_unix.so
password        include         system-auth

I think it should be including pam_systemd.so somewhere, right?

Offline

#4 2021-09-18 20:41:11

loqs
Member
Registered: 2014-03-06
Posts: 18,998

Re: [Solved] pam_systemd and creation of /run/user/$UID directory

If you want it to use pam_systemd.so it has to be included.
If I understand correctly you want to have an X server started by one none root user which will run some graphical programs with additional graphical programs started by a second none root user?
Edit:
Also look at the session entries in system-login to see what else is skipped when you use su.

Last edited by loqs (2021-09-18 20:48:53)

Offline

#5 2021-09-18 20:52:13

ltsdw
Member
Registered: 2020-04-20
Posts: 76

Re: [Solved] pam_systemd and creation of /run/user/$UID directory

loqs wrote:

If you want it to use pam_systemd.so it has to be included.
If I understand correctly you want to have an X server started by one none root user which will run some graphical programs with additional graphical programs started by a second none root user?

Yeah quite that, first I login with my user, then I open a terminal to login with another user to run a graphical program.

loqs wrote:

Edit:
Also look at the session entries in system-login to see what else is skipped when you use su.

Ok, I'll try.

Offline

#6 2021-09-18 21:04:56

ltsdw
Member
Registered: 2020-04-20
Posts: 76

Re: [Solved] pam_systemd and creation of /run/user/$UID directory

well, I don't know if it's right.

su:

#%PAM-1.0
auth       required   pam_shells.so
auth       requisite  pam_nologin.so
auth       include    system-auth

account    required   pam_access.so
account    required   pam_nologin.so
account    include    system-auth

password   include    system-auth

session    optional   pam_loginuid.so
session    include    system-auth
-session   optional   pam_systemd.so
session    required   pam_env.so           user_readenv=1

su-l:

#%PAM-1.0
auth       required   pam_shells.so
auth       requisite  pam_nologin.so
auth       include    system-auth

account    required   pam_access.so
account    required   pam_nologin.so
account    include    system-auth

password   include    system-auth

session    optional   pam_loginuid.so
session    include    system-auth
-session   optional   pam_systemd.so
session    required   pam_env.so           user_readenv=1

then I killed Xorg to be prompted to login again, re-logged with my main user, then tried switch to the other user with su - myuser. But still, no /run/user/1001 created. It still looking for /run/user/1000.

Edit:
Also the application runs just fine, the problem is that it will try to save some config files under /run/user/1000, which the owner is my main user.

Edit2:
As it's not doing it automatically, I created the directory manually as root and changed the permissions/owner/group and exported to XDG_RUNTIME_DIR=/run/user/$UID.

It's not exactly what I was expecting, but it works, so I'll mark as solved, thank you!

Last edited by ltsdw (2021-09-19 00:17:17)

Offline

Board footer

Powered by FluxBB