From d19bd027f11bac363532e02d6545724b08094485 Mon Sep 17 00:00:00 2001 From: vasilev Date: Mon, 9 Mar 2026 23:35:15 +0600 Subject: [PATCH] feature: Support for snapped versions of Firefox and Chromium. As AppArmor profiles allow access only to `$XDG_RUNTIME_DIR/snap.$SNAP_INSTANCE_NAME/`, re-routed profiles of snapped browsers exactly into respective `$XDG_RUNTIME_DIR/snap.$SNAP_INSTANCE_NAME/` subdirectories. --- common/profile-sync-daemon.in | 33 +++++++++++++++++++++++++-------- contrib/chromium-in-snap | 2 ++ contrib/firefox-in-snap | 17 +++++++++++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 contrib/chromium-in-snap create mode 100644 contrib/firefox-in-snap diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 8564e797..eda1f66e 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -368,6 +368,11 @@ suffix_needed() { [[ -n "$check_suffix" ]] } +infix_needed() { + browser=$1 + [[ $browser == *"-in-snap" ]] +} + dup_check() { # only for firefox, icecat, seamonkey, and palemoon # the LAST directory in the profile MUST be unique @@ -429,13 +434,17 @@ do_sync_for() { DIR="$item" BACKUP="$item-backup" BACK_OVFS="$item-back-ovfs" + infix= + if infix_needed "$browser"; then + infix="../snap.${browser%-in-snap}/" + fi suffix= if suffix_needed "$browser"; then suffix="-${item##*/}" fi - TMP="$VOLATILE/$user-$browser$suffix" - UPPER="$VOLATILE/$user-$browser${suffix}-rw" - WORK="$VOLATILE/.$user-$browser${suffix}" + TMP="$VOLATILE/$infix$user-$browser$suffix" + UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw" + WORK="$VOLATILE/$infix.$user-$browser${suffix}" local REPORT # make tmpfs container @@ -554,13 +563,17 @@ do_unsync() { DIR="$item" BACKUP="$item-backup" BACK_OVFS="$item-back-ovfs" + infix= + if infix_needed "$browser"; then + infix="../snap.${browser%-in-snap}/" + fi suffix= if suffix_needed "$browser"; then suffix="-${item##*/}" fi - TMP="$VOLATILE/$user-$browser$suffix" - UPPER="$VOLATILE/$user-$browser${suffix}-rw" - WORK="$VOLATILE/.$user-$browser${suffix}" + TMP="$VOLATILE/$infix$user-$browser$suffix" + UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw" + WORK="$VOLATILE/$infix.$user-$browser${suffix}" # check if user has browser profile if [[ -h "$DIR" ]]; then unlink "$DIR" @@ -634,11 +647,15 @@ parse() { for item in "${DIRArr[@]}"; do DIR="$item" BACKUP="$item-backup" + infix= + if infix_needed "$browser"; then + infix="../snap.${browser%-in-snap}/" + fi suffix= if suffix_needed "$browser"; then suffix="-${item##*/}" fi - UPPER="$VOLATILE/$user-$browser${suffix}-rw" + UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw" if [[ -d "$DIR" ]]; then local CRASHArr=() while IFS= read -d '' -r backup; do @@ -668,7 +685,7 @@ parse() { warn= fi echo -en " ${BLD}tmpfs dir:" - echo -e "$(tput cr)$(tput cuf 17) ${GRN}$VOLATILE/$user-$browser$suffix${NRM}" + echo -e "$(tput cr)$(tput cuf 17) ${GRN}$VOLATILE/$infix$user-$browser$suffix${NRM}" echo -en " ${BLD}profile size:" echo -e "$(tput cr)$(tput cuf 17) $psize${NRM}" if [[ -f $PID_FILE ]]; then diff --git a/contrib/chromium-in-snap b/contrib/chromium-in-snap new file mode 100644 index 00000000..8219ec02 --- /dev/null +++ b/contrib/chromium-in-snap @@ -0,0 +1,2 @@ +DIRArr[0]="$HOME/snap/chromium/common/chromium" +PSNAME="chromium" diff --git a/contrib/firefox-in-snap b/contrib/firefox-in-snap new file mode 100644 index 00000000..7231d8b8 --- /dev/null +++ b/contrib/firefox-in-snap @@ -0,0 +1,17 @@ +if [[ -d "$HOME/snap/firefox/common/.mozilla/firefox" ]]; then + index=0 + PSNAME="firefox" + while read -r profileItem; do + if [[ $(echo "$profileItem" | cut -c1) = "/" ]]; then + # path is not relative + DIRArr[$index]="$profileItem" + else + # we need to append the default path to give a + # fully qualified path + DIRArr[$index]="$HOME/snap/firefox/common/.mozilla/firefox/$profileItem" + fi + (( index=index+1 )) + done < <(grep '^[Pp]ath=' "$HOME/snap/firefox/common/.mozilla/firefox/profiles.ini" | sed 's/[Pp]ath=//') +fi + +check_suffix=1