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
    • 最新
    • 标签
主页 / server / 问题 / 974689
Accepted
DoRe
DoRe
Asked: 2019-07-11 05:16:45 +0800 CST2019-07-11 05:16:45 +0800 CST 2019-07-11 05:16:45 +0800 CST

升级到 buster 后加密的 qemu 虚拟机不启动:权限被拒绝

  • 772

我正在使用 libvirt 的 debian 主机上运行加密的 qemu 虚拟机。

为了设置机器,我采取了以下步骤:

  1. 将加密密钥放在一个文件$secretfile中/etc/libvirt/secret
  2. 创建图像:qemu-img create --object secret,id=sec0,file=$secretfile,format=raw -f qcow2 -o encrypt.format=luks,encrypt.key-secret=sec0 $vmfile $size
  3. 根据需要设置 VM
  4. 将虚拟机导入 virt:virt-install -n $theName -r 2048 --os-type=linux --os-variant=debian9 --connect=qemu:///system --import --network=network:default --vnc --qemu-commandline="--object secret,id=sec0,file=$secretfile -drive driver=qcow2,file.filename=$vmfile,encrypt.key-secret=sec0" --disk none --cpu host --import

这适用于主机系统上的 debian 拉伸

升级到debian buster后,虚拟机启动失败,如下

error: Failed to start domain Feigenbaum
error: internal error: process exited while connecting to monitor: 2019-07-08T11:32:00.290494Z qemu-system-x86_64: --object secret,id=sec0,file=/etc/libvirt/secret/Feigenbaum.secret: Unable to read /etc/libvirt/secret/Feigenbaum.secret: Failed to open file “/etc/libvirt/secret/Feigenbaum.secret”: Permission denied

我的第一个猜测是,apparmor在 buster 中是新的,阻止访问/etc/libvirt/secret/

但是,如果我将 apparmor 设置为抱怨模式,问题仍然存在,据我所知,这应该停止阻止对秘密文件的访问:

aa-complain /usr/sbin/libvirtd
  • 我对 apparmor 很陌生:我如何确保 apparmor 不会干扰?
  • 还有哪些其他机制可以阻止对机密文件的访问?

- 编辑 -

关于访问权限的评论,我认为它们设置正确。在升级之前它运行良好。运行 qemu-vm 的用户是否将 ugprade 更改为 buster?

ls -l /etc/libvirt/secret/Feigenbaum.secret 
-rw-r----- 1 root libvirt-qemu 61 Mar  8 14:13 /etc/libvirt/secret/Feigenbaum.secret

ls -ld /etc/libvirt/secret/
drwxrwx--- 2 libvirt-qemu libvirt-qemu 102 Mar  8 14:13 /etc/libvirt/secret/

ls -ld /etc/libvirt/
drwxr-xr-x 7 root root 4096 Jul  8 11:51 /etc/libvirt/

ls -ld /etc/
drwxr-xr-x 103 root root 8192 Jul 10 06:35 /etc/

- 编辑 -

报告为 debian 的错误:https ://bugs.debian.org/cgi-bin/bugreport.cgi?bug=933385

debian
  • 1 1 个回答
  • 722 Views

1 个回答

  • Voted
  1. Best Answer
    DoRe
    2019-07-31T21:55:25+08:002019-07-31T21:55:25+08:00

    感谢 debian 项目的 Guido,我能够解决这个问题。

    Apparmor 确实阻止了对秘密文件的访问。

    不支持 qemu-commandline 选项,这使得 apparmor 无法正确设置访问权限。这可以在 中手动配置/etc/apparmor.d/libvirt/TEMPLATE.qemu。该文件需要从

    #
    # This profile is for the domain whose UUID matches this file.
    #
    
    #include <tunables/global>
    
    profile LIBVIRT_TEMPLATE flags=(attach_disconnected) {
      #include <abstractions/libvirt-qemu>
    }
    

    至

    #
    # This profile is for the domain whose UUID matches this file.
    #
    
    #include <tunables/global>
    
    profile LIBVIRT_TEMPLATE flags=(attach_disconnected) {
      #include <abstractions/libvirt-qemu>
      /etc/libvirt/secret/** r,
      /var/lib/libvirt/images/** rwk,
    }
    

    更好的解决方案是通过 libvirt 使用卷加密,如下所述:https ://libvirt.org/formatstorageencryption.html#StorageEncryption 。这应该允许 apparmor 设置正确的访问权限。

    • 1

相关问题

  • 关闭 FTP

  • 如何在同一台电脑上从 putty 连接 debian vmware

  • debian- 文件到包的映射

  • Debian Ubuntu 网络管理器错误 [关闭]

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

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

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve