Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 2 additions & 7 deletions src/plugins/terminal/www/Terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,16 @@ const Terminal = {
reject("Alpine is not installed.");
return;
}

const cmd = `
set -e

INCLUDE_FILES="alpine .downloaded .extracted axs"
if [ "$FDROID" = "true" ]; then
INCLUDE_FILES="$INCLUDE_FILES libtalloc.so.2 libproot-xed.so"
fi

EXCLUDE="--exclude=alpine/data --exclude=alpine/system --exclude=alpine/vendor --exclude=alpine/sdcard --exclude=alpine/storage --exclude=alpine/public"

EXCLUDE="--exclude=alpine/data --exclude=alpine/system --exclude=alpine/vendor --exclude=alpine/sdcard --exclude=alpine/storage --exclude=alpine/public --exclude=alpine/apex --exclude=alpine/odm --exclude=alpine/product --exclude=alpine/system_ext --exclude=alpine/linkerconfig --exclude=alpine/proc --exclude=alpine/sys --exclude=alpine/dev --exclude=alpine/run --exclude=alpine/tmp"
tar -cf "$PREFIX/aterm_backup.tar" -C "$PREFIX" $EXCLUDE $INCLUDE_FILES
echo "ok"
`;

const result = await Executor.execute(cmd);
if (result === "ok") {
resolve(cordova.file.dataDirectory + "aterm_backup.tar");
Expand Down Expand Up @@ -387,7 +382,7 @@ const Terminal = {
rm -rf -- "$item"
done

tar -xf "$PREFIX/aterm_backup.bin" -C "$PREFIX"
tar -xf "$PREFIX/aterm_backup.tar" -C "$PREFIX"
echo "ok"
`;

Expand Down
6 changes: 3 additions & 3 deletions src/settings/terminalSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export default function terminalSettings() {
await system.copyToUri(
data.uri,
cordova.file.dataDirectory,
"aterm_backup",
"aterm_backup.tar",
console.log,
console.error,
);
Expand All @@ -341,7 +341,7 @@ export default function terminalSettings() {
await Terminal.restore();

// Clean up
const backupFilename = "aterm_backup.bin";
const backupFilename = "aterm_backup.tar";
const tempBackupPath = cordova.file.dataDirectory + backupFilename;
const tempFS = fsOperation(tempBackupPath);
await tempFS.delete();
Expand All @@ -352,7 +352,7 @@ export default function terminalSettings() {
);
},
toast,
"application/x-tar",
"application/octet-stream",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 MIME type change widens file picker filter

Changing from "application/x-tar" to "application/octet-stream" makes the file picker show all files instead of only .tar archives. While this is a pragmatic choice given Android's inconsistent MIME type associations for .tar files, it means a user can accidentally select any binary file and attempt a restore with it. Terminal.restore() will only fail after copying the wrong file to $PREFIX and running tar -xf on it.

If application/x-tar did not work reliably on device (which is a valid reason), consider also trying "application/x-tar,application/octet-stream" as a comma-separated fallback list (if the sdcard.openDocumentFile API supports it), or at least add a filename validation step before the restore to check that the selected file ends with .tar.

);
} catch (error) {
loader.removeTitleLoader();
Expand Down