如何在安装之前检查和验证deb软件包?

我想在安装之前尽可能了解有关 .deb 包的所有信息。在常规的软件包构建过程中会生成大量的元数据,而且我知道还有来自发行库的签名软件包。

这不是我要找的答案。当然,我可以用 file-roller 打开软件包,并以此方式找到构建日期,但我想超越这一点。我想到的是类似于在 Firefox 中检查 TLS 证书的方法。

关键问题如下:
  • 软件包是何时构建的?
  • 如果可能的话,由谁或在何处构建的?
  • 有哪些依赖项?(链接到完整答案)
  • 软件包是否已签名?
    • 由谁或什么签名的?
关于最后一点,我知道有关 .dsc 文件的情况,尽管通常这些文件并不在第三方网站上提供。(也许我们应该提高这方面的意识,以便将来能够改变这种情况。)
你可以以谷歌浏览器作为第三方软件包的示例。
6个回答

使用这个:
dpkg-deb --info <deb file>

如果需要签名,最好使用apt工具。

像魔法一样有效地工作 - Alex

普通的deb文件并不包含你所需要的所有数据,除非你通过`dpkg-deb --info`命令或查看`DEBIAN/control`文件来获取。
如果你从launchpad或官方软件源下载,可以获得带有这些数据的dsc文件。
deb文件默认情况下没有签名。一般建议不要从你不信任的网站安装deb软件包。
Debian软件包中没有特殊的安全工具。

你所需要的只是
dpkg -I package.deb

这是我电脑上一个名为hostapd_2.1-0ubuntu1.2_amd64.deb的软件包的示例输出。
 ~$ dpkg -I '/home/mark/hostapd_2.1-0ubuntu1.2_amd64.deb' 
 new debian package, version 2.0.
 size 422472 bytes: control archive=2619 bytes.
      66 bytes,     3 lines      conffiles            
    1537 bytes,    31 lines      control              
    1085 bytes,    15 lines      md5sums              
    1375 bytes,    53 lines   *  postinst             #!/bin/sh
     359 bytes,    14 lines   *  postrm               #!/bin/sh
     570 bytes,    30 lines   *  preinst              #!/bin/sh
     204 bytes,     7 lines   *  prerm                #!/bin/sh
 Package: hostapd
 Source: wpa (2.1-0ubuntu1.2)
 Version: 1:2.1-0ubuntu1.2
 Architecture: amd64
 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
 Installed-Size: 1219
 Depends: libc6 (>= 2.15), libnl-3-200 (>= 3.2.7), libnl-genl-3-200 (>= 3.2.7), libssl1.0.0 (>= 1.0.1), lsb-base (>= 3.2-13), initscripts (>= 2.88dsf-13.3)
 Section: net
 Priority: optional
 Multi-Arch: foreign
 Homepage: http://w1.fi/wpa_supplicant/
 Description: user space IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
  Originally, hostapd was an optional user space component for Host AP
  driver. It adds more features to the basic IEEE 802.11 management
  included in the kernel driver: using external RADIUS authentication
  server for MAC address based access control, IEEE 802.1X Authenticator
  and dynamic WEP keying, RADIUS accounting, WPA/WPA2 (IEEE 802.11i/RSN)
  Authenticator and dynamic TKIP/CCMP keying.
  .
  The current version includes support for other drivers, an integrated
  EAP authenticator (i.e., allow full authentication without requiring
  an external RADIUS authentication server), and RADIUS authentication
  server for EAP authentication.
  .
  hostapd works with the following drivers:
  .
   * mac80211 based drivers with support for master mode [linux]
   * Host AP driver for Prism2/2.5/3 [linux]
   * Driver interface for FreeBSD net80211 layer [kfreebsd]
   * Any wired Ethernet driver for wired IEEE 802.1X authentication.
 Original-Maintainer: Debian/Ubuntu wpasupplicant Maintainers <pkg-wpa-devel@lists.alioth.debian.org>

还有一个随机的名字叫做 pulseaudio_6.0-90-g75dd2-1_amd64.deb

~$ dpkg -I '/home/mark/pulseaudio/pulseaudio_6.0-90-g75dd2-1_amd64.deb' 
 new debian package, version 2.0.
 size 1421422 bytes: control archive=314 bytes.
       0 bytes,     0 lines      conffiles            
     222 bytes,     9 lines      control              
 Package: pulseaudio
 Priority: extra
 Section: checkinstall
 Installed-Size: 8144
 Maintainer: root@Ubuntu
 Architecture: amd64
 Version: 6.0-90-g75dd2-1
 Provides: pulseaudio
 Description: Package created with checkinstall 1.6.2

这个包裹是什么时候建造或提供的? - Reinier Post

对于通过配置的软件源可用的软件包,可以尝试使用以下命令:
``` apt-cache show ```
你将会得到很多元数据(维护者、原始维护者、依赖关系、MD5),但可能并不是你所寻找的全部内容。

2请仔细阅读:安装之前 - LiveWireBT
2这仅适用于存储库。 - Pilot6

我想提供一个基于GUI的桌面用户友好的解决方案。我正在使用Ubuntu Mate 18.04。

  1. 双击.deb文件。它会在Gdebi中打开。如果尚未安装,您可以使用sudo apt-get install gdebi命令安装Gdebi。

    enter image description here

  2. 当您双击.deb文件时,您可以找到软件包的名称、依赖项、将安装在何处以及更多信息。

  3. 如果决定安装该软件包,请使用Install Package


验证完整性的最佳方法是通过其他证明来确认您的SHA256是否与预期的SHA256相符。

一个由一个小型社区控制的git,就像一个区块链一样,是一个可靠的验证完整性的来源,并且在社区的所有克隆中都不可能进行中间人攻击。

有一些筛选出的SHA256结果吗?

我们可以创建一个Github存储库,其中包含一个简单的CSV完整性检查,但您至少需要信任维护CSV的社区。

例如google-chrome-stable_current_amd64.deb

  • dpkg-deb --info google-chrome-stable_current_amd64.deb说:"... 大小为103884100字节:控制归档=15708字节(...)软件包:google-chrome-stable(...)版本:119.0.6045.159-1"

  • sha256sum google-chrome-stable_current_amd64.deb说:"c409bb6cfb279c90fb516353b4728cbf97a71e8deb33dc3433cd503ea65594fe"

  • 所以,CSV看起来像:

    file,size,size_cntrl,package,version
    google-chrome-stable_current_amd64.deb,103884100,15708,c409bb6cfb279c90fb516353b4728cbf97a71e8deb33dc3433cd503ea65594fe,119.0.6045.159-1
    ...deb,...,...,...,...
    

    或者,在CSV查看器中:
    文件 大小 大小控制 版本 SHA256
    google-chrome-stable_current_amd64.deb 103884100 15708 119.0.6045.159-1 c409bb6cfb279c90fb516353b4728cbf97a71e8deb33dc3433cd503ea65594fe
    ...deb ... ... ... ...

    PS:检查后,如果SHA256正确,执行以下操作进行安装:

    1. 使用dpkg-deb --info google-chrome-stable_current_amd64.deb命令检查软件包名称。
    2. 使用sudo dpkg -r google-chrome-stable命令将其移除。
    3. 使用sudo dpkg --install google-chrome-stable_current_amd64.deb命令进行安装。