Unbreak setting up /home as a symbolic link
The whole idea behind commit66e982af72was to set up $HOME and /home to match the host. Therefore, it's pointless to check if /home is a symbolic link or not inside the toolbox container. The state of /home needs to be checked on the host, and then the toolbox container adjusted accordingly. Fallout from8b84b5e460https://github.com/debarshiray/toolbox/issues/185
This commit is contained in:
parent
adfca25c57
commit
8ce8441983
|
|
@ -19,7 +19,7 @@ __toolbox() {
|
||||||
declare -A options
|
declare -A options
|
||||||
local options=([create]="--candidate-registry --container --image --release" \
|
local options=([create]="--candidate-registry --container --image --release" \
|
||||||
[enter]="--container --release" \
|
[enter]="--container --release" \
|
||||||
[init-container]="--home --monitor-host --shell --uid --user" \
|
[init-container]="--home --home-link --monitor-host --shell --uid --user" \
|
||||||
[list]="--containers --images" \
|
[list]="--containers --images" \
|
||||||
[rm]="--all --force" \
|
[rm]="--all --force" \
|
||||||
[rmi]="--all --force" \
|
[rmi]="--all --force" \
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ toolbox\-init\-container - Initialize a running container
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**toolbox init-container** *--home HOME*
|
**toolbox init-container** *--home HOME*
|
||||||
|
*--home-link*
|
||||||
*--monitor-host*
|
*--monitor-host*
|
||||||
*--shell SHELL*
|
*--shell SHELL*
|
||||||
*--uid UID*
|
*--uid UID*
|
||||||
|
|
@ -25,6 +26,10 @@ The following options are understood:
|
||||||
|
|
||||||
Create a user inside the toolbox container whose login directory is HOME.
|
Create a user inside the toolbox container whose login directory is HOME.
|
||||||
|
|
||||||
|
**--home-link**
|
||||||
|
|
||||||
|
Make `/home` a symbolic link to `/var/home`.
|
||||||
|
|
||||||
**--monitor-host**
|
**--monitor-host**
|
||||||
|
|
||||||
Ensure that certain configuration files inside the toolbox container are kept
|
Ensure that certain configuration files inside the toolbox container are kept
|
||||||
|
|
|
||||||
36
toolbox
36
toolbox
|
|
@ -642,6 +642,7 @@ create()
|
||||||
|
|
||||||
dbus_system_bus_address="unix:path=/var/run/dbus/system_bus_socket"
|
dbus_system_bus_address="unix:path=/var/run/dbus/system_bus_socket"
|
||||||
dns_none=""
|
dns_none=""
|
||||||
|
home_link=""
|
||||||
kcm_socket=""
|
kcm_socket=""
|
||||||
kcm_socket_bind=""
|
kcm_socket_bind=""
|
||||||
monitor_host=""
|
monitor_host=""
|
||||||
|
|
@ -741,6 +742,20 @@ create()
|
||||||
max_minus_uid=$((max_uid_count - user_id_real))
|
max_minus_uid=$((max_uid_count - user_id_real))
|
||||||
uid_plus_one=$((user_id_real + 1))
|
uid_plus_one=$((user_id_real + 1))
|
||||||
|
|
||||||
|
if ! home_canonical=$(readlink --canonicalize "$HOME" 2>&3); then
|
||||||
|
echo "$base_toolbox_command: failed to canonicalize $HOME" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$base_toolbox_command: $HOME canonicalized to $home_canonical" >&3
|
||||||
|
|
||||||
|
echo "$base_toolbox_command: checking if /home is a symbolic link to /var/home" >&3
|
||||||
|
|
||||||
|
if [ "$(readlink /home)" = var/home ] 2>&3; then
|
||||||
|
echo "$base_toolbox_command: /home is a symbolic link to /var/home" >&3
|
||||||
|
home_link="--home-link"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$base_toolbox_command: calling org.freedesktop.Flatpak.SessionHelper.RequestSession" >&3
|
echo "$base_toolbox_command: calling org.freedesktop.Flatpak.SessionHelper.RequestSession" >&3
|
||||||
|
|
||||||
if ! gdbus call \
|
if ! gdbus call \
|
||||||
|
|
@ -785,19 +800,19 @@ create()
|
||||||
$kcm_socket_bind \
|
$kcm_socket_bind \
|
||||||
$toolbox_path_bind \
|
$toolbox_path_bind \
|
||||||
$toolbox_profile_bind \
|
$toolbox_profile_bind \
|
||||||
--volume "$HOME":"$HOME":rslave \
|
|
||||||
--volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" \
|
--volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" \
|
||||||
--volume "$XDG_RUNTIME_DIR"/.flatpak-helper/monitor:/run/host/monitor \
|
--volume "$XDG_RUNTIME_DIR"/.flatpak-helper/monitor:/run/host/monitor \
|
||||||
--volume "$dbus_system_bus_path":"$dbus_system_bus_path" \
|
--volume "$dbus_system_bus_path":"$dbus_system_bus_path" \
|
||||||
|
--volume "$home_canonical":"$home_canonical":rslave \
|
||||||
--volume /etc:/run/host/etc \
|
--volume /etc:/run/host/etc \
|
||||||
--volume /dev:/dev:rslave \
|
--volume /dev:/dev:rslave \
|
||||||
--volume /media:/media:rslave \
|
--volume /media:/media:rslave \
|
||||||
--volume /mnt:/mnt:rslave \
|
--volume /mnt:/mnt:rslave \
|
||||||
--volume /run/media:/run/media:rslave \
|
--volume /run/media:/run/media:rslave \
|
||||||
--workdir "$HOME" \
|
|
||||||
"$base_toolbox_image_full" \
|
"$base_toolbox_image_full" \
|
||||||
toolbox --verbose init-container \
|
toolbox --verbose init-container \
|
||||||
--home "$HOME" \
|
--home "$HOME" \
|
||||||
|
$home_link \
|
||||||
$monitor_host \
|
$monitor_host \
|
||||||
--shell "$SHELL" \
|
--shell "$SHELL" \
|
||||||
--uid "$user_id_real" \
|
--uid "$user_id_real" \
|
||||||
|
|
@ -831,10 +846,11 @@ enter()
|
||||||
init_container()
|
init_container()
|
||||||
{
|
{
|
||||||
init_container_home="$1"
|
init_container_home="$1"
|
||||||
init_container_monitor_host="$2"
|
init_container_home_link="$2"
|
||||||
init_container_shell="$3"
|
init_container_monitor_host="$3"
|
||||||
init_container_uid="$4"
|
init_container_shell="$4"
|
||||||
init_container_user="$5"
|
init_container_uid="$5"
|
||||||
|
init_container_user="$6"
|
||||||
|
|
||||||
if $init_container_monitor_host; then
|
if $init_container_monitor_host; then
|
||||||
working_directory="$PWD"
|
working_directory="$PWD"
|
||||||
|
|
@ -889,7 +905,7 @@ init_container()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! id -u "$init_container_user" >/dev/null 2>&3; then
|
if ! id -u "$init_container_user" >/dev/null 2>&3; then
|
||||||
if [ "$(readlink /home)" = var/home ] 2>&3; then
|
if $init_container_home_link ; then
|
||||||
# shellcheck disable=SC2174
|
# shellcheck disable=SC2174
|
||||||
if ! (rmdir /home 2>&3 \
|
if ! (rmdir /home 2>&3 \
|
||||||
&& mkdir --mode 0755 --parents /var/home 2>&3 \
|
&& mkdir --mode 0755 --parents /var/home 2>&3 \
|
||||||
|
|
@ -1606,6 +1622,7 @@ usage()
|
||||||
echo " or: toolbox [-v | --verbose]"
|
echo " or: toolbox [-v | --verbose]"
|
||||||
echo " [-y | --assumeyes]"
|
echo " [-y | --assumeyes]"
|
||||||
echo " init-container --home"
|
echo " init-container --home"
|
||||||
|
echo " --home-link"
|
||||||
echo " --monitor-host"
|
echo " --monitor-host"
|
||||||
echo " --shell"
|
echo " --shell"
|
||||||
echo " --uid"
|
echo " --uid"
|
||||||
|
|
@ -1718,6 +1735,7 @@ if [ -f /run/.containerenv ] 2>&3; then
|
||||||
exit "$?"
|
exit "$?"
|
||||||
;;
|
;;
|
||||||
init-container )
|
init-container )
|
||||||
|
init_container_home_link=false
|
||||||
init_container_monitor_host=false
|
init_container_monitor_host=false
|
||||||
while has_prefix "$1" -; do
|
while has_prefix "$1" -; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
@ -1726,6 +1744,9 @@ if [ -f /run/.containerenv ] 2>&3; then
|
||||||
exit_if_missing_argument --home "$1"
|
exit_if_missing_argument --home "$1"
|
||||||
init_container_home="$1"
|
init_container_home="$1"
|
||||||
;;
|
;;
|
||||||
|
--home-link )
|
||||||
|
init_container_home_link=true
|
||||||
|
;;
|
||||||
--monitor-host )
|
--monitor-host )
|
||||||
init_container_monitor_host=true
|
init_container_monitor_host=true
|
||||||
;;
|
;;
|
||||||
|
|
@ -1751,6 +1772,7 @@ if [ -f /run/.containerenv ] 2>&3; then
|
||||||
done
|
done
|
||||||
init_container \
|
init_container \
|
||||||
"$init_container_home" \
|
"$init_container_home" \
|
||||||
|
"$init_container_home_link" \
|
||||||
"$init_container_monitor_host" \
|
"$init_container_monitor_host" \
|
||||||
"$init_container_shell" \
|
"$init_container_shell" \
|
||||||
"$init_container_uid" \
|
"$init_container_uid" \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue