Skip to content

Commit d19bd02

Browse files
committed
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.
1 parent 09db82c commit d19bd02

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

common/profile-sync-daemon.in

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ suffix_needed() {
368368
[[ -n "$check_suffix" ]]
369369
}
370370

371+
infix_needed() {
372+
browser=$1
373+
[[ $browser == *"-in-snap" ]]
374+
}
375+
371376
dup_check() {
372377
# only for firefox, icecat, seamonkey, and palemoon
373378
# the LAST directory in the profile MUST be unique
@@ -429,13 +434,17 @@ do_sync_for() {
429434
DIR="$item"
430435
BACKUP="$item-backup"
431436
BACK_OVFS="$item-back-ovfs"
437+
infix=
438+
if infix_needed "$browser"; then
439+
infix="../snap.${browser%-in-snap}/"
440+
fi
432441
suffix=
433442
if suffix_needed "$browser"; then
434443
suffix="-${item##*/}"
435444
fi
436-
TMP="$VOLATILE/$user-$browser$suffix"
437-
UPPER="$VOLATILE/$user-$browser${suffix}-rw"
438-
WORK="$VOLATILE/.$user-$browser${suffix}"
445+
TMP="$VOLATILE/$infix$user-$browser$suffix"
446+
UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw"
447+
WORK="$VOLATILE/$infix.$user-$browser${suffix}"
439448
local REPORT
440449

441450
# make tmpfs container
@@ -554,13 +563,17 @@ do_unsync() {
554563
DIR="$item"
555564
BACKUP="$item-backup"
556565
BACK_OVFS="$item-back-ovfs"
566+
infix=
567+
if infix_needed "$browser"; then
568+
infix="../snap.${browser%-in-snap}/"
569+
fi
557570
suffix=
558571
if suffix_needed "$browser"; then
559572
suffix="-${item##*/}"
560573
fi
561-
TMP="$VOLATILE/$user-$browser$suffix"
562-
UPPER="$VOLATILE/$user-$browser${suffix}-rw"
563-
WORK="$VOLATILE/.$user-$browser${suffix}"
574+
TMP="$VOLATILE/$infix$user-$browser$suffix"
575+
UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw"
576+
WORK="$VOLATILE/$infix.$user-$browser${suffix}"
564577
# check if user has browser profile
565578
if [[ -h "$DIR" ]]; then
566579
unlink "$DIR"
@@ -634,11 +647,15 @@ parse() {
634647
for item in "${DIRArr[@]}"; do
635648
DIR="$item"
636649
BACKUP="$item-backup"
650+
infix=
651+
if infix_needed "$browser"; then
652+
infix="../snap.${browser%-in-snap}/"
653+
fi
637654
suffix=
638655
if suffix_needed "$browser"; then
639656
suffix="-${item##*/}"
640657
fi
641-
UPPER="$VOLATILE/$user-$browser${suffix}-rw"
658+
UPPER="$VOLATILE/$infix$user-$browser${suffix}-rw"
642659
if [[ -d "$DIR" ]]; then
643660
local CRASHArr=()
644661
while IFS= read -d '' -r backup; do
@@ -668,7 +685,7 @@ parse() {
668685
warn=
669686
fi
670687
echo -en " ${BLD}tmpfs dir:"
671-
echo -e "$(tput cr)$(tput cuf 17) ${GRN}$VOLATILE/$user-$browser$suffix${NRM}"
688+
echo -e "$(tput cr)$(tput cuf 17) ${GRN}$VOLATILE/$infix$user-$browser$suffix${NRM}"
672689
echo -en " ${BLD}profile size:"
673690
echo -e "$(tput cr)$(tput cuf 17) $psize${NRM}"
674691
if [[ -f $PID_FILE ]]; then

contrib/chromium-in-snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DIRArr[0]="$HOME/snap/chromium/common/chromium"
2+
PSNAME="chromium"

contrib/firefox-in-snap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if [[ -d "$HOME/snap/firefox/common/.mozilla/firefox" ]]; then
2+
index=0
3+
PSNAME="firefox"
4+
while read -r profileItem; do
5+
if [[ $(echo "$profileItem" | cut -c1) = "/" ]]; then
6+
# path is not relative
7+
DIRArr[$index]="$profileItem"
8+
else
9+
# we need to append the default path to give a
10+
# fully qualified path
11+
DIRArr[$index]="$HOME/snap/firefox/common/.mozilla/firefox/$profileItem"
12+
fi
13+
(( index=index+1 ))
14+
done < <(grep '^[Pp]ath=' "$HOME/snap/firefox/common/.mozilla/firefox/profiles.ini" | sed 's/[Pp]ath=//')
15+
fi
16+
17+
check_suffix=1

0 commit comments

Comments
 (0)