AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 782766
Accepted
Pietro
Pietro
Asked: 2024-08-30 18:21:03 +0800 CST2024-08-30 18:21:03 +0800 CST 2024-08-30 18:21:03 +0800 CST

无法使用浏览器打开存储在 RAM 磁盘上的 HTML 文件

  • 772

我编写了一个脚本,可以在 RAM 磁盘上生成 PDF 和 HTML 文件:

  • PDF 文件可以按预期打开。
  • HTML 文件可以用编辑器打开,但不能用浏览器打开。

这是我从 Ubuntu Linux 24.04 上的浏览​​器(Chrome、Firefox)收到的错误消息:

Access to the file was denied
The file at file:///dev/shm/test.html is not readable. It may have been removed, moved or file permissions may be preventing access.
ERR_ACCESS_DENIED

这些是文件详细信息:

/dev/shm> ll
-rw-rw-r-- 1  11K 2024-08-30 11:06 test.html

如果我将文件复制到硬盘上,它可以按预期打开:

/dev/shm> cp ./test.html ~
browser
  • 1 1 个回答
  • 355 Views

1 个回答

  • Voted
  1. Best Answer
    Chris Davies
    2024-08-30T22:20:54+08:002024-08-30T22:20:54+08:00

    它不是/dev/shm文件系统类型,而是与snaptmpfs安装直接相关。证据:

    echo '<h1>Header</h1><p>Paragraph of text</p>' >/tmp/file.html
    cp /tmp/file.html /dev/shm
    
    firefox file:///tmp/file.html        # Firefox renders the file as expected
    
    firefox file:///dev/shm/file.html    # Firefox fails to render, with permission denied
    firefox file:///dev/shm              # Firefox renders the directory as expected
    
    sudo umount /dev/shm                 # Remove the tmpfs filesystem
    cp /tmp/file.html /dev/shm
    
    firefox file:///dev/shm/file.html    # Firefox STILL fails to render, with permission denied
    

    此外

    sudo mkdir /mnt/shm
    sudo mount -t tmpfs /mnt/shm         # Mount a tmpfs filesystem elsewhere
    cp /tmp/file.html /mnt/shm
    
    firefox file:///mnt/shm/file.html    # Firefox renders as expected
    

    Ubuntu 22.04 使用“Snap”版 Firefox 作为其标准安装的一部分,此类应用程序被沙盒化,无法访问大部分文件系统中的文件(包括目录中的文件,/dev/shm但不包括目录本身)。此外,可访问目录集不可配置。


    相关参考

    • https://askubuntu.com/questions/1388679/snap-applications-firefox-and-chromium-snap-cannot-open-folders-mounted-via-ss#comment2398571_1388679
    • https://askubuntu.com/questions/1184357/why-cant-chromium-suddenly-access-any-partition- except-for-home#comment1978874_1184357
    • https://www.reddit.com/r/Ubuntu/comments/155txyp/snap_has_no_permission_to_access_devshm/
    • 如何禁用 snap 文件系统沙盒
    • 是的,挂载点列表确实是硬编码的
    • 10

相关问题

  • 如何忽略主机文件?[关闭]

  • 选择在哪个浏览器中打开链接

  • AkamaiGlobalHost 上的文件使用浏览器下载,但不使用 curl

  • 如何通过命令行浏览器重置路由器?[关闭]

  • 浏览器不再播放 Flash (.swf) 文件

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve