pam elogind su-l and chroot
by Weber Kai from LinuxQuestions.org on (#6PC1K)
Hi, all!
I am running Slackware 15.0 and I've decided to install steam inside a multilib chroot.
The new steam client needs XDG_* environment variables to be set to run nicely, in special XDG_CONFIG_DIRS and XDG_RUNTIME_DIR.
I've noticed that both are set after a sucessful login in Slackware 15.0, but they were not available after a login in a chroot jail. I've decided to investigate, and I've noticed they are not available even after a sucessful "su - user" command (!).
My first attempt was to add "-session optional pam_elogind.so" to /etc/pam.d/su-l, but it didn't worked. The pam_elogind module realizes there is a previous session running and exits, not creating the environment variables.
Then my next attempt was to edit /etc/profile.d scripts, to set the environment variables accordingly.
I've created/edited the 3 files below:
File 1: Created /etc/profile.d/elogind.sh
Code:#!/bin/sh
# If there's no $XDG_CONFIG_DIRS variable, set it to /etc/xdg:
if [ -z "$XDG_CONFIG_DIRS" ]; then
XDG_CONFIG_DIRS=/etc/xdg
else
if [[ ! "$XDG_CONFIG_DIRS" =~ (^|:)"/etc/xdg"(:|$) ]]; then
XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS:/etc/xdg
fi
fi
export XDG_CONFIG_DIRS
if [ -z "$XDG_RUNTIME_DIR" ]; then
if [ -d /run/user/$UID ]; then
XDG_RUNTIME_DIR=/run/user/$UID
else
XDG_RUNTIME_DIR=/tmp/xdg-runtime-$UID
if [ ! -d $XDG_RUNTIME_DIR ]; then
mkdir -p $XDG_RUNTIME_DIR
fi
chown $USER $XDG_RUNTIME_DIR
chmod 700 $XDG_RUNTIME_DIR
fi
fi
export XDG_RUNTIME_DIRFile 2: Edited /etc/profile.d/kde.sh
Code:#!/bin/sh
# KDE additions:
KDEDIRS=/usr
export KDEDIRS
# Add KDE paths if they exist:
if [ -d /usr/lib64/libexec/kf5 ]; then
PATH="$PATH:/usr/lib64/libexec/kf5"
fi
if [ -d /usr/lib64/kde4/libexec ]; then
PATH="$PATH:/usr/lib64/kde4/libexec"
fi
export PATH
# Add /etc/kde/xdg to $XDG_CONFIG_DIRS (if it exists):
if [ -d /etc/kde/xdg ] then
if [ -z "$XDG_CONFIG_DIRS" ]; then
XDG_CONFIG_DIRS=/etc/kde/xdg
else
if [[ ! "$XDG_CONFIG_DIRS" =~ (^|:)"/etc/kde/xdg"(:|$) ]]; then
XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS:/etc/kde/xdg
fi
fi
fi
export XDG_CONFIG_DIRS
# Commented out, after creation of elogind.sh:
# # If there's no $XDG_CONFIG_DIRS variable, set it to /etc/xdg:
# if [ -z "$XDG_CONFIG_DIRS" ]; then
# XDG_CONFIG_DIRS=/etc/xdg
# fi
# Commented out, since PAM should take care of this:
#if [ "$XDG_RUNTIME_DIR" = "" ]; then
# # Using /run/user would be more in line with XDG specs, but in that case
# # we should mount /run as tmpfs and add this to the Slackware rc scripts:
# # mkdir /run/user ; chmod 1777 /run/user
# # XDG_RUNTIME_DIR=/run/user/$USER
# XDG_RUNTIME_DIR=/tmp/xdg-runtime-$USER
# mkdir -p $XDG_RUNTIME_DIR
# chown $USER $XDG_RUNTIME_DIR
# chmod 700 $XDG_RUNTIME_DIR
#fi
#export XDG_RUNTIME_DIRFile 3: Edited /etc/profile.d/kde.csh (CAUTION: I haven't tested kde.csh !)
Code:#!/bin/csh
# KDE additions:
if ( ! $?KDEDIRS ) then
setenv KDEDIRS /usr
endif
# Add KDE paths if they exist:
if ( -d /usr/lib64/libexec/kf5 ) then
setenv PATH ${PATH}:/usr/lib64/libexec/kf5
endif
if ( -d /usr/lib64/kde4/libexec ) then
setenv PATH ${PATH}:/usr/lib64/kde4/libexec
endif
# Add /etc/kde/xdg to $XDG_CONFIG_DIRS (if it exists):
if ( -d /etc/kde/xdg ) then
# setenv XDG_CONFIG_DIRS ${XDG_CONFIG_DIRS}:/etc/kde/xdg
if ( ! $?XDG_CONFIG_DIRS ); then
setenv XDG_CONFIG_DIRS /etc/kde/xdg
else
if ( ! "$XDG_CONFIG_DIRS" =~ (^|:)"/etc/kde/xdg"(:|$) ); then
setenv XDG_CONFIG_DIRS $XDG_CONFIG_DIRS:/etc/kde/xdg
endif
endif
endif
# Commented out, after creation of elogind.sh:
# # If there's no $XDG_CONFIG_DIRS variable, set it to /etc/xdg:
# if ( ! $?XDG_CONFIG_DIRS ) then
# setenv XDG_CONFIG_DIRS /etc/xdg
# endif
# Commented out, since PAM should take care of this:
#if ( ! $?XDG_RUNTIME_DIR ) then
# # Using /run/user would be more in line with XDG specs, but in that case
# # we should mount /run as tmpfs and add this to the Slackware rc scripts:
# # mkdir /run/user ; chmod 1777 /run/user
# # setenv XDG_RUNTIME_DIR /run/user/$USER
# setenv XDG_RUNTIME_DIR /tmp/xdg-runtime-$USER
# mkdir -p $XDG_RUNTIME_DIR
# chown $USER $XDG_RUNTIME_DIR
# chmod 700 $XDG_RUNTIME_DIR
#endifAfter I've made these modifications, XDG_CONFIG_DIRS and XDG_RUNTIME_DIR are set accordingly after a "su - user" command, and inside a chroot jail.
Please, could someone check these changes, and maybe add then in sources?
Thank you!
Weber Kai
P.S. I've opened an issue at https://github.com/elogind/elogind/issues/286
I am running Slackware 15.0 and I've decided to install steam inside a multilib chroot.
The new steam client needs XDG_* environment variables to be set to run nicely, in special XDG_CONFIG_DIRS and XDG_RUNTIME_DIR.
I've noticed that both are set after a sucessful login in Slackware 15.0, but they were not available after a login in a chroot jail. I've decided to investigate, and I've noticed they are not available even after a sucessful "su - user" command (!).
My first attempt was to add "-session optional pam_elogind.so" to /etc/pam.d/su-l, but it didn't worked. The pam_elogind module realizes there is a previous session running and exits, not creating the environment variables.
Then my next attempt was to edit /etc/profile.d scripts, to set the environment variables accordingly.
I've created/edited the 3 files below:
File 1: Created /etc/profile.d/elogind.sh
Code:#!/bin/sh
# If there's no $XDG_CONFIG_DIRS variable, set it to /etc/xdg:
if [ -z "$XDG_CONFIG_DIRS" ]; then
XDG_CONFIG_DIRS=/etc/xdg
else
if [[ ! "$XDG_CONFIG_DIRS" =~ (^|:)"/etc/xdg"(:|$) ]]; then
XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS:/etc/xdg
fi
fi
export XDG_CONFIG_DIRS
if [ -z "$XDG_RUNTIME_DIR" ]; then
if [ -d /run/user/$UID ]; then
XDG_RUNTIME_DIR=/run/user/$UID
else
XDG_RUNTIME_DIR=/tmp/xdg-runtime-$UID
if [ ! -d $XDG_RUNTIME_DIR ]; then
mkdir -p $XDG_RUNTIME_DIR
fi
chown $USER $XDG_RUNTIME_DIR
chmod 700 $XDG_RUNTIME_DIR
fi
fi
export XDG_RUNTIME_DIRFile 2: Edited /etc/profile.d/kde.sh
Code:#!/bin/sh
# KDE additions:
KDEDIRS=/usr
export KDEDIRS
# Add KDE paths if they exist:
if [ -d /usr/lib64/libexec/kf5 ]; then
PATH="$PATH:/usr/lib64/libexec/kf5"
fi
if [ -d /usr/lib64/kde4/libexec ]; then
PATH="$PATH:/usr/lib64/kde4/libexec"
fi
export PATH
# Add /etc/kde/xdg to $XDG_CONFIG_DIRS (if it exists):
if [ -d /etc/kde/xdg ] then
if [ -z "$XDG_CONFIG_DIRS" ]; then
XDG_CONFIG_DIRS=/etc/kde/xdg
else
if [[ ! "$XDG_CONFIG_DIRS" =~ (^|:)"/etc/kde/xdg"(:|$) ]]; then
XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS:/etc/kde/xdg
fi
fi
fi
export XDG_CONFIG_DIRS
# Commented out, after creation of elogind.sh:
# # If there's no $XDG_CONFIG_DIRS variable, set it to /etc/xdg:
# if [ -z "$XDG_CONFIG_DIRS" ]; then
# XDG_CONFIG_DIRS=/etc/xdg
# fi
# Commented out, since PAM should take care of this:
#if [ "$XDG_RUNTIME_DIR" = "" ]; then
# # Using /run/user would be more in line with XDG specs, but in that case
# # we should mount /run as tmpfs and add this to the Slackware rc scripts:
# # mkdir /run/user ; chmod 1777 /run/user
# # XDG_RUNTIME_DIR=/run/user/$USER
# XDG_RUNTIME_DIR=/tmp/xdg-runtime-$USER
# mkdir -p $XDG_RUNTIME_DIR
# chown $USER $XDG_RUNTIME_DIR
# chmod 700 $XDG_RUNTIME_DIR
#fi
#export XDG_RUNTIME_DIRFile 3: Edited /etc/profile.d/kde.csh (CAUTION: I haven't tested kde.csh !)
Code:#!/bin/csh
# KDE additions:
if ( ! $?KDEDIRS ) then
setenv KDEDIRS /usr
endif
# Add KDE paths if they exist:
if ( -d /usr/lib64/libexec/kf5 ) then
setenv PATH ${PATH}:/usr/lib64/libexec/kf5
endif
if ( -d /usr/lib64/kde4/libexec ) then
setenv PATH ${PATH}:/usr/lib64/kde4/libexec
endif
# Add /etc/kde/xdg to $XDG_CONFIG_DIRS (if it exists):
if ( -d /etc/kde/xdg ) then
# setenv XDG_CONFIG_DIRS ${XDG_CONFIG_DIRS}:/etc/kde/xdg
if ( ! $?XDG_CONFIG_DIRS ); then
setenv XDG_CONFIG_DIRS /etc/kde/xdg
else
if ( ! "$XDG_CONFIG_DIRS" =~ (^|:)"/etc/kde/xdg"(:|$) ); then
setenv XDG_CONFIG_DIRS $XDG_CONFIG_DIRS:/etc/kde/xdg
endif
endif
endif
# Commented out, after creation of elogind.sh:
# # If there's no $XDG_CONFIG_DIRS variable, set it to /etc/xdg:
# if ( ! $?XDG_CONFIG_DIRS ) then
# setenv XDG_CONFIG_DIRS /etc/xdg
# endif
# Commented out, since PAM should take care of this:
#if ( ! $?XDG_RUNTIME_DIR ) then
# # Using /run/user would be more in line with XDG specs, but in that case
# # we should mount /run as tmpfs and add this to the Slackware rc scripts:
# # mkdir /run/user ; chmod 1777 /run/user
# # setenv XDG_RUNTIME_DIR /run/user/$USER
# setenv XDG_RUNTIME_DIR /tmp/xdg-runtime-$USER
# mkdir -p $XDG_RUNTIME_DIR
# chown $USER $XDG_RUNTIME_DIR
# chmod 700 $XDG_RUNTIME_DIR
#endifAfter I've made these modifications, XDG_CONFIG_DIRS and XDG_RUNTIME_DIR are set accordingly after a "su - user" command, and inside a chroot jail.
Please, could someone check these changes, and maybe add then in sources?
Thank you!
Weber Kai
P.S. I've opened an issue at https://github.com/elogind/elogind/issues/286