Skip to content

Commit

Permalink
Update APP-MANAGER: prevent non-privileged users using "AM"...
Browse files Browse the repository at this point in the history
...this works for multi-accuont configurations.

"AM" will be used only by the system administrator (or rather, the one who installed it the first time) and the "root" user.

Non-privileged users will be advised to contact the owner of the /opt/am directory to change permissions, or at least use "AppMan" as an alternative.

This should fix the problems found here:

#466

starting with this minor release.
  • Loading branch information
ivan-hc authored Apr 23, 2024
1 parent 9c40a0e commit ddbb8f0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion APP-MANAGER
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DIR="$( cd "$( dirname "$0" )" && pwd )"
CLI=$(basename "$0")
AMVERSION="6.6.2"
AMVERSION="6.6.2-1"

SCRIPTDIR="$(if command -v xdg-user-dir &>/dev/null; then xdg-user-dir DESKTOP; else echo $HOME; fi)"

Expand Down Expand Up @@ -119,6 +119,20 @@ export AMCATALOGUEICONS="https://github.com/Portable-Linux-Apps/P
# Determine system architecture and current user
export arch="$HOSTTYPE"
export currentuser="$USER"
if [ "$AMCLI" == am ]; then
ampathowner=$(ls -ld /opt/am | awk 'NR==1 {print $3}')
if [ "$ampathowner" != "$currentuser" ]; then
echo ' 💀 ERROR: you are not the owner of /opt/am, so you cannot use "AM"'
echo '--------------------------------------------------------------------------'
echo ' The user that have installed "AM" on this system is "'"$ampathowner"'"'
echo ' you are only allowed to use the installed apps, not to manage them.'
echo '--------------------------------------------------------------------------'
echo ' Please, contact "'"$ampathowner"'" to change the ownership of /opt/am or'
echo ' consider using "AppMan" instead, see https://github.com/ivan-hc/AppMan'
echo '--------------------------------------------------------------------------'
exit
fi
fi

if [[ -f "$AMPATH"/new-repo.txt ]]; then
AMREPO=$(<"$AMPATH/new-repo.txt") # Utilizing command substitution with < for more efficient file reading
Expand Down

0 comments on commit ddbb8f0

Please sign in to comment.