Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--allow-local-files fails on chromium in snap environment #201

Closed
matoken opened this issue Feb 15, 2020 · 12 comments · Fixed by #203 or #283
Closed

--allow-local-files fails on chromium in snap environment #201

matoken opened this issue Feb 15, 2020 · 12 comments · Fixed by #203 or #283

Comments

@matoken
Copy link

matoken commented Feb 15, 2020

It happens in npm, npx, Standalone binary in Debian sid adm64 environment.

$ marp --allow-local-files --pdf test.md
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from test.md.
[  WARN ] Marp CLI has detected accessing to local file. That is blocked by security reason. Instead we recommend using assets uploaded to
          online. (Or you can use --allow-local-files option if you are understood of security risk)
[ ERROR ] Failed converting Markdown. (net::ERR_FILE_NOT_FOUND at file:///tmp/tmp-1187272jpnBmJk9frtF.html)

Chromium in this environment includes a snap version and a Debian package version.

$ which chromium
/snap/bin/chromium
$ PATH=`echo $PATH|tr : '\n'|grep -v snap|tr "\n" :` which chromium
/usr/bin/chromium

Using the package version instead of the snap version worked fine.

$ PATH=`echo $PATH|tr : '\n'|grep -v snap|tr "\n" :` marp --allow-local-files --pdf hoge.md
@yhatt
Copy link
Member

yhatt commented Feb 15, 2020

See also similar issue happened by Snap Chromium: marp-team/marp-vscode#94, https://forum.snapcraft.io/t/sharing-files-via-tmp/1613

A simple workaround:

CHROME_PATH=/usr/bin/chromium marp --allow-local-files --pdf foobar.md

@matoken
Copy link
Author

matoken commented Feb 16, 2020

Thank you.
Chromium could be specified by using CHROME_PATH.
It seems to be helpful if a warning is displayed when using the snap version of Chromium.

@yhatt
Copy link
Member

yhatt commented Feb 16, 2020

The suggested warning may be helpful for CLI user, but does not resolve marp-team/marp-vscode#94 so thinking about radical solution would be better.

Owing to your report, we recognized the Snapd Chromium cannot access from the sandbox container to user-land /tmp/, due to strict snap confinement. Snapd Chromium only allows reading visible files from $HOME.

Marp CLI should create visible tmp file into $HOME when the resolved Chromium path starts with /snap.

@yhatt
Copy link
Member

yhatt commented Feb 22, 2020

Fixed in v0.17.1.

@zhelnio
Copy link

zhelnio commented Sep 9, 2020

Looks like this bug still appears

  • Ubuntu 20.04.1 LTS, updated
  • chromium installed using the system default apt install (installs snap package)
$ npx marp slides_ru.md --allow-local-files --output out/slides_ru.pdf
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from slides_ru.md.
[  WARN ] The local file is missing and will be ignored. Make sure the file path is correct.
[ ERROR ] Failed converting Markdown. (net::ERR_FILE_NOT_FOUND at file:///tmp/tmp-32659-D1CkptSeH8No-.html)

$ which chromium
/snap/bin/chromium

$ npx marp --version
@marp-team/marp-cli v0.21.0 (w/ @marp-team/marp-core v1.3.0)

@yhatt
Copy link
Member

yhatt commented Sep 9, 2020

@zhelnio Thanks!

Previously Marp CLI could find out /snap/bin/chromium and detect the snap chromium from the path starting with /snap/. But now, Marp is trying to use /usr/bin/chromium-browser, that is a proxy script for calling /snap/bin/chromium likely added at some point in the past half of year.

yhatt@yhatt-ubuntu2004:~$ echo '# Marp' | DEBUG=puppeteer:launcher npx @marp-team/marp-cli -o ~/marp.pdf --allow-local-files
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from -.
  puppeteer:launcher Calling /usr/bin/chromium-browser --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --user-data-dir=/tmp/marp-cli-conversion --headless --hide-scrollbars --mute-audio about:blank --export-tagged-pdf --remote-debugging-pipe +0ms
[  WARN ] The local file is missing and will be ignored. Make sure the file path is correct.
[ ERROR ] Failed converting Markdown. (net::ERR_FILE_NOT_FOUND at file:///tmp/tmp-9964-KRtSNXzO5F7m-.html)

yhatt@yhatt-ubuntu2004:~$ tail /usr/bin/chromium-browser 
      }
    }
EOF
  )"
  qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "$SCRIPT" 2> /dev/null
fi

# TODO: handle other desktop environments

exec /snap/bin/chromium "$@"

Probably we should check the path of "real" process launched by Puppeteer.

@yhatt yhatt reopened this Sep 9, 2020
@zhelnio
Copy link

zhelnio commented Sep 9, 2020

@yhatt I've tried to set CHROME_PATH but it did not help

$ CHROME_PATH=/snap/bin/chromium npx marp slides_ru.md --allow-local-files --output out/slides_ru.pdf
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from slides_ru.md.
[ ERROR ] Failed converting Markdown. (dir option must be relative to "/tmp", found "/home/user".)

@yhatt
Copy link
Member

yhatt commented Sep 10, 2020

I think it may be another problem that has brought from #259 and #264 (released in v0.20.0). Is CHROME_PATH=/snap/bin/chromium npx @marp-team/[email protected] working?

@zhelnio
Copy link

zhelnio commented Sep 10, 2020

No, it does not

$ CHROME_PATH=/snap/bin/chromium npx @marp-team/[email protected] slides_ru.md --allow-local-files --output out/slides_ru.pdf
npx: installed 271 in 24.933s
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from slides_ru.md.
[ ERROR ] Failed converting Markdown. (dir option must be relative to "/tmp", found "/home/user".)

@yhatt
Copy link
Member

yhatt commented Sep 10, 2020

Ah, it didn't a real matter. Probably we've missed a breaking change of node-tmp to create tmpfile for conversion.

@yhatt
Copy link
Member

yhatt commented Sep 12, 2020

Fixed again in v0.21.1.

@nevyn

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants