Add open-urls-in-browser combinator
This commit is contained in:
parent
f5cc61ef63
commit
d35e9df391
2 changed files with 37 additions and 0 deletions
|
|
@ -1122,6 +1122,24 @@ in rec {
|
|||
;
|
||||
};
|
||||
|
||||
open-urls-in-browser = {
|
||||
sig = "Combinator";
|
||||
doc = ''
|
||||
Allows access to open URLs in `$BROWSER`.
|
||||
|
||||
This works by creating a pipe that is mounted into the jail that forwards
|
||||
all URLs to the `$BROWSER` outside of the jail. This way the jailed
|
||||
program can launch your browser, even if it has a subset of the
|
||||
permissions your browser has.
|
||||
'';
|
||||
__functor = _:
|
||||
compose [
|
||||
(jail-to-host-channel "browserchannel" ''"$BROWSER" "$1"'')
|
||||
(set-env "BROWSER" "browserchannel")
|
||||
]
|
||||
;
|
||||
};
|
||||
|
||||
############################################
|
||||
# deprecated
|
||||
persisthome = {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,25 @@ spec = parallel $ inTestM $ do
|
|||
|]
|
||||
liftIO $ (read out :: Int) `shouldSatisfy` (< 100)
|
||||
|
||||
describe "open-urls-in-browser" $ do
|
||||
it "exposes a $BROWSER in the jail that calls $BROWSER outside of the jail" $ do
|
||||
tmpDir <- getTestDir
|
||||
void $
|
||||
runNixDrv
|
||||
[i|
|
||||
let
|
||||
fakeBrowser = sh ''
|
||||
echo "got url: $1" >> #{tmpDir </> "fake-browser"}
|
||||
'';
|
||||
jailed = jail "test" (sh ''$BROWSER https://example.org'') (c: [
|
||||
c.open-urls-in-browser
|
||||
]);
|
||||
in sh ''
|
||||
BROWSER=${lib.getExe fakeBrowser} ${lib.getExe jailed}
|
||||
''
|
||||
|]
|
||||
liftIO $ readFile (tmpDir </> "fake-browser") `shouldReturn` "got url: https://example.org\n"
|
||||
|
||||
describe "readonly-from-path-var" $ do
|
||||
forM_ [":", " "] $ \separator ->
|
||||
describe ("with separator \"" <> separator <> "\"") $ do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue