Bring XDG_RUNTIME_DIR variable to chroot (another attempt)

This commit is contained in:
lemniskett 2020-10-29 12:37:16 +07:00
parent 4a0eeb1f61
commit 81eb43b12a
2 changed files with 8 additions and 6 deletions

View File

@ -14,8 +14,9 @@ asroot(){
[[ $EUID -ne 0 ]] && err "Run this as root!"
}
storedbus(){
storeenv(){
echo $DBUS_SESSION_BUS_ADDRESS > /tmp/archbox_dbus_session_address
echo $XDG_RUNTIME_DIR > /tmp/archbox_xdg_runtime_dir
}
help_text(){
@ -78,7 +79,7 @@ case $1 in
chroot $CHROOT /bin/bash -c "sh /chroot_setup"
;;
--enter)
storedbus
storeenv
copyresolv
$PRIV /usr/local/share/archbox/bin/archbox enter
;;
@ -92,7 +93,7 @@ case $1 in
err "Unknown option: $1"
;;
*)
storedbus
storeenv
copyresolv
COMMAND=$(echo $@ | tr ' ' '\ ')
$PRIV /usr/local/share/archbox/bin/archbox $COMMAND

View File

@ -2,7 +2,8 @@
source /etc/archbox.conf
DBUS_ADDRESS="$(cat /tmp/archbox_dbus_session_address)"
DBUS_ADDRESS_ENV="$(cat /tmp/archbox_dbus_session_address)"
XDG_RUNTIME_ENV="$(cat /tmp/archbox_xdg_runtime_dir)
COMMAND=$(echo $@ | tr ' ' '\ ')
[[ $1 = "enter" ]] && chroot $CHROOT /sbin/env DBUS_SESSION_BUS_ADDRESS=$DBUS_ADDRESS /bin/su $USER \
|| chroot $CHROOT /bin/su -c "env DBUS_SESSION_BUS_ADDRESS=$DBUS_ADDRESS $COMMAND" $USER
[[ $1 = "enter" ]] && chroot $CHROOT /sbin/env DBUS_SESSION_BUS_ADDRESS=$DBUS_ADDRESS_ENV XDG_RUNTIME_DIR=$XDG_RUNTIME_ENV /bin/su $USER \
|| chroot $CHROOT /bin/su -c "env DBUS_SESSION_BUS_ADDRESS=$DBUS_ADDRESS XDG_RUNTIME_DIR=$XDG_RUNTIME_ENV $COMMAND" $USER