From 54ae6d9a70318babfb858fa1c71da16f2a31a271 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 25 Dec 2017 15:26:13 +0000 Subject: sisyphus-gui : prevent instant crash if application is started as non-root user --- sisyphus-gui | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/sisyphus-gui b/sisyphus-gui index 87254ec..0d46356 100755 --- a/sisyphus-gui +++ b/sisyphus-gui @@ -1,12 +1,29 @@ #!/usr/bin/env bash -# Sisyphus is a simple GUI for sisyphus, the portage wrapper +# Sisyphus-GUI is a simple frontend for libsisyphus # Main Author : Ghiunhan Mamut @ Redcore Linux Project +if [[ -f /lib/gentoo/functions.sh ]] ; then + source /lib/gentoo/functions.sh +else + echo "Cannot import Gentoo functions, I will abort now!" + exit 1 +fi + +checkifroot() { + if [[ "$(whoami)" != root ]] ; then + eerror "I won't do that, unless you're root!" + exit 1 + fi +} + + main() { - pushd /usr/share/sisyphus - python3 sisyphus-gui.py - popd + if checkifroot; then + pushd /usr/share/sisyphus + python3 sisyphus-gui.py + popd + fi } main -- cgit v1.2.3