Replies: 3 comments 4 replies
-
Start them like
Yes (click me)#!/bin/bash
# SPDX-License-Identifier: ISC
# Copyright © 2021 rusty-snake
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE
get_sandbox() {
local radiolist=(--radiolist "firejail --list" 0 0 0)
while read -r sandbox; do
radiolist+=("${sandbox%%:*}" "${sandbox#*:}" off)
done < <(firejail --list)
# FIXME: reject empty selection
SBOXPID=$(dialog "${radiolist[@]}" 2>&1 >/dev/tty)
}
list_files() {
local checklist=(--checklist "ls ~/Downloads" 0 0 0)
while read -r file; do
[[ $file == . || $file == .. ]] && continue
checklist+=("$file" "" on)
# FIXME: Handle --ls failures (e.g. EACESS)
done < <(firejail --ls="$SBOXPID" ~/Downloads | awk '{ print $5 }')
# FIXME: What the hell!!!
eval "SELECTED_FILES=($(dialog "${checklist[@]}" 2>&1 >/dev/tty))"
}
get_files() {
for file in "${SELECTED_FILES[@]}"; do
firejail --get="$SBOXPID" "$HOME/Downloads/$file"
done
}
get_sandbox
list_files
get_files
root can: |
Beta Was this translation helpful? Give feedback.
-
As @rusty-snake mentioned, instead of trying to find its id, you can give firejail --name=firefox1 --private firefox
# on another shell/terminal
firejail --get=firefox1 ~/Downloads/foo.pdf
In this case, it's probably simpler to just join the sandbox and use shell firejail --name=firefox1 --private firefox
# on another shell/terminal
firejail --quiet --profile=tar --join=firefox1 sh -c \
'cd ~/Downloads && tar c ./*.pdf' | tar x The above should copy all pdf files in ~/Downloads to the current directory. firejail --quiet --profile=tar --join=firefox1 sh -c \
'cd ~/Downloads && tar c .' | tar x Or to copy the directory itself: firejail --quiet --join=firefox1 tar c Downloads | tar x Note: The first tar above runs inside the sandbox and the second one runs |
Beta Was this translation helpful? Give feedback.
-
@rusty-snake @kmk3 Maybe we could look into adding/coding a new option for this use-case, e.g. |
Beta Was this translation helpful? Give feedback.
-
I often run temporary sandboxed (
--private
) instances of Firefox in quick one-off workflows in addition to your normal persistent sandboxed Firefox instances.However, retrieving downloaded files is a pain--the process is like this:
firejail --list
, look for the id (often times you have to guess, if there are several involved), thenfirejail --get=<id> ~/Downloads/<this is the most annoying part>
where<this is the most annoying part>
is the part you have to type out manually because wildcards or tab completion isn't supported. If the filename you downloaded on the browser is something like "fQiY3jq8Cs9m-3940132471.pdf", it seems you have to manually read and type all that out and hope there isn't a typo.Am I missing something? Can this be automated/scripted to make it a more seamless process? IIRC, downloaded files in a
--private
instance aren't directly accessible by your filesystem so I can't just go there andmv
it for retrieval.Much appreciated.
Relates to:
Beta Was this translation helpful? Give feedback.
All reactions