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

"AM" 9.3, allow enable sandoxing when installing AppImages #1180

Merged
merged 37 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4f81106
Add sandboxing in `-ia` or 'install-appimage' using the `--sandbox` flag
ivan-hc Dec 2, 2024
e2b3a61
Save the list of installed apps if Aisap is not installed
ivan-hc Dec 2, 2024
9c7ae46
Allow AM users with appman-config file to choose local installation...
ivan-hc Dec 2, 2024
14e443f
Option --sandbox, detect if the argument is in BINDIR...
ivan-hc Dec 2, 2024
b26e31a
Extend sandboxing also to `-i`/`install` in case of local scripts
ivan-hc Dec 2, 2024
bc2e74e
Add option `-ias`
ivan-hc Dec 2, 2024
75ca1ae
Add option `-ias`
ivan-hc Dec 2, 2024
0fc969c
Update "help" message
ivan-hc Dec 2, 2024
b87e9b2
Fix "-ias", with multiple arguments it fails since "$1" is replaced
ivan-hc Dec 2, 2024
39aa6b3
Update README.md
ivan-hc Dec 2, 2024
be2e965
Update install-appimage.md
ivan-hc Dec 2, 2024
b24150c
Update install.md
ivan-hc Dec 2, 2024
6c5e45a
Update install.md
ivan-hc Dec 2, 2024
359431c
Update install.md
ivan-hc Dec 2, 2024
26440c4
Update install.md
ivan-hc Dec 2, 2024
27b72e2
Update install-appimage.md
ivan-hc Dec 2, 2024
b6c7429
Update install-appimage.md
ivan-hc Dec 2, 2024
27a126c
Update sandbox.md
ivan-hc Dec 2, 2024
ed5224e
Update APP-MANAGER
ivan-hc Dec 2, 2024
312c994
Update install.am
ivan-hc Dec 2, 2024
443e8de
Update install-appimage.md
ivan-hc Dec 2, 2024
eedc428
use shell built in test
Samueru-sama Dec 2, 2024
c2343dd
Merge pull request #1182 from Samueru-sama/dev
ivan-hc Dec 2, 2024
ec43a54
Update install-appimage.md
ivan-hc Dec 2, 2024
7316272
List "aisap" among the installed apps
ivan-hc Dec 3, 2024
78525a9
Update install-appimage.md
ivan-hc Dec 3, 2024
4fd7513
Merge pull request #1183 from ivan-hc/main
ivan-hc Dec 3, 2024
5074ead
Merge pull request #1184 from ivan-hc/main
ivan-hc Dec 3, 2024
b176970
Merge pull request #1185 from ivan-hc/main
ivan-hc Dec 3, 2024
7f4b850
Prevent "aisap" to be sandboxed
ivan-hc Dec 3, 2024
aeab9ca
Install aisap using the correct CLI
ivan-hc Dec 3, 2024
5e54dd9
Merge pull request #1188 from ivan-hc/main
ivan-hc Dec 4, 2024
55fe4d2
Fix sandboxing argument issue
ivan-hc Dec 4, 2024
3e3f235
Use LASTDIR
ivan-hc Dec 4, 2024
9970a24
Update install.am
ivan-hc Dec 4, 2024
504fcea
Show aisap sandboxing message if "appimage🔒" is detected
ivan-hc Dec 4, 2024
352d0b1
Update install-appimage.md
ivan-hc Dec 4, 2024
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
21 changes: 13 additions & 8 deletions APP-MANAGER
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

AMVERSION="9.2"
AMVERSION="9.3"

# Determine main repository and branch
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
Expand Down Expand Up @@ -383,7 +383,7 @@ available_options="about add apikey backup clean config disable downgrade downlo
install install-appimage launcher list lock neodb newrepo nolibfuse off on overwrite purge query remove sandbox \
select sync template test unlock update --all --appimages --apps --byname --config --convert --debug \
--devmode-disable --devmode-enable --disable-notifications --enable-notifications --force-latest --home --icons \
--launcher --less --pkg --rollback --disable-sandbox --sandbox --system --toolpack --user"
-ias --launcher --less --pkg --rollback --disable-sandbox --sandbox --system --toolpack --user"

function _completion_lists() {
# Remove existing lists and download new ones
Expand Down Expand Up @@ -1072,7 +1072,7 @@ case "$1" in
;;
'download'|'-d'|\
'extra'|'-e'|\
'install'|'-i'|\
'install'|'-i'|'-ias'|\
'install-appimage'|'-ia')
MODULE="install.am"
_online_check
Expand Down Expand Up @@ -1224,18 +1224,21 @@ case "$1" in
${LightBlue}$AMCLI -i {PROGRAM}
${LightBlue}$AMCLI -i --debug {PROGRAM}
${LightBlue}$AMCLI -i --force-latest {PROGRAM}
${LightBlue}$AMCLI -i --icons {PROGRAM}\033[0m
${LightBlue}$AMCLI -i --icons {PROGRAM}
${LightBlue}$AMCLI -i --sandbox {PROGRAM}\033[0m

Description: Install one or more programs or libraries from the list. With the \"--debug\" option you can see log messages to debug the script. For more details on \"--force-latest\", see the dedicated option, below. Use the \"--icons\" flag to allow the program to use icon themes. It can also be extended with additional flags (see \"--toolpack\").
Description: Install one or more programs or libraries from the list. With the \"--debug\" option you can see log messages to debug the script. For more details on \"--force-latest\", see the dedicated option, below. Use the \"--icons\" flag to allow the program to use icon themes. It can also be extended with additional flags (see \"--toolpack\"). The \"--sandbox\" flag allows you to set sandboxes for AppImage packages.

${Gold}install-appimage, -ia\033[0m
${Gold}install-appimage, -ia, -ias\033[0m

${LightBlue}$AMCLI -ia {PROGRAM}
${LightBlue}$AMCLI -ia --debug {PROGRAM}
${LightBlue}$AMCLI -ia --force-latest {PROGRAM}
${LightBlue}$AMCLI -ia --icons {PROGRAM}\033[0m
${LightBlue}$AMCLI -ia --icons {PROGRAM}
${LightBlue}$AMCLI -ia --sandbox {PROGRAM}
${LightBlue}$AMCLI -ias {PROGRAM}\033[0m

Description: Same as \"install\" (see above) but for AppImages only.
Description: Same as \"install\" (see above) but for AppImages only. Option \"-ias\" (aka Install AppImage & Sandox) is equivalent to \"-ia --sandbox\", to set sandboxes for AppImage packages.

${Gold}lock\033[0m

Expand Down Expand Up @@ -1302,6 +1305,8 @@ case "$1" in

Description: Run an AppImage in a sandbox using Aisap.

NOTE, \"--sandbox\" can be used as a flag in \"-i\" and \"-ia\" or can be replaced using the option \"-ias\" (aka Install AppImage & Sandox).

${Gold}sync, -s\033[0m

${LightBlue}$AMCLI -s\033[0m
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,27 @@ Allow installed apps to use system icon themes. You can specify the name of the
am -i --debug {PROGRAM}
am -i --force-latest {PROGRAM}
am -i --icons {PROGRAM}
am -i --sandbox {PROGRAM}

**Description**:

Install one or more programs or libraries from the list. With the "`--debug`" option you can see log messages to debug the script. For more details on "`--force-latest`", see the dedicated option, below. Use the "`--icons`" flag to allow the program to use icon themes. It can also be extended with additional flags (see "`--toolpack`").
Install one or more programs or libraries from the list. With the "`--debug`" option you can see log messages to debug the script. For more details on "`--force-latest`", see the dedicated option, below. Use the "`--icons`" flag to allow the program to use icon themes. It can also be extended with additional flags (see "`--toolpack`"). The "`--sandbox`" flag allows you to set sandboxes for AppImage packages.

NOTE: Since this is an "install" option, you can add the "`--user`" flag to install apps locally. See "`--user`" at the bottom to learn more.

------------------------------------------------------------------------
### `install-appimage`, `-ia`
### `install-appimage`, `-ia`, `-ias`

am -ia {PROGRAM}
am -ia --debug {PROGRAM}
am -ia --force-latest {PROGRAM}
am -ia --icons {PROGRAM}
am -ia --sandbox {PROGRAM}
am -ias {PROGRAM}

**Description**:

Same as "install" (see above) but for AppImages only.
Same as "install" (see above) but for AppImages only. Option "`-ias`" (aka Install AppImage & Sandox) is equivalent to "`-ia --sandbox`", to set sandboxes for AppImage packages.

------------------------------------------------------------------------
### `lock`
Expand Down Expand Up @@ -513,6 +516,8 @@ Removes one or more apps without asking.

Run an AppImage in a sandbox using Aisap.

NOTE, "`--sandbox`" can be used as a flag in "`-i`" and "`-ia`" or can be replaced using the option "`-ias`" (aka Install AppImage & Sandox).

------------------------------------------------------------------------
### `sync`, `-s`

Expand Down Expand Up @@ -705,6 +710,7 @@ Below you can access the documentation pages related to the use of "AM", complet
------------------------------------------------------------------------
- [Install applications](docs/guides-and-tutorials/install.md)
- [Install only AppImages](docs/guides-and-tutorials/install-appimage.md)
- [Install and sandbox AppImages in one go](docs/guides-and-tutorials/install-appimage.md#install-and-sandbox-appimages-in-one-go)
- [Install AppImages not listed in this database but available in other github repos](docs/guides-and-tutorials/extra.md)
- [List the installed applications](docs/guides-and-tutorials/files.md)
- [List and query all the applications available on the database](docs/guides-and-tutorials/list-and-query.md)
Expand Down
34 changes: 32 additions & 2 deletions docs/guides-and-tutorials/install-appimage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,51 @@ All flags for the `-i`/`install` option can be used here as well.
```
am -ia --debug {PROGRAM}
am -ia --force-latest {PROGRAM}
am -ia --user --debug {PROGRAM}
am -ia --user --force-latest {PROGRAM}
am -ia --debug {PROGRAM}
am -ia --sandbox {PROGRAM}
```
Same for AppMan.
```
appman -ia {PROGRAM}
appman -ia --debug {PROGRAM}
appman -ia --force-latest {PROGRAM}
appman -ia --sandbox {PROGRAM}
```
In this example, I run the script `brave-appimage` but running `brave`, that instead is the original upstream package.

https://github.com/user-attachments/assets/b938430c-ec0b-4b90-850f-1332063d5e53

In the video above, before proceeding I use the command `am -q` and `am -q --appimages` to show the difference between `brave` and `brave-appimage` in the lists.

------------------------------------------------------------------------
## Install and sandbox AppImages in one go
There is also a declination of `-ia`, namely `-ias` (Install AppImage & Sandox) which is equivalent to `-ia --sandbox` to start the sandbox configuration process via Aisap/Bubblewrap at the end of each installation
```
am -ias {PROGRAM}
am -ias --user {PROGRAM}
```
or
```
appman -ias {PROGRAM}
```

https://github.com/user-attachments/assets/3498f29b-3f6b-48b1-b4ff-2b1d083af57c

NOTE, `-ia --sandbox` and `-ias` are only for the AppImages listed in the "AM" database!

To Install and Sandbox other AppImages from local scripts and third-party/custom databases, use the `-i --sandbox` combination
```
am -i --sandbox {PROGRAM}
am -i --user --sandbox {PROGRAM}
```
or
```
appman -i --sandbox {PROGRAM}
```
Sandboxing of other formats is not supported.

See also how sandboxing works in "AM", at "[Sandboxing](./sandbox.md)".

------------------------------------------------------------------------

| [Back to "Guides and tutorials"](../../README.md#guides-and-tutorials) | [Back to "Main Index"](../../README.md#main-index) | ["Portable Linux Apps"](https://portable-linux-apps.github.io/) | [ "AppMan" ](https://github.com/ivan-hc/AppMan) |
Expand Down
26 changes: 25 additions & 1 deletion docs/guides-and-tutorials/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ The option `-i` or `install` is the one responsible of the installation of apps

https://github.com/user-attachments/assets/62bc7444-8b1f-4db2-b23b-db7219eec15d

----------------------------------------------------
### Install, normal behaviour
This is the normal syntax.
```
Expand All @@ -18,6 +19,7 @@ appman -i {PROGRAM}
```
Since version 9, "AM" also covers locally installed apps. It is therefore not necessary to add a root password, once the `--user` flag is added. And this can also be used in conjunction with the other flags below.

----------------------------------------------------
### Install, debug an installation script
The "install.am" module contains some patches to disable long messages. You can see them with the `--debug` flag.

Expand All @@ -32,7 +34,7 @@ or
appman -i --debug {PROGRAM}
```


----------------------------------------------------
### Install the "latest" stable release instead of the latest "unstable"
By default, many installation scripts for apps hosted on github will point to the more recent generic release instead of "latest", which is normally used to indicate that the build is "stable". This is because upstream developers do not always guarantee a certain packaging format in "latest", sometimes they may only publish packages for Windows or macOS, so pointing to "latest" would not guarantee that any package for Linux will be installed.

Expand All @@ -48,6 +50,28 @@ appman -i --force-latest {PROGRAM}

https://github.com/user-attachments/assets/ee29adfd-90e1-46f7-aed9-b9c410f68776

----------------------------------------------------
### Install and Sandbox AppImages
Since version 9.3 it is possible to use the "`--sandbox`" flag to sandbox only AppImages during the installation process
```
am -i --sandbox {PROGRAM}
am -i --user --sandbox {PROGRAM}
```
or
```
appman -i --sandbox {PROGRAM}
```

![Istantanea_2024-12-02_03-50-43-2](https://github.com/user-attachments/assets/da90b4ea-f199-469c-b2a3-e410577f3847)

...note that sandboxing only works for AppImages (see "[Sandboxing](./sandbox.md)"), for other programs it will not work.

NOTE, **it is recommended to use the `-i --sandbox` combination only if you have local and custom scripts to install.**

If you rely on the AppImages listed in the "AM" database, use the `-ia --sandbox` combination or even better `-ias` (Install AppImage & Sandox).

See more at "[Install only AppImages](./install-appimage.md)".

------------------------------------------------------------------------

| [Back to "Guides and tutorials"](../../README.md#guides-and-tutorials) | [Back to "Main Index"](../../README.md#main-index) | ["Portable Linux Apps"](https://portable-linux-apps.github.io/) | [ "AppMan" ](https://github.com/ivan-hc/AppMan) |
Expand Down
8 changes: 7 additions & 1 deletion docs/guides-and-tutorials/sandbox.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Sandbox an AppImage
This page explains in detail how AppImage sandboxing works individually in "AM". To apply them during installation, go to the related guide "[Install and sandbox AppImages in one go](./install-appimage.md#install-and-sandbox-appimages-in-one-go)" instead.

Since version 6.12, "AM"/"AppMan" uses Bubblewrap for sandboxing AppImage packages, thanks to "[Aisap](https://github.com/mgord9518/aisap)", a highly intuitive and configurable command line solution.

The option "`--sandbox`", which since version 5.3 was using Firejail, has taken on a completely different appearance and usability, thanks to the intense work of @Samueru-sama, who managed to extend and enhance "Aisap", making it extremely easy to use in our project, to the point of making us forget that we are using a command line utility.
Expand All @@ -7,6 +9,7 @@ The option "`--sandbox`", which since version 5.3 was using Firejail, has taken

In this sense, "Aisap" may be considered a reference point for the future of AppImages sandboxing!

----------------------------------------------------
#### How to enable a sandbox
This method works as follows:
```
Expand All @@ -28,19 +31,22 @@ We will first compile the Aisap script in a non-privileged, easy-to-access direc

NOTE, the default location for the sandboxed homes is at $HOME/.local/am-sandboxes, but that location can be changed by setting the $SANDBOXDIR environemt variable.

----------------------------------------------------
#### How to disable a sandbox
To remove the sandbox just run the command of the AppImage with the flag "--disable-sandbox", like this:
```
$APP --disable-sandbox
```

----------------------------------------------------
#### Sandboxing example
In the video below we will use "Baobab" (GTK3 version), a disk space analyzer, available in the database as "baobab-gtk3".

Among the XDG directories we will authorize "Images" (Pictures) and "Videos" (Videos), while manually we will authorize "Public". The test will be carried out in normal mode, then in sandbox and again without sandbox:

https://github.com/ivan-hc/AM/assets/88724353/dd193943-7b08-474a-bbbb-4a6906de8b24

----------------------------------------------------
#### About Aisap sandboxing
For more information about "Aisap", visit https://github.com/mgord9518/aisap

Expand All @@ -55,4 +61,4 @@ EXTRA: The behavior of this option can be tested in a completely standalone way
| [Back to "Guides and tutorials"](../../README.md#guides-and-tutorials) | [Back to "Main Index"](../../README.md#main-index) | ["Portable Linux Apps"](https://portable-linux-apps.github.io/) | [ "AppMan" ](https://github.com/ivan-hc/AppMan) |
| - | - | - | - |

------------------------------------------------------------------------
------------------------------------------------------------------------
14 changes: 13 additions & 1 deletion modules/install.am
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ case "$1" in
fi
;;

'install'|'-i'|\
'install'|'-i'|'-ias'|\
'install-appimage'|'-ia')
[ "$AMCLI" = "am" ] && echo "$@" | grep -q -- "--user" && _appman

Expand All @@ -370,6 +370,7 @@ case "$1" in
echo " USAGE: $AMCLI $1 --debug [ARGUMENT]"
echo " USAGE: $AMCLI $1 --force-latest [ARGUMENT]"
echo " USAGE: $AMCLI $1 --icons [ARGUMENT]"
echo " USAGE: $AMCLI $1 --sandbox [ARGUMENT]"
[ "$AMCLI" = "am" ] && echo " USAGE: $AMCLI $1 --user [ARGUMENT]"
exit 1
;;
Expand All @@ -389,6 +390,7 @@ case "$1" in
METAPACKAGES="kdegames kdeutils node platform-tools"

if [ "$1" = "-ia" ] || [ "$1" = "install-appimage" ]; then _install_appimage; fi
if [ "$1" = "-ias" ]; then FLAGS=$(echo "$@ --sandbox" | tr ' ' '\n' | grep -- "--" | tr '\n ' ' '); _install_appimage; fi

for arg in $entries; do
echo ""
Expand Down Expand Up @@ -423,6 +425,16 @@ case "$1" in
else
echo "💀 ERROR: \"$arg\" does NOT exist in the \"AM\" database, $(printf "please check the list, run the \"%b$AMCLIPATH_ORIGIN -l\033[0m\" command.\n\n" "${Gold}")" | fold -sw 72 | sed 's/^/ /g'
fi
if echo "$FLAGS" | grep -q -- "--sandbox"; then
if ! command -v aisap >/dev/null 2>&1; then
mv "$AMCACHEDIR"/installed "$CACHEDIR"/installed.backup.am 2>/dev/null
"$AMCLIPATH_ORIGIN" --sandbox "$arg"
mv "$CACHEDIR"/installed.backup.am "$AMCACHEDIR"/installed 2>/dev/null
else
echo ""
"$AMCLIPATH_ORIGIN" --sandbox "$arg"
fi
fi
echo "____________________________________________________________________________"
done
echo "============================================================================"
Expand Down
19 changes: 17 additions & 2 deletions modules/sandboxes.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# THIS MODULE INCLUDES ALL ACTIONS INTENDED TO ISOLATE DOTFILES OR CONTAINERIZE INSTALLED APPIMAGES
###################################################################################################

SUDOCMD_ORIGIN="$SUDOCMD"

# Get xdg variables for _configure_dirs_access
for DIR in DESKTOP DOCUMENTS DOWNLOAD GAMES MUSIC PICTURES VIDEOS; do
eval XDG_DIR="$(xdg-user-dir $DIR 2>/dev/null)"
Expand Down Expand Up @@ -70,14 +72,26 @@ _check_aisap() {
echo " OPERATION ABORTED!"
return 1
fi
"$AMCLIPATH" -i aisap >/dev/null 2>&1
if [ "$CLI" = am ] && [ -f "$APPMANCONFIG"/appman-config ]; then
read -r -p " ◆ DO YOU WISH TO INSTALL AISAP LOCALLY? (Y/n) " yn
if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
"$AMCLIPATH" -i aisap >/dev/null 2>&1
else
"$AMCLIPATH" -i --user aisap >/dev/null 2>&1
fi
else
"$AMCLIPATH" -i aisap >/dev/null 2>&1
fi
command -v aisap 1>/dev/null || return 1
echo " aisap installed successfully!"
fi
fi
if grep "aisap-am" "$TARGET" >/dev/null 2>&1; then
echo " $1 is already sandboxed!"
return 1
fi
if [ -n "$BINDIR" ] && test -f "$BINDIR"/"$1"; then
ivan-hc marked this conversation as resolved.
Show resolved Hide resolved
SUDOCMD=""
fi
}

_generate_sandbox_script() {
Expand Down Expand Up @@ -239,6 +253,7 @@ _install_sandbox_script() {
printf '\033[0m%s\033[33m\n' " to revert the changes, in this case that is:"
printf '\033[33m%s\033[0m' " $1 --disable-sandbox"
printf '%s\033[33m%s\n\033[0m\n' " or " "$AMCLI --disable-sandbox $1"
SUDOCMD="$SUDOCMD_ORIGIN"
}

# Main logic
Expand Down