Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run everything under a slice, and terminate the entire slice #78

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions portable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ function enterSandbox() {
fi
pecho debug "procps-ng returned child ${childPid}"
systemd-run --tty \
-p Slice="portable-${unitName}.slice" \
-u "${unitName}-subprocess-$(uuidgen)" \
-p EnvironmentFile="${XDG_DATA_HOME}/${stateDirectory}/portable-generated.env" \
-p Environment=XAUTHORITY="${HOME}/.XAuthority" \
Expand Down Expand Up @@ -300,7 +301,7 @@ function execApp() {
-u "${unitName}" \
-p Description="Portable Sandbox for ${appID}" \
-p Documentation="https://github.com/Kraftland/portable" \
-p Slice=app.slice \
-p Slice="portable-${unitName}.slice" \
-p ExitType=cgroup \
-p OOMPolicy=stop \
-p KillMode=control-group \
Expand Down Expand Up @@ -575,7 +576,7 @@ function warnMulRunning() {
zenity --title "Application is not responding" --icon=utilities-system-monitor-symbolic --default-cancel --question --text="Do you wish to terminate the running session?"
fi
if [ $? = 0 ]; then
systemctl --user stop $@
systemctl --user stop "portable-${unitName}.slice"
else
pecho crit "User denied session termination"
exit $?
Expand Down Expand Up @@ -632,6 +633,7 @@ function dbusProxy() {
mkdir -p "${XDG_RUNTIME_DIR}/doc/by-app/${appID}"
systemd-run \
--user \
-p Slice="portable-${unitName}.slice" \
-u ${proxyName} \
-p ExecStop="rm ${XDG_RUNTIME_DIR}/.flatpak/${instanceId} -r" \
-- bwrap \
Expand Down Expand Up @@ -733,6 +735,7 @@ function dbusProxy() {
fi
systemd-run \
--user \
-p Slice="portable-${unitName}.slice" \
-u ${proxyName}-a11y \
-- bwrap \
--symlink /usr/lib64 /lib64 \
Expand Down Expand Up @@ -767,6 +770,7 @@ function execAppUnsafe() {
pecho info "GTK_IM_MODULE is ${GTK_IM_MODULE}"
pecho info "QT_IM_MODULE is ${QT_IM_MODULE}"
systemd-run --user \
-p Slice="portable-${unitName}.slice" \
-p Environment=QT_AUTO_SCREEN_SCALE_FACTOR="${QT_AUTO_SCREEN_SCALE_FACTOR}" \
-p Environment=QT_ENABLE_HIGHDPI_SCALING="${QT_ENABLE_HIGHDPI_SCALING}" \
-p EnvironmentFile="${XDG_DATA_HOME}/${stateDirectory}/portable-generated.env" \
Expand Down Expand Up @@ -863,7 +867,7 @@ function passPid() {
}

function stopApp() {
systemctl --user stop ${proxyName} ${proxyName}-a11y ${unitName}
systemctl --user stop "portable-${unitName}.slice"
}

function cmdlineDispatcher() {
Expand All @@ -887,7 +891,7 @@ function cmdlineDispatcher() {
}

if [[ $@ = "--actions quit" ]]; then
stopApp $@
stopApp "portable-${unitName}.slice"
exit $?
fi

Expand Down