Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steamrt
steam-runtime-tools
Commits
66d17d02
Commit
66d17d02
authored
7 years ago
by
Simon McVittie
Browse files
Options
Downloads
Patches
Plain Diff
wrap: Invert order of bind-mounts, and append instead of prepending
Signed-off-by:
Simon McVittie
<
smcv@collabora.com
>
parent
fd5904f9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pressure-vessel-wrap
+53
-60
53 additions, 60 deletions
pressure-vessel-wrap
with
53 additions
and
60 deletions
pressure-vessel-wrap
+
53
−
60
View file @
66d17d02
...
@@ -233,12 +233,6 @@ if [ -z "$fake_home" ]; then
...
@@ -233,12 +233,6 @@ if [ -z "$fake_home" ]; then
fi
fi
fi
fi
# Because this was originally a Bourne shell script rather than a bash
# script, we historically only had access to one array, which
# was $@; so we needed to build up the bwrap command line backwards,
# with "wider" mount points like / coming after "narrower" mount points
# like $HOME.
bwrap_options
=()
bwrap_options
=()
# Protect the controlling terminal from the app/game, unless we are
# Protect the controlling terminal from the app/game, unless we are
...
@@ -282,36 +276,27 @@ if [ -d /home ]; then
...
@@ -282,36 +276,27 @@ if [ -d /home ]; then
bwrap_options+
=(
--tmpfs
/home
)
bwrap_options+
=(
--tmpfs
/home
)
fi
fi
set
--
# The shellcheck tool warns that -m is only applied to the deepest
# directory and not any parents created via -p, but that's fine here:
# Make sure the current working directory (the game we are going to
# we use a separate mkdir -p for each directory whose permissions we
# run) is available. Some games write here.
# care about.
PWD
=
"
$(
pwd
)
"
# shellcheck disable=SC2174
if
test
"
$HOME
"
-ef
"
$PWD
"
;
then
{
echo
"
$me
: Not making real
$PWD
available to container because it is"
\
# Set up the home directory
"the home directory"
>
&2
mkdir
-m700
-p
"
$fake_home
"
else
bwrap_options+
=(
--bind
"
$fake_home
"
"
$HOME
"
)
set
--
--bind
"
$PWD
"
"
$PWD
"
"
$@
"
bwrap_options+
=(
--bind
"
$fake_home
"
"
$fake_home
"
)
fi
bwrap_options+
=(
--chdir
"
$PWD
"
)
# We need libraries from the Steam Runtime, so make sure that's visible
# (it should never need to be read/write though)
if
[
-n
"
${
STEAM_RUNTIME
:-}
"
]
;
then
set
--
--ro-bind
"
$STEAM_RUNTIME
"
"
$STEAM_RUNTIME
"
"
$@
"
fi
# We need the LD_PRELOADs from Steam visible at the paths that were
# Set up /var/tmp, XDG_*_HOME like Flatpak does
# used for them, which might be their physical rather than logical
mkdir
-m700
-p
"
$fake_home
/cache"
# locations
mkdir
-m700
-p
"
$fake_home
/cache/tmp"
old_ifs
=
"
$IFS
"
bwrap_options+
=(
--bind
"
$fake_home
/cache/tmp"
/var/tmp
)
IFS
=
:
bwrap_options+
=(
--setenv
XDG_CACHE_HOME
"
$fake_home
/cache"
)
for
preload
in
$caller_ld_preload
;
do
mkdir
-m700
-p
"
$fake_home
/config"
if
[
-e
"
$preload
"
]
;
then
bwrap_options+
=(
--setenv
XDG_CONFIG_HOME
"
$fake_home
/config"
)
set
--
--ro-bind
"
$preload
"
"
$preload
"
"
$@
"
mkdir
-m700
-p
"
$fake_home
/data"
fi
bwrap_options+
=(
--setenv
XDG_DATA_HOME
"
$fake_home
/data"
)
done
}
IFS
=
"
$old_ifs
"
# These might be API entry points, according to .steam/steam/steam.sh.
# These might be API entry points, according to .steam/steam/steam.sh.
# On the host system they're symlinks to a real location, but in a
# On the host system they're symlinks to a real location, but in a
...
@@ -320,40 +305,48 @@ IFS="$old_ifs"
...
@@ -320,40 +305,48 @@ IFS="$old_ifs"
for
api
in
bin bin32 bin64 root sdk32 sdk64 steam steambeta
;
do
for
api
in
bin bin32 bin64 root sdk32 sdk64 steam steambeta
;
do
dir
=
"
$HOME
/.steam/
$api
"
dir
=
"
$HOME
/.steam/
$api
"
if
[
-d
"
$dir
"
]
;
then
if
[
-d
"
$dir
"
]
;
then
set
--
--ro-bind
"
$dir
"
"
$dir
"
"
$@
"
bwrap_options+
=(
--ro-bind
"
$dir
"
"
$dir
"
)
fi
fi
done
done
# steamclient.so relies on this for communication with Steam
# steamclient.so relies on this for communication with Steam
if
[
-e
"
$HOME
/.steam/steam.pid"
]
;
then
if
[
-e
"
$HOME
/.steam/steam.pid"
]
;
then
set
--
--ro-bind
"
$HOME
/.steam/steam.pid"
"
$HOME
/.steam/steam.pid"
"
$@
"
bwrap_options+
=(
--ro-bind
"
$HOME
/.steam/steam.pid"
"
$HOME
/.steam/steam.pid"
)
fi
fi
# Make sure Steam IPC is available (TODO: do we need this? do we need more?)
# Make sure Steam IPC is available (TODO: do we need this? do we need more?)
if
[
-e
"
$HOME
/.steam/steam.pipe"
]
;
then
if
[
-e
"
$HOME
/.steam/steam.pipe"
]
;
then
set
--
--bind
"
$HOME
/.steam/steam.pipe"
"
$HOME
/.steam/steam.pipe"
"
$@
"
bwrap_options+
=(
--bind
"
$HOME
/.steam/steam.pipe"
"
$HOME
/.steam/steam.pipe"
)
fi
fi
# The shellcheck tool warns that -m is only applied to the deepest
# We need the LD_PRELOADs from Steam visible at the paths that were
# directory and not any parents created via -p, but that's fine here:
# used for them, which might be their physical rather than logical
# we use a separate mkdir -p for each directory whose permissions we
# locations
# care about.
old_ifs
=
"
$IFS
"
# shellcheck disable=SC2174
IFS
=
:
{
for
preload
in
$caller_ld_preload
;
do
# Set up the home directory
if
[
-e
"
$preload
"
]
;
then
mkdir
-m700
-p
"
$fake_home
"
bwrap_options+
=(
--ro-bind
"
$preload
"
"
$preload
"
)
set
--
--bind
"
$fake_home
"
"
$HOME
"
--bind
"
$fake_home
"
"
$fake_home
"
"
$@
"
fi
done
IFS
=
"
$old_ifs
"
# Set up /var/tmp, XDG_*_HOME like Flatpak does
# We need libraries from the Steam Runtime, so make sure that's visible
mkdir
-m700
-p
"
$fake_home
/cache"
# (it should never need to be read/write though)
mkdir
-m700
-p
"
$fake_home
/cache/tmp"
if
[
-n
"
${
STEAM_RUNTIME
:-}
"
]
;
then
set
--
--bind
"
$fake_home
/cache/tmp"
/var/tmp
"
$@
"
bwrap_options+
=(
--ro-bind
"
$STEAM_RUNTIME
"
"
$STEAM_RUNTIME
"
)
bwrap_options+
=(
--setenv
XDG_CACHE_HOME
"
$fake_home
/cache"
)
fi
mkdir
-m700
-p
"
$fake_home
/config"
bwrap_options+
=(
--setenv
XDG_CONFIG_HOME
"
$fake_home
/config"
)
# Make sure the current working directory (the game we are going to
mkdir
-m700
-p
"
$fake_home
/data"
# run) is available. Some games write here.
bwrap_options+
=(
--setenv
XDG_DATA_HOME
"
$fake_home
/data"
)
PWD
=
"
$(
pwd
)
"
}
if
test
"
$HOME
"
-ef
"
$PWD
"
;
then
echo
"
$me
: Not making real
$PWD
available to container because it is"
\
"the home directory"
>
&2
else
bwrap_options+
=(
--bind
"
$PWD
"
"
$PWD
"
)
fi
bwrap_options+
=(
--chdir
"
$PWD
"
)
if
"
$BWRAP
"
--help
|
grep
unshare-uts
>
/dev/null
;
then
if
"
$BWRAP
"
--help
|
grep
unshare-uts
>
/dev/null
;
then
# Set a standard hostname for the container to make it easier
# Set a standard hostname for the container to make it easier
...
@@ -366,11 +359,11 @@ fi
...
@@ -366,11 +359,11 @@ fi
# Replace this process with bwrap, which replaces itself with the
# Replace this process with bwrap, which replaces itself with the
# desired command (unless exec fails)
# desired command (unless exec fails)
if
[
-n
"
$verbose
"
]
;
then
if
[
-n
"
$verbose
"
]
;
then
echo
"
$me
: '
$BWRAP
${
bwrap_options
[*]
}
$*
$bwrap_end_of_options
${
wrapped_command
[*]
}
'"
>
&2
echo
"
$me
: '
$BWRAP
${
bwrap_options
[*]
}
$bwrap_end_of_options
${
wrapped_command
[*]
}
'"
>
&2
fi
fi
exec
"
$BWRAP
"
"
${
bwrap_options
[@]
}
"
"
$@
"
$bwrap_end_of_options
"
${
wrapped_command
[@]
}
"
||
e
=
$?
exec
"
$BWRAP
"
"
${
bwrap_options
[@]
}
"
$bwrap_end_of_options
"
${
wrapped_command
[@]
}
"
||
e
=
$?
echo
"
$me
: failed to execute '
$BWRAP
${
bwrap_options
[*]
}
$*
$bwrap_end_of_options
${
wrapped_command
[*]
}
': exec status
$e
"
>
&2
echo
"
$me
: failed to execute '
$BWRAP
${
bwrap_options
[*]
}
$bwrap_end_of_options
${
wrapped_command
[*]
}
': exec status
$e
"
>
&2
exit
"
$e
"
exit
"
$e
"
# vim:set sw=4 sts=4 et:
# vim:set sw=4 sts=4 et:
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment