rpm & signature
我们使用RPM数据库(/var/lib/rpm)来比对rpm安装后的软件有无改动
- rpm -qp --requires *.rpm query list capabilities required by package(s)
- rpm --verify -a 校验所有已安装的rpm包
- rpm --verify openssh-server 有改动才会输出,否则无输出
- rpm --verify -v openssh-server 显示所有文件
- rpm --verify -f /etc/pam.d/sshd 单独验证某个文件
表示文件的9个属性信息
- S file Size differs 文件大小是否被改动
- M Mode differs(includes permissions and file type) 文件的属性和类型是否被改动
- 5 MD5 sum differs MD5内容是否被改动
- D Device major/minor number mismatch 设备的主/次代码是否被改动
- L readLink(2) path mismatch Link路径是否被改动
- U User ownership differs 文件的所有人是否被改动
- G Group ownership differs 文件的组是否被改动
- T mTime differs 文件的修改是否是否被改动
- P caPabilities differ
表示文件格式的信息
- c %config configuration file 配置文件
- d %doc documentation file 文档文件
- g %ghost file 通常是该文件不会被某个燃机所包含 较少发生
- l %license license file 许可证文件
- r %readme readme file 自述文件
RPM数字签名:
这里主要从制作RPM的时候加入数字签名,这里用的是GPG。
这里简单说明一下GPG与PGP不同之处。来自与Fedora_RPM_documentation
GPG and PGP? Acronyms Explained
The RPM documentation uses GPG and PGP pretty much interchangeably, so much so, in fact, that you may think these are typographical errors. Not so.
PGP stands for Pretty Good Privacy. Invented by Phil Zimmerman, PGP was originally invented to encrypt e-mail to allow for private communication. Based on a public-key cryptography algorithm, PGP also supports encrypted digital signatures. These signatures allow you to verify that a package you have downloaded really comes from the vendor you think it does. You do this by using the vendor’s public key.
GPG stands for GNU Privacy Guard, a free, open-source implementation of PGP from the GNU project. GPG aims to be compatible with the OpenPGP Internet standard as defined in RFC 2440. It started when a number of developers wanted a free implementation. One such free implementation, GPG, allows Linux vendors such as Red Hat to include PGP in their products. So, in a sense, GPG provides PGP.
PGP has a long and somewhat troubled history as an open-source product and as a commercial product. See www.philzimmermann.com for background on PGP and its long history. See www.gnupg.org for more details on GPG.
- 创建数字认证之前要确保gpg-agent在运行,因为需要它穿件一个socket或者pipe用于连接 $gpg-agent --daemon --use-standard-socket
- 创建数字认证的时候不要用su之后的用户 如果用的话gpg-agent将会失败 gpg-agent fails to launch/usr/bin/pinentry (which in turn decides whether to launchpinentry-curses, or a QT or GTK equivalent).
一旦有了数字认证key,就可以在制作RPM的时候设置相关数字签名宏。添加下面的代码到$HOME/.rpmmacros
1 %_signature gpg
2 %_gpg_path /root/.gnupg
3 %_gpg_name uid
4 %_gpgbin /usr/bin/gpg
制作rpm时添加
rpmbuild -ba --sign xxx.spec
制作完成后添加
rpm --addsign name-version-release.rpm
修改rpm数字签名
rpm --resign name-version-release.rpm
验证rpm包数字签名
rpm -K [-vv] name-version-release.rpm
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律