Bluemix容器系统更新udev的问题

Bluemix 更新 udev 的问题

最近在 IBM Bluemix 管理控制台中查看容器状态时发现一直会报 策略违例 问题,进入容器详细信息界面,可以看到漏洞顾问程序扫描到的容器系统中存在的违例情况,主要是系统中某些软件包版本比较老,Bluemix 建议进行安全更新升级:

Bluemix容器策略违例

由于我的 Bluemix 容器使用的是 Ubuntu 14.04 系统,起初想着直接运行 apt-get 命令将系统中的软件包都进行升级应该就差不多可以搞定了:

root@instance-007a20ff:~# apt-get update
root@instance-007a20ff:~# apt-get upgrade

但是在升级 udev 软件包的时候发现能正确下载软件包但升级失败,提示 /etc/modprobe.d 内核模块配置目录无法正常写入:

root@instance-007a20ff:~# apt-get install udev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be upgraded:
  udev
1 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.
28 not fully installed or removed.
Need to get 735 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main udev amd64 204-5ubuntu20.19 [735 kB]
Fetched 735 kB in 1s (437 kB/s)
(Reading database ... 30255 files and directories currently installed.)
Preparing to unpack .../udev_204-5ubuntu20.19_amd64.deb ...
Adding 'diversion of /bin/udevadm to /bin/udevadm.upgrade by fake-udev'
Unpacking udev (204-5ubuntu20.19) over (204-5ubuntu20.15) ...
dpkg: error processing archive /var/cache/apt/archives/udev_204-5ubuntu20.19_amd64.deb (--unpack):
 unable to create `/etc/modprobe.d/fbdev-blacklist.conf.dpkg-new' (while processing `./etc/modprobe.d/fbdev-blacklist.conf'): Permission denied
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Removing 'diversion of /bin/udevadm to /bin/udevadm.upgrade by fake-udev'
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 /var/cache/apt/archives/udev_204-5ubuntu20.19_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我如果跳过升级 udev 包,又会由于 cpio 等软件包依赖新版本的 udev 包导致其它的软件包也无法正常升级,因此最好能解决 udev 包的升级问题。

接着我测试在报错的 /etc/modprobe.d 目录中创建文件或者拷贝文件,发现始终都是报 Permission denied 错误。看起来很有可能是由于 Bluemix 容器的限制导致无法在该目录中进行写操作。要解决 udev 包升级的问题看来需要重新打包 udev 进行安装。

重新打包 udev

首先使用 apt-get 命令下载最新版本的 udev 安装包:

root@instance-007a20ff:~# apt-get download udev
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main udev amd64 204-5ubuntu20.19 [735 kB]
Fetched 735 kB in 0s (905 kB/s)

创建用于解压缩及重新构建 deb 包的目录:

root@instance-007a20ff:~# mkdir extract extract/DEBIAN build

开始解压缩 deb 安装包中的文件以及专用的 control 文件:

root@instance-007a20ff:~# dpkg -X udev_204-5ubuntu20.19_amd64.deb extract/
root@instance-007a20ff:~# dpkg -e udev_204-5ubuntu20.19_amd64.deb extract/DEBIAN/

接着就可以删除不需要的 fbdev-blacklist.conf 文件了,需要注意的是 control 目录中也需要移除对应项:

root@instance-007a20ff:~# rm -f extract/etc/modprobe.d/fbdev-blacklist.conf
root@instance-007a20ff:~# sed -i '/fbdev-blacklist.conf/d' extract/DEBIAN/conffiles

最后就可以打包新的 deb 安装文件了:

root@instance-007a20ff:~# dpkg-deb -b extract build
dpkg-deb: warning: 'extract/DEBIAN/control' contains user-defined field 'Original-Maintainer'
dpkg-deb: warning: ignoring 1 warning about the control file(s)

dpkg-deb: building package `udev' in `build/udev_204-5ubuntu20.19_amd64.deb'.

升级 udev 相关软件包

到这一步就可以直接用 dpkg 命令安装我们重新打包的 udev 安装文件了:

root@instance-007a20ff:~# dpkg -i build/udev_204-5ubuntu20.19_amd64.deb
(Reading database ... 30255 files and directories currently installed.)
Preparing to unpack .../udev_204-5ubuntu20.19_amd64.deb ...
Adding 'diversion of /bin/udevadm to /bin/udevadm.upgrade by fake-udev'
Unpacking udev (204-5ubuntu20.19) over (204-5ubuntu20.15) ...
dpkg: dependency problems prevent configuration of udev:
 udev depends on libdbus-1-3 (>= 1.0.2); however:
  Package libdbus-1-3:amd64 is not configured yet.
 udev depends on libudev1 (= 204-5ubuntu20.19); however:
  Package libudev1:amd64 is not configured yet.

dpkg: error processing package udev (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 udev

这里的报错信息可以先不用管,后面我们再运行 apt-get upgrade 命令升级完其它的软件包就没有问题了。此时用 dpkg 命令就可以检查新的 udev 包状态:

root@instance-007a20ff:~# dpkg -l udev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                   Version          Architecture     Description
+++-======================-================-================-=================================================
ii  udev                   204-5ubuntu20.19 amd64            /dev/ and hotplug management daemon

将 Bluemix 报告的有安全风险的软件包都进行升级,等到 Bluemix 重新进行漏洞扫描之后,再访问管理控制台就可以看到 Ubuntu 容器系统已经不会报策略违例了。

Bluemix容器系统更新udev的问题》上的评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注


*