Org*_*ble 30 login motd 20.04 esm
当我 ssh 进入我的机器时,我想禁止生成以下消息
Expanded Security Maintenance for Applications is not enabled.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
Run Code Online (Sandbox Code Playgroud)
由于某种原因(我不想推测原因),这些消息不是通过正常的 motd 进程发出的,而是似乎从update-notifier. motd 目录中有一些脚本似乎可以生成这些消息,但删除它们没有效果。
如何防止我的系统在登录时生成这些消息?
小智 35
这些消息的定义/usr/lib/update-notifier/apt_check.py没有标记来禁用它们。
这是一个 sed 命令,它将通过插入一条return语句作为消息函数的第一行来中性化生成消息的函数:
sudo sed -Ezi.orig \
-e 's/(def _output_esm_service_status.outstream, have_esm_service, service_type.:\n)/\1 return\n/' \
-e 's/(def _output_esm_package_alert.*?\n.*?\n.:\n)/\1 return\n/' \
/usr/lib/update-notifier/apt_check.py
Run Code Online (Sandbox Code Playgroud)
新旧文件的差异如下所示:
$ diff -u /usr/lib/update-notifier/apt_check.py{.orig,}
--- /usr/lib/update-notifier/apt_check.py.orig 2023-02-22 11:33:39.476095290 -0500
+++ /usr/lib/update-notifier/apt_check.py 2023-02-22 11:59:41.396527682 -0500
@@ -160,6 +160,7 @@
def _output_esm_package_alert(
outstream, service_type, disabled_pkg_count, is_esm=False
):
+ return
" output the number of upgradable packages if esm service was enabled "
outstream.write("\n")
if disabled_pkg_count > 0:
@@ -206,6 +207,7 @@
def _output_esm_service_status(outstream, have_esm_service, service_type):
+ return
if have_esm_service:
outstream.write(gettext.dgettext("update-notifier",
"Expanded Security Maintenance for "
Run Code Online (Sandbox Code Playgroud)
使用以下命令测试修复:
$ /usr/lib/update-notifier/apt_check.py --human-readable
1 update can be applied immediately.
To see these additional updates run: apt list --upgradable
Run Code Online (Sandbox Code Playgroud)
重新生成缓存的消息文件
sudo /usr/lib/update-notifier/update-motd-updates-available --force
Run Code Online (Sandbox Code Playgroud)
nob*_*ody 22
我发现避免此 esm 消息的最简单方法是注释掉 esm-repo
/var/lib/ubuntu-advantage/apt-esm/etc/apt/sources.list.d/ubuntu-esm-apps.list
# Written by ubuntu-advantage-tools
#deb https://esm.ubuntu.com/apps/ubuntu jammy-apps-security main
# deb-src https://esm.ubuntu.com/apps/ubuntu jammy-apps-security main
#deb https://esm.ubuntu.com/apps/ubuntu jammy-apps-updates main
# deb-src https://esm.ubuntu.com/apps/ubuntu jammy-apps-updates main
Run Code Online (Sandbox Code Playgroud)
使用例如 bash:
创建 .hushlogin 并将类似的内容添加到 init 文件(如 .bashrc_profile)中
grep 'immediately' /var/lib/update-notifier/updates-available
grep 'security' /var/lib/update-notifier/updates-available
grep 'upgradable' /var/lib/update-notifier/updates-available
/etc/update-motd.d/98-reboot-required
Run Code Online (Sandbox Code Playgroud)
登录时:
2 updates can be applied immediately.
To see these additional updates run: apt list --upgradable
*** System restart required ***
Run Code Online (Sandbox Code Playgroud)
请注意,/var/lib/update-notifier/updates-available 可能是模式 0600,因此您必须修复该问题。
| 归档时间: |
|
| 查看次数: |
10752 次 |
| 最近记录: |